function MouseOut(Source, ElementName) 
{
	var e = document.getElementById(ElementName);
	if (e.style.display == 'none') Source.src = 'Images/max-btn.gif'; else Source.src = 'Images/min-btn.gif';
}

function MouseOver(Source, ElementName) 
{
	var e = document.getElementById(ElementName);
	if (e.style.display == 'none') Source.src = 'Images/max-btn-h.gif'; else Source.src = 'Images/min-btn-h.gif';
}


function CollapseExpandPane(Btn, ElementName)
{
    var vDate = new Date();
    vDate.setDate(90);
    var e = document.getElementById(ElementName);
    
    var vBlockValue
    if (window.navigator.appName == 'Opera') vBlockValue = ''; else vBlockValue = 'inline-block';
    
    if (e.style.display == 'none')
    {
        e.style.cssText = e.style.cssText.replace('none', vBlockValue);
        document.cookie = e.id+'Show=1; expires=' + vDate.toGMTString();
        Btn.src = 'Images/min-btn-h.gif';
    }
    else
    {
        e.style.display = 'none';
        document.cookie = e.id+'Show=0; expires=' + vDate.toGMTString();
        Btn.src = 'Images/max-btn-h.gif';
    }
}

eng=new Array(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,87,82,84,83,67,74,90);
geo=new Array(4304,4305,4330,4307,4308,4324,4306,4336,4312,4335,4313,4314,4315,4316,4317,4318,4325,4320,4321,4322,4323,4309,4332,4334,4327,4310,4333,4326,4311,4328,4329,4319,4331,91,93,59,39,44,46,96);


function keyfilter_num(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode!=46 &&charCode > 31 && (charCode < 48 || charCode > 57)) {
		status = "This field accepts numbers only."
		return false
	}
	status = ""
	return true
}

function keyfilter_dig(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ( charCode > 31 && (charCode < 48 || charCode > 57)) {
		status = "This field accepts numbers only."
		return false
	}
	status = ""
	return true
}

function ValidEmail(EmailAddr) {
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
	
	var SpecChar="!#$%^&*()'+{}[]\|:;?/><,~`" + "\"";
	var frmValue = new String(EmailAddr);
	var len = frmValue.length;
	
	if( len < 1 ) { return false; }
	for (var i=0;i<len;i++)
	{
				temp=frmValue.substring(i,i+1)
				if (SpecChar.indexOf(temp)!=-1)
		 		{
					return false;
				}
	}	
	
	if(!reg1.test(frmValue) && reg2.test(frmValue)) 
	{ 
		return true;
	}
	
	return false;
}

function keyfilter_alnum(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (!  ((charCode >= 48 && charCode <= 57)||(charCode >= 97 && charCode <= 122)||(charCode >= 65 && charCode <= 90)||charCode==95)  ) {
		status = "This field accepts 'a'-'z','A'-'Z','0'-'9' and '_' only."
		return false
	}
	status = ""
	return true
}

function makeGeo(ob,e) {
	code = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;	
	
	if (code==96) {
		document.getElementById('geoKeys').checked = !document.getElementById('geoKeys').checked;
		return false;
	}

	if (e.which==0) return true;
	
	if (!document.getElementById('geoKeys').checked) return true;
	


	//alert(' e.keyCode='+e.keyCode+'\n'+'e.which='+e.which+'\n'+'e.charCode='+e.charCode);
	
	var found = false;
	for (i=0; i<=geo.length; i++) {
		if (eng[i]==code) {
			c=geo[i];
			found = true;
		}
	}

	if ( found ) {
		if (document.selection) {
			sel = document.selection.createRange();
			if (sel.text==ob.value) {
					document.selection.clear();
					ob.value = String.fromCharCode(c);
			} else {
					sel.text = String.fromCharCode(c);
			}
		} else {
			if (ob.selectionStart || ob.selectionStart == '0') {
				ob.selectionStart				
				var startPos = ob.selectionStart;
				var endPos = ob.selectionEnd;
				ob.value = ob.value.substring(0, startPos) + String.fromCharCode(c) + ob.value.substring(endPos, ob.value.length);
				ob.selectionStart = startPos+1;
				ob.selectionEnd = endPos+1;
			} else {
				//ob.value = ob.value + String.fromCharCode(c);
				return true;
			}
		}
		return false;
	} else {
		return true;
	}

}

