
/*
new ActiveXObject("Msxml2.XMLHTTP");
new ActiveXObject("Microsoft.XMLDOM");
new ActiveXObject("MICROSOFT.XmlHttp");
new XMLHttpRequest();
*/

/*
function XmlHttpRes (sUri, sParam, async, postMethod)
{
	if (async == null){
		async = false;
	}
	
	oXML = new ActiveXObject("MICROSOFT.XmlHttp");	

	oXML.Open("GET", sUri, async);
	oXML.Send(sParam)
	
	return oXML;
}
*/

//Send and XMLHttp request.
function sendXMLHTTP(sURI, sParam, async, postMethod)
{
	//Set default values :
	var sAsync = ((typeof(async) == "undefined") || (async == "")) ? false : async ;
	var sParam = ((typeof(sParam) == "undefined") || (sParam == "")) ? null : sParam ;
	var sPostMethod = (typeof(postMethod) == "undefined")? "GET" : postMethod ;
	
	//Get the xml object.
	var xmlHttp = getActiveXObjectType();
	
	//Send request to the server.
	xmlHttp.open(sPostMethod, sURI, sAsync);
   	xmlHttp.send(sParam);

	return xmlHttp;
}

//Decide the type of the xml object according to the browser type.
function getActiveXObjectType(xmlhttp)
{
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  	try{
	  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
	  	}
	  	catch (e)
	  	{
	  		try {
	  			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 		} 
			catch (e) {
	  			try{ 
	  				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	  			} 
				catch (e) { 
					xmlhttp = false; 
				}
	 		}
	 	}
	@else
	 	xmlhttp=false
	@end @*/
	
	if (!xmlhttp) {
		try { xmlhttp = new XMLHttpRequest(); }
		catch (e){ xmlhttp = false; }
	}

	return xmlhttp;
}

function checkState()
{
	if (xmlHttp.readyState==4)
	{
	
		/*
		*/
	}
}

//Calls the page that contains the print mechanism.
function printDocument(oElement)
{
	//Client side format.
	top.frames["frame_hidden"].doPrintDocument(oElement);		//Calls the print function in the blenk.aspx file to handle the print action.
}

//Returns a string representing the UTC date and time.
function getUtcTime()
{
	var oDate = new Date();
	
	var date = (oDate.getUTCMonth() + 1) + "/";
	date += oDate.getUTCDate() + "/";
	date += oDate.getUTCFullYear();
	
	var sHours = oDate.getUTCHours() + "";
	if(sHours.length == 1){
		sHours = "0" + sHours;
	}
	
	var sMinutes = oDate.getUTCMinutes() + "";
	if(sMinutes.length == 1){
		sMinutes = "0" + sMinutes;
	}
	
	var sSeconds = oDate.getUTCSeconds() + "";
	if(sSeconds.length == 1){
		sSeconds = "0" + sSeconds;
	}

	return date + " " + sHours + ":" + sMinutes + ":" + sSeconds + " (UTC)";	
}


//Mask function: masks non numeric keys from text fields.
function fMaskNonNumericKey(objEvent) 
{	
	var iKeyCode;
	iKeyCode = objEvent.keyCode;
	
	if ((iKeyCode>57 || iKeyCode<48) && iKeyCode != 9)
	{
		objEvent.returnValue = false;
	}
}
/*
//mask function: masks non numeric keys
function fMaskNonNumericKey(objEvent) 
{	
	var iKeyCode;
	iKeyCode = objEvent.keyCode;
	if (iKeyCode>57 || iKeyCode<48)
	{
		objEvent.returnValue=false;
	}
}
*/

function setCreditCardFocus()
{
	if(fMaskNonNumericKey(event) != false)
	{
		var oElement = event.srcElement;
		var sElementId = oElement.id.substr(0, oElement.id.length -1);
		var iElementIndex = parseInt(oElement.id.substr(oElement.id.length -1, 1));
		
		if(oElement.value.length == 4 && iElementIndex < 4 && oElement.value != "****")
		{
		    document.getElementById(sElementId + (iElementIndex + 1)).value = "";
			document.getElementById(sElementId + (iElementIndex + 1)).focus();
		}
	}
	else{
		return false;
	}
}


function showProcessState(oDocument)
{
	//alert('0');
	top.window.status = "Please wait processing...";
	//top.frames['frame_center'].frames['frame_main'].status.style.color = "red";
}

function hideProcessState()
{
	//alert('1');
	top.window.status = "Done";
}

function OpenOrClose(theID)
{
	if (document.getElementById(theID).style.visibility == "hidden")
		document.getElementById(theID).style.visibility = "visible";
	else
		document.getElementById(theID).style.visibility = "hidden";
		
	if (document.getElementById(theID).style.display == "none")
		document.getElementById(theID).style.display = "block";
	else
		document.getElementById(theID).style.display = "none";
}
