//<Script>
//alert("common")
var gCallbackptr = null;
var MESSAGE_NO			= 1;
var MESSAGE_YES			= 2;
var MESSAGE_CANCEL		= 4;
var COL_DELIMITER		= '@#@';	
	
	function setCursorStyle(objControl, strStyle)
	{
		switch(strStyle.toLowerCase())
		{			
			case "auto":
				objControl.style.cursor = "auto";
				break;
				
			case "default":
				objControl.style.cursor = "default";
				break;
				
			case "crosshair":
				objControl.style.cursor = "crosshair";
				break;
				
			case "hand":
				objControl.style.cursor = "hand";
				break;
				
			case "move":
				objControl.style.cursor = "move";
				break;
				
			case "wait":
				objControl.style.cursor = "wait";
				break;
				
			case "text":
				objControl.style.cursor = "text";
				break;
				
			case "help":
				objControl.style.cursor = "help";
				break;
				
			case "bottom-right resize":
				objControl.style.cursor = "se-resize";
				break;
				
			default :
				objControl.style.cursor = null;
				break;
		}
	}
	
	//This function will truncate the string to the given length and add "..." at the end of it
	function Truncate(strSource, Length)
	{
			var strReturn = '';
			var strSuffix = '...';
			strSource = strSource + '';

			if (strSource.length == 0)
			{
				strReturn = '';
			}
			else
			{
				strSource = Trim(strSource);
				//strSource = escape(strSource);
				
				if (strSource.length > Length)
				{
					strReturn = strSource.substring(0, Length);
					strReturn = strReturn + strSuffix;
				}
				else
				{
					strReturn = strSource;
				}

			}
			return strReturn;	
	
	
	}
	
	
	function Trim(strTrimMe)
	{	
		strTrimMe += "";

		// alert(typeof(strTrimMe));

		// Check if anything was passed at all
		// if undefined
		if(typeof(strTrimMe)== typeof(void(0)))
			return '';
			
		if(strTrimMe.toString() == '')
			return '';			

		// DevDebug
		// strTrimMe = strTrimMe.toString();
			
		// This function is supposed to trim a string from the left and the right.  
		// Could be done, cleaner, but ...

		var intStart = parseInt(strTrimMe.length, 10);
		var intLast = 0;
		
		// Find the first non-white space character
		for ( var i = 0; i < strTrimMe.length; i++ )
			if (strTrimMe.charAt(i) != ' '){ 					 
				intStart = i;
				break;
			}


		// Find the last non-white space character
		for ( var i = (strTrimMe.length - 1); i >= intStart; i-- )
			if (strTrimMe.charAt(i) != ' '){ 
				intLast = i; // Found the first non-whitespace 
				break;
			}
					
		// See the definition of substring()
		//alert(strTrimMe.substring(intStart, (intLast + 1)) + ': First: ' + strTrimMe.substring(intStart, intLast).length + ' Last: ' + intStart + ' End: ' + intLast + ' ' ); // DevDebug
					
		if (intLast < intStart)
			return '';
		else
			return strTrimMe.substring(intStart, (intLast + 1));
				
	}
	
// Description : Minimize/Maximize table

	
// Added by Ramesh Singhvi for a required Numberic validation
function IsNumber(NewText)
{ 
	var pattern = /[^0-9]/; 
	if (NewText.value.match(pattern) != null || NewText.value==""){
		return false; 
	} 
	else{
		return true; 
	} 
}


function setMessage(strMessage)
{
	// The function will receive save text message as parameter and display in span as text based on the propoer class
	// Message will be remove from the screeen after 10 second
	
	document.all['tdMessage'].style.visibility = 'visible';
	document.all['tdMessage'].className='Message';
	document.all['tdMessage'].innerHTML = strMessage;	
	window.setTimeout("document.all['tdMessage'].style.visibility = 'Hidden';",10000);
}		

function setErrorMessage(strMessage)
{
	var ss;
	var StrSplitData;
	var strMsg;
		
	
	if(strMessage.indexOf("<Description") > -1)
		{
			ss = strMessage.split("<Description>");
			StrSplitData=(ss[1]);
			strMsg=StrSplitData.split("</Description>");
			strMessage=strMsg[0];
		}
	
	document.all['tdMessage'].style.visibility = 'visible';
	document.all['tdMessage'].className='ErrorMessage';
	document.all['tdMessage'].innerHTML = strMessage;	
	
}

function clearMessage()
{
	document.all['tdMessage'].style.visibility = 'hidden';
}


// supress input of alpha & special chars in date fields
function checkDate(e) //numeric and /
{ 
	if (e.keyCode != 13) // ignore non-numeric keys
	{
		if ((e.keyCode < 47) || (e.keyCode > 57))
		{
			e.keyCode = 0;
			return true;
		}
	}
	if (document.all)
		if (e.keyCode == 13)
			return false;
	else
		if (e.which == 13)
			return false;
							
	return true;
}	

function CheckCharLimt(control, e, maxlength)
{
	if(control.value.length >= maxlength)
	{
		alert('This field can contain only ' + maxlength + ' characters. Current: ' + control.value.length + ' characters.');
		e.keyCode = 0
		return false;
	}
}

function checkNumber(e)
{
	if (e.keyCode != 13) // ignore non-numeric keys
	{
		if ((e.keyCode < 48) || (e.keyCode > 57))
		{
			e.keyCode = 0;
			return true;
		}
	}
	if (document.all)
		if (e.keyCode == 13)
			return false;
	else
		if (e.which == 13)
			return false;
							
	return true;

}

function checkAlphaNumeric(e)
{
	if (e.keyCode != 13) // ignore non-numeric keys
	{
		//if ((e.keyCode < 48) || (e.keyCode > 57))
		if(!( (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 97 && e.keyCode <= 122)))
		{
			e.keyCode = 0;
			return true;
		}
	}
	if (document.all)
		if (e.keyCode == 13)
			return false;
	else
		if (e.which == 13)
			return false;
							
	return true;

}
function displayPopup(URL, windowName, Width, Height, ScrollBars)
{
	var w = screen.width;
	var h = screen.height;
	var pW;
	var pH;
	if(!ScrollBars)
		ScrollBars = "no";
		
	if(Width) 
		pW = Width;
	else
        pW = 600;
        
    if(Height)
        pH = Height;
    else
        pH = 400;
    
	var posLeft = (w - pW)/2;
	var posTop	= (h - pH)/2;
		        
	popupWindow = window.open(URL, windowName, "top=" + posTop + ",left=" + posLeft + ",height=" + pH + ",width=" + pW + ",scrollbars=" + ScrollBars);
	popupWindow.focus();
	return popupWindow;
}        

function addLeadingZeros(control, maxlength)
{
	if(control.value.length < maxlength && control.value.length > 0)
	{
		var i;
		var sZeros = '';
		for(i=0; i< maxlength - control.value.length; i++)
		{
			sZeros += '0';
		}
		control.value = sZeros + control.value; 
	}

}

function ValidateEmailFormat(val)
{
//Validating the email field
var re =/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (! val.match(re)) {
    return (false);
}
return(true);
}


//</script>
