function loadContent(id, msg, cfm, sid) {
	if (sid!='') { var fulled = notEmpty(sid); if (!fulled) { alert('Can not process blank field!'); return false; } }
	if (cfm!='') { var answer = confirm(cfm); if (!answer) return false; }
	$.blockUI({
		overlayCSS: { backgroundColor: '#ffffff' },
		css: { padding: '10px', backgroundColor: '#FFFFFF', opacity: .8, color: '#000000', font: 'bold 14px tahoma', border: '4px solid #cae4ff', width: '30%' },
		message: msg+', please wait...<br /><br /><img src="/images/icon_loading.gif" border="0">' });
		$("#showed").load('/libs/'+id, function() { setTimeout($.unblockUI, 300); });
}

function notEmpty(sid) {
	var myTextField = document.getElementById(sid);
	if (myTextField.value != "") return true
	else return false
}

function ajaxLoading(id,url,msg,eval_str) {
	url="/libs/"+url;
	if(document.getElementById){var x=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();}
    if(x){x.onreadystatechange=function() {
        el=document.getElementById(id);
		//if (msg!='') { el.innerHTML='<div style="padding:180px 0 180px 0;font:bold 17px arial;color:gray">'+msg+', please wait ...<br /><img src="/images/loader.gif" border="0"></div>'; }
		el.innerHTML='<div style="padding:180px 0 180px 0;"><img src="/images/loader.gif" border="0"></div>';
        if(x.readyState==4&&x.status==200){
            el.innerHTML='';
            el=document.getElementById(id);
            el.innerHTML=x.responseText;
            eval(eval_str);
            }
        }
    x.open("GET",url,true);x.send(null);
    }
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		//if (objCheckBoxes[1].checked==true) { CheckValue = false; }
		for(var i = 0; i < countCheckBoxes; i++)
			//objCheckBoxes[i].checked = CheckValue;
			if (objCheckBoxes[i].checked==true) { objCheckBoxes[i].checked = false; } else { objCheckBoxes[i].checked = true; }
}

function s(field) { field.focus(); field.select(); }

function check_val(iSource) {
	var ins = document.getElementsByName(iSource);
	var i;
	var j=0;
	var vals= new Array();
	for(i=0;i<ins.length;i++)
	{
		if (ins[i].checked == true) { vals[j]=ins[i].value; }
		j++;
	}
	return vals;
}

function calcHeight(fid) {
//SH Iframe Height Auto Resize v.01
//Used to resize the height of IFRAME to fit the content without any scrollbar.
//Coded by Silvery Hat Hacker 2006
var page_height = document.getElementById(fid).contentWindow.document.body.scrollHeight;
document.getElementById(fid).height=page_height;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"><\/span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);