function isRadioSelected(name)
{
	var vRadio = document.getElementsByName(name);
	var i;
	
	for (i=0; i<vRadio.length; i++)
	{
	    if (vRadio.item(i).checked) return true
	}
	
	return false
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function SetCookie(cookieName,cookieValue) {
     var nDays = 1;
     var today = new Date();
     var expire = new Date();
     if (nDays==null || nDays==0) nDays=1;
     expire.setTime(today.getTime() + 3600000*24*nDays);
     document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}


function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
	offset = document.cookie.indexOf(search)
		if (offset != -1) { // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1)
			end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}


//<Inline Calculator by Me :)>

function inputOnKeyPress(e, IsNumeric, ArrowNavigation)
{
    e = (e) ? e : window.event
    var vSrc = e.srcElement? e.srcElement : e.target;
    var vKeyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    
    window.status=vKeyCode;
    
	if (ArrowNavigation)
	{
		if (vKeyCode == 40)
 		{
 			if (e.ctrlKey) return
	 		
 			for (i=vSrc.sourceIndex+1; i<document.all.length; i++)
     		{
     			var e = document.all(i);
     			if ((e.tagName == 'INPUT' || e.tagName == 'SELECT') && (e.disabled==false))
     			{
     				try
     				{
     					e.focus();
     					//e.keyCode = 0;
     					e.preventDefault? e.preventDefault() : e.returnValue = false;
	 		            return
     				}
     				catch (e) {}
     			}
     		}
	     	
     		return
 		}


 		if (vKeyCode == 38)
 		{
 			if (e.ctrlKey) return
	 		
 			for (i=vSrc.sourceIndex-1; i>=1; i--)
     		{
     			var e = document.all(i);
     			if ((e.tagName == 'INPUT' || e.tagName == 'SELECT') && (e.disabled==false))
     			{
     				try
     				{
     					e.focus();
     					//e.keyCode = 0;
     					e.preventDefault? e.preventDefault() : e.returnValue = false;
	 		            return
     				}
     				catch (e)
     					{}
	     			
     			}
     		}
	     	
     		return
 		}
 	}
     
    
    if (IsNumeric == true)
    {
		if ((vKeyCode == 13 || vKeyCode == 10) && e.ctrlKey) 
		{
			ValidateNumInput(e);
			e.preventDefault? e.preventDefault() : e.returnValue = false;
	 		return
		}

		if ((vKeyCode >= 48 && vKeyCode <= 57) 
			|| (vKeyCode == 99 && e.ctrlKey)     //Ctrl+C
			|| (vKeyCode == 118 && e.ctrlKey)     //Ctrl+V
			|| (vKeyCode == 120 && e.ctrlKey)     //Ctrl+x
			|| vKeyCode == 116  //F5
			|| vKeyCode == 8    //backspace
			|| vKeyCode == 9    //Tab
			|| vKeyCode == 10    //Enter in IE
			|| vKeyCode == 13    //Enter in Firefox
			|| vKeyCode == 37   //arrow left
			|| vKeyCode == 39   //arrow right
			|| vKeyCode == 42
			|| vKeyCode == 43
			|| vKeyCode == 45   //delete
			|| vKeyCode == 46   //delete
			|| vKeyCode == 47){}
	 	else
	 	{
	 		e.preventDefault? e.preventDefault() : e.returnValue = false;
	 		return
	 	}
	}	
}

function ValidateNumInput(e)
{
    var vSrc = e.srcElement? e.srcElement : e.target;
    vSrc.value = Calc(vSrc.value, 1);
}

function Calc(Formula, Operation) 
{
	var vOpSymbol, p, vOperation

    vOperation = Operation;

	switch (vOperation)
	{
		case 1:
			vOpSymbol = '-';
			break;
		case 2:
			vOpSymbol = '+';
			break;
		case 3:
			vOpSymbol = '/';
			break;
		case 4:
			vOpSymbol = '*';
			break;
	}

	p = Formula.indexOf(vOpSymbol);

    if (p>-1)
    {
		switch (vOperation)
		{
			case 1:
				    return Calc(Formula.substr(0, p), vOperation) - Calc(Formula.substr(p + 1), vOperation);
				    break;
			case 2:
				    return Calc(Formula.substr(0, p), vOperation) + Calc(Formula.substr(p + 1), vOperation);
				    break;
			case 3:
				    return Calc(Formula.substr(0, p), vOperation) / Calc(Formula.substr(p + 1), vOperation);
				    break;
			case 4:
				    return Calc(Formula.substr(0, p), vOperation) * Calc(Formula.substr(p + 1), vOperation);
				    break;
		}
	}        
    else
	{	    
        if (vOperation < 4)
        {
            vOperation = vOperation + 1;
            return Calc(Formula, vOperation);
        }
        else
        {
            if (Formula == '')
                return 0;
            else
                return parseNum(Formula);
        }
    }
}

function parseNum(Source)
{
	return(parseFloat(Source.replace(',','')));
}


//</Inline Calculator by Me :)>
