// JavaScript Document

/* 
Purpose : Checking for obj availabe and Its Not Blank Value*/
function checkValidNull(obj, msg)
{
	if(obj)
    {   
     	if(Trim(obj.value)=="")
        {
			alert(msg);
			obj.focus();
			return false;
		}
	}
    else
    {   
		return false;	
	}
	return true;	
}

function Trim(s) 
{
	return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function AllCharacters(obj)
{
var code=obj.keyCode?obj.keyCode:obj.charCode;
if ((code>=65 && code <=90 ) || (code>=97 && code <=122) || code==8 || code==9 || code==127 || code==32 || code==46 || code==46 || code==13)
return true;
else
return false;
}

function AllowPhoneNumber(obj)
{
var code=obj.keyCode?obj.keyCode:obj.charCode;
/////// code= 8 (backspace) code== 46 (delete) code == 45 ('-') code == 13 ('enter')	
if ( (code >=48 && code <=57 ) || code==190 || code==8 || code == 46 || code == 40 || code == 41 || code == 43 || code == 45 || code == 9 || code ==  13)
	return true;
else
	return false;
}


function AllDigits(obj)
{
var code=obj.keyCode?obj.keyCode:obj.charCode;
//alert(code);
/////// code= 8 (backspace) code== 46 (delete) code == 45 ('-') code == 13 ('-')
if ( (code >=48 && code <=57 ) || code==190 || code==8 || code == 9 || code == 46 || code ==  13)
	return true;
else
	return false;
}

function checkValidPhoneFormate(obj, msg)
{
	chk1="+.1234567890()- ";
	flag=false;
	if(obj)
	{
		value=obj.value;
		if(Trim(value)!="")
		{
			len=obj.value.length;
			for(i=0;i<len;i++)
			{
				ch1=value.charAt(i);
				rtn1=chk1.indexOf(ch1);
				if(rtn1==-1)
					flag=true;
			}
		}
	}else{
		flag=true;
		msg='Object is not Avaible';
	}
	if(flag)
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}




function checkZipCode(events,country)
{
   var unicodes=events.charCode? events.charCode :events.keyCode
   if (unicodes!=8){ //if the key isn't the backspace key (which we should allow)
        if(country != 'US' && ((unicodes>47 && unicodes<58)||(unicodes>64 && unicodes<91) || (unicodes>96 && unicodes<123) || unicodes ==  13 || unicodes ==  46) )
            return true;
		else if(country == 'US' && ((unicodes>47 && unicodes<58) || unicodes ==  13 || unicodes ==  46))
            return true;
		else
			return false;	 //disable key press
	}	
}

function openWindow(destination,height,width)
 {
	var targetWindow = destination;
	var x = Math.random();
	x = x * 1000;
	x = Math.round(x);
	var wind = "window" + x
	temp = window.open(targetWindow, wind, config='height=' + height + ',width=' + width + ',toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no, directories=no,status=yes,left=200,top=100');
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
	{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
	}
catch (e)
	{
	// Internet Explorer
	try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
	catch (e)
    {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

