var okimg    = "<img src='images/true.gif' border=0>";
var nokimg   = "<img src='images/false.gif' border=0>";
var alertimg = "<img src='images/alert.jpg' border=0>";
function fnPaste(){event.returnValue=false;}
function isNull(obj,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=Trim(obj.value);
	if (obj1==""){
		alert("Please Enter  " +msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isSelNull(obj,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=obj.value;
	if (obj1==""){
		alert("Please Enter " +msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isLen(obj,siz,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=Trim(obj.value);
	if(obj1!=""){
		var strLen=obj.value;
		if(strLen.length < siz){
			alert(msg+" should be minimum " + siz + " characters");
			obj.focus();
			return true;  
		} 
	}else
		return false;
}
function isLenequal(obj,siz,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=Trim(obj.value);
	if(obj1!=""){
		var strLen=obj.value;
		if(strLen.length <siz)
		{
			alert(msg);
			obj.focus();
			return true; 
		   } 
		else if	(strLen.length >siz)
		{
			alert(msg);
			obj.focus();
			return true; 
		} 
		else
		{
			return false; 
		}
	}else
		return false;
}
function isLenlarege(obj,siz,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=obj.value;
	if(obj1!=""){
		var strLen=obj.value;
		if(strLen.length >siz){
			alert(msg+" should not exceed " + siz + " characters");
			obj.focus();
			return true;  
		} 
	}else
		return false;
}
function isSame(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value))==(Trim(obj2.value))){
		alert(msg1+" is matched with the "+msg2);
		obj2.focus();
		return true;
	}else
		return false;
}	
function isNotSame(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value))!=(Trim(obj2.value))){
		alert("Password does not match,try  again");
		obj2.focus();
		return true;
	}else
		return false;
}	
function isCorrect(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value)) >= (Trim(obj2.value))){
		alert(msg1+" should be less than "+msg2);
		obj2.focus();
		return true;
	}else
		return false;
}	
function isTxtareaNull(obj,msg){
	if(Trim(obj.innerText) == ""){
		alert("Please enter " + msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isTxtareaLen(obj,msg){
	if(obj.innerHTML.length > 255){
		alert("Please enter below 256 characters in " + msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isTxtareaLen(obj,msg){
	if(obj.innerHTML.length > 200){
		alert("Please enter below 256 characters in " + msg);
		var mySplitResult = myString.split("200");
		obj.focus();
		return true;
	}else
		return false;
}
function isTxtareaLensms(obj,msg){

	if(obj.value.length >1000){
		alert("Please enter below 1000 characters in " + msg);
		
		obj.focus();
		return true;
	}else
		return false;
}
function notEmail(obj,msg){
	var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if (!exp.test(obj.value)){
		alert("Fill inn "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function notZipcode(obj,msg){
	exp = /[a-zA-Z|\d]-{1}/;
	if (!exp.test(obj.value)){
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function notChecked(obj,msg){
	checked = false;
	if(obj.length){
		for(i=0;i<obj.length;i++){
			if(obj[i].checked){
				checked = true;break;
			}
		}
	}else if(obj.checked)
		checked = true;
	if(!(checked)){
		alert("Please select the "+msg);
		if(obj.length)
			obj[0].focus();
		else
			obj.focus();
		return true;
	}
}
function notSelected(obj,msg){
		if (obj.options[obj.selectedIndex].value == ""){
		alert("Please select the "+ msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isSelected(obj,msg){
		if (obj.options[obj.selectedIndex].value!="")
		{
		  return true;
	    }else
		return false;
}
function notImageFile(obj,msg){
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF)$/;
	if (!exp.test((obj.value).toLowerCase())){
		alert("Please choose jpg or gif file for "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function notDocFile(obj,msg){
	if(Trim(obj.value)!=""){
		var exp = /^.+\.(DOC|doc|TXT|txt)$/;
		if (!exp.test((obj.value).toLowerCase())){
			alert("Please choose doc or txt file for "+msg);
			obj.value="";
			obj.focus();
			return true;
		}else
			return false;	
	}else
		return false;
}
function notPdfDocFile(obj,msg){
	var exp = /^.+\.(pdf|doc|PDF|DOC)$/;
	if (!exp.test((obj.value).toLowerCase())){
		alert("Please choose pdf or doc file for "+msg);
		obj.value="";
		obj.focus();
		return true;
	}else
		return false;
}
function notPdfFile(obj,msg){
	var exp = /^.+\.(pdf|PDF)$/;
	if (!exp.test((obj.value).toLowerCase())){
		alert("Please choose pdf file for "+msg);
		obj.value="";
		obj.focus();
		return true;
	}else
		return false;
}
function notPrice(obj,msg){
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value)){
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkNum(obj,msg){exp = /^\d+$/;
	if (!exp.test(obj.value)){
		alert("Please enter only numeric values in "+msg
	);
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkAlpha(obj,msg)
{
	//exp = (/(^([a-z]|[A-Z]|["."]|[\s])*$)/);
	exp = (/(^([a-z]|[A-Z]|["."])*$)/);
	if (!exp.test(obj.value))
	{
		//alert("Please enter only alphabets in "+msg);
		document.getElementById('txtnamemsg').innerHTML=nokimg+"Please enter only alphabets"
		obj.focus();
		return true;
	}
	else
		return false;
}	

function fnChkAlphaNum(obj,msg){
	exp = (/(^([a-z]|[A-Z]|[0-9])*$)/);
	if (!exp.test(obj.value)){
		//alert("Please enter only alphanumeric in "+msg);
		document.getElementById('txtusernamemsg').innerHTML=nokimg+"Please enter only alphanumeric"
		obj.focus();
		return true;
	}else
		return false;
}

function fnChkAlphaNumeric(obj,msg){
	var Alpha = /[a-zA-Z|]/;
	var Num = /[\d]/;
	if (!(Alpha.test(obj.value) && Num.test(obj.value))){
		alert("Please enter only alphanumeric in "+msg);
		obj.focus();
		return true;
	}else
		return false;
}

function isEditorNull(obj,msg){
	strTmp = obj.value;
	StrContent=strTmp.split("<BODY>");
	StrContent=StrContent[1];
	StrContent=StrContent.split("</BODY>");
	StrContent=StrContent[0];
	strLength=StrContent.length;
	if (strLength==0){
		alert (msg);
		return true;
	}else
		return false;
}
function fnChkFolderName(){
	if(((window.event.keyCode < 48) || (window.event.keyCode > 57)) && ((window.event.keyCode < 65) || (window.event.keyCode > 90)) && ((window.event.keyCode < 97) || (window.event.keyCode > 122)) && (window.event.keyCode != 95)){
		alert("Only Alphabets(A-Z, a-z), Numbers(0-9) and Underscore(_) are allowed");
		window.event.keyCode = 0;
		return true;
	}
}
function GetCountry(defaultValue,isNotWithSelect){
	var sCountry="Afghanistan,Albania,Algeria,American Samoa,Andorra,Angola,Anguilla,Antarctica,Antigua and Barbuda,Argentina,Armenia,Aruba,Australia,Austria,Azerbaidjan,Bahamas,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bermuda,Bolivia,Bosnia-Herzegovina,Botswana,Bouvet Island,Brazil,British Indian O. Terr.,Brunei Darussalam,Bulgaria,Burkina Faso,Burundi,Buthan,Cambodia,Cameroon,Canada,Cape Verde,Cayman Islands,Central African Rep.,Chad,Chile,China,Christmas Island,Cocos (Keeling) Isl.,Colombia,Comoros,Congo,Cook Islands,Costa Rica,Croatia,Cuba,Cyprus,Czech Republic,Czechoslovakia,Denmark,Djibouti,Dominica,Dominican Republic,East Timor,Ecuador,Egypt,El Salvador,Equatorial Guinea,Estonia,Ethiopia,Falkland Isl.(Malvinas),Faroe Islands,Fiji,Finland,France,France (European Ter.),French Southern Terr.,Gabon,Gambia,Georgia,Germany,Ghana,Gibraltar,Great Britain (UK),Greece,Greenland,Grenada,Guadeloupe (Fr.),Guam (US),Guatemala,Guinea,Guinea Bissau,Guyana,Guyana (Fr.),Haiti,Heard & McDonald Isl.,Honduras,Hong Kong,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Israel,Italy,Ivory Coast,Jamaica,Japan,Jordan,Kazachstan,Kenya,Kirgistan,Kiribati,Korea (North),Korea (South),Kuwait,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macau,Madagascar,Malawi,Malaysia,Maldives,Mali,Malta,Marshall Islands,Martinique (Fr.),Mauritania,Mauritius,Mexico,Micronesia,Moldavia,Monaco,Mongolia,Montserrat,Morocco,Mozambique,Myanmar,Namibia,Nauru,Nepal,Netherland Antilles,Netherlands,Neutral Zone,New Caledonia (Fr.),New Zealand,Nicaragua,Niger,Nigeria,Niue,Norfolk Island,Northern Mariana Isl.,Norway,Oman,Pakistan,Palau,Panama,Papua New,Paraguay,Peru,Philippines,Pitcairn,Poland,Polynesia (Fr.),Portugal,Puerto Rico (US),Qatar,Reunion (Fr.),Romania,Russian Federation,Rwanda,Saint Lucia,Samoa,San Marino,Saudi Arabia,Senegal,Seychelles,Sierra Leone,Singapore,Slovak Republic,Slovenia,Solomon Islands,Somalia,South Africa,Spain,Sri Lanka,St. Helena,St. Pierre & Miquelon,St. Tome and Principe,St.Kitts Nevis Anguilla,St.Vincent & Grenadines,Sudan,Suriname,Svalbard & Jan Mayen Is,Swaziland,Sweden,Switzerland,Syria,Tadjikistan,Taiwan,Tanzania,Thailand,Togo,Tokelau,Tonga,Trinidad & Tobago,Tunisia,Turkey,Turkmenistan,Turks & Caicos Islands,Tuvalu,Uganda,Ukraine,United Arab Emirates,United Kingdom,United States,Uruguay,US Minor outlying Isl.,Uzbekistan,Vanuatu,Vatican City State,Venezuela,Vietnam,Virgin Islands (British)";
	var xCountry=sCountry.split(",");
	var str="";
	if (!isNotWithSelect)str+="<option value='' selected>Select Country</option>\n";else str+="<option value='' selected>Doesn't Matter</option>\n";
	for(i=0;i<xCountry.length; i++)
	if(xCountry[i]==defaultValue)str+="<option value='"+xCountry[i]+"' selected>"+xCountry[i]+"</option>\n";else str+="<option value='"+xCountry[i]+"'>"+xCountry[i]+"</option>\n";
	document.write(str);
}
function fnShowDate(obj,msg){
	var retdate=window.showModalDialog("includes/calender.htm","","dialogHeight: 219px; dialogWidth: 273px;  center: Yes; help: No; resizable: No; status: No;titlebar:No");
	obj.value=retdate;
}
	
function isNullMulti(obj,msg){
	if (Trim(obj.value)==""){
		alert("Please select the " + msg);
		obj.focus();
		return true;
	}else
		return false;
}
function fnProfile(v1){
	ref=window.open("employee_profile.php?Id="+v1,"Profile","Left=180, Top=90, height=500,width=650,toolbar=no,scrollbars=yes,menubar=no,resize=false");
}
function stripEditorNull(obj)
{
	
	strTmp = obj.value;
	//var strTmp=obj.getContent();
	//alert(strTmp);
	strTmp = strTmp.replace(/<HTML(.*)>/i,"");
	strTmp = strTmp.replace('<HEAD>',"");
	strTmp = strTmp.replace(/<META\scontent=(.*)>/ig,"");
	strTmp = strTmp.replace(/<LINK(.*)type=text\/css rel=stylesheet>/ig,"");
/*	strTmp = strTmp.replace(/<font/ig,"<font");
	strTmp = strTmp.replace(/<\/font>/ig,"</font>");
	strTmp = strTmp.replace(/style=/ig,"style=");*/
	strTmp = strTmp.replace('</HEAD>',"");
	strTmp = strTmp.replace('<BODY>',"");
	strTmp = strTmp.replace("</BODY>","");
	strTmp = strTmp.replace("</HTML>","");
	strTmp = strTmp.replace("<DIV>","");
	strTmp = strTmp.replace("&nbsp;",""); 

	strTmp = strTmp.replace("</br>",""); 
	strTmp = strTmp.replace("</br></br>",""); 
	strTmp = strTmp.replace("<br>",""); 
	strTmp = strTmp.replace("<br><br>",""); 
	strTmp = strTmp.replace("</DIV>",""); 
	strTmp = strTmp.replace("<p>","");
	strTmp = strTmp.replace("</p>","");
	return strTmp;
}
function stripTags_TinyMCE(obj) { //strips html tags leaving plain text
    var content=obj.getContent();
    //content=getHTML_TinyMCE(txtfield);
    var re = /(<([^>]+)>)/ig ; //strip all tags
    plaintext = content.replace(re, "");
    return plaintext;
}
function trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{

		sString = sString.substring(1, sString.length);

	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{

		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function stripPSpace(obj)
{
	var strTmp = obj.value;
	//var strTmp=obj.getContent();
	strTmp= strTmp.replace(/<P>&nbsp;(.*)<\/P>/igm,"");
	strTmp= strTmp.replace(/<P><\/P>/igm,"");
	return strTmp;
}
//To check valide email address with spaces  added by archunan 
function isEmail(emailStr)
{

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	var checkTLD=1;
	/* The following is the list of known TLDs that an e-mail address must end with. */
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	var emailPat=/^(.+)@(.+)$/;
	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/
	var validChars="\[^\\s" + specialChars + "\]";
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")";
	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	/* The following string represents an atom (basically a series of non-special characters.) */
	var atom=validChars + '+';
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")";
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	/* Finally, let's start trying to figure out if the supplied address is valid. */
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		//alert("Email address seems incorrect (check @ and .'s)");
		//alert("invalid email id .please try again.");
		document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
			//alert("invalid email id .please try again.");
			document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
			return false;
		}
	}
	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			//alert("Ths domain name contains invalid characters.");
			//alert("invalid email id .please try again.");
			document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
			return false;
		}
	}
	// See if "user" is valid 
	if (user.match(userPat)==null)
	{
	// user is not valid
		//alert("invalid email id .please try again.");
		document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
		return false;
	}
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		// this is an IP address
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				//alert("invalid Host!");
				document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
				return false;
		   }
		}
		return true;
	}
	// Domain is symbolic name.  Check if it's valid.
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			//alert("The domain name does not seem to be valid.");
			//alert("invalid email id .please try again.");
			document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
			return false;
		}
	}
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
	{
		//alert("The address must end in a well-known domain or two letter " + "country.");
		//alert("invalid email id .please try again.");
		document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
		return false;
	}
	// Make sure there's a host name preceding the domain.
	if (len<2)
	{
		//alert("This address is missing a hostname!");
		//alert("invalid email id .please try again.");
		document.getElementById('txtmailmsg').innerHTML=nokimg+"invalid email id .please try again.";
		return false;
	}
	// If we've gotten this far, everything's valid!
	return true;
	
}
// eof of valide email check added by archunan
function popImage(imageURL,imageTitle,pos,AutoClose,CopyRight){
	//Safari workaround
	is_safari=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)?true:false;
	safari_version=Number(navigator.userAgent.substring(navigator.userAgent.indexOf("Safari/")+7));
	if (is_safari && safari_version<300){
		var f="top=0, left=0, width="+screen.width+",height="+screen.height+" ,scrollbars=yes";
		imgWin=window.open(imageURL,'im',f);
	}
	else{
		//Based on browser set correct resize mode
		if (parseInt(navigator.appVersion.charAt(0))>=4){
			if (navigator.appName=="Netscape" || is_safari){
				var f="width="+screen.width+",height="+screen.height;	
				var rs="var iWidth=window.innerWidth;iHeight=window.innerHeight";
				var adj="0";
			}
			if(document.all){
				var f="width=150,height=150";	
				var rs = "var iWidth=document.body.clientWidth;iHeight=document.body.clientHeight;";
				if(typeof window.opera != 'undefined'){ 
					 var adj="window.outerHeight-24";
				 }
				else{
					var adj="32";
				}	 
			} 
		}
		//
		v=pos.substring(0,pos.indexOf("_"));
		h=pos.substring(pos.indexOf("_")+1);
		f+=",left=0,top=0";
		imgWin=window.open('about:blank','',f);
		imDoc=imgWin.document;
		with (imDoc){
			writeln('<html><head><title>Loading...</title>');writeln('<sc'+'ript>');
			writeln('var sdstr=\"\";window.onerror=function(){return true;}');
			writeln('function resizeWin(){');
			//If the image size is bigger then screen resize window to the screen size
			writeln('sc=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)?15:"";');
			writeln('iW=document.images[0].width;iH=document.images[0].height;sW=screen.availWidth;sH=screen.availHeight;');
			writeln('if(iW>=sW || iH>=sH){window.resizeTo(sW,sH);window.moveTo(0,0)}else{');
			writeln(rs);
			writeln('var v=\"'+v+'\";var h=\"'+h+'\";');
			writeln('switch (v){case \"top\":vPos=0;break;case \"middle\":vPos=(sH-iH-'+adj+')/2;break;case \"bottom\":vPos=sH-'+adj+'-iH'+((is_safari)?'-20':'')+';break;default: vPos=0;}');
			
			writeln('switch (h){case \"left\":hPos=0;break;case \"center\":hPos=(sW-iW)/2;break;case \"right\":hPos=sW-iW'+((is_safari)?'-20':'')+';break;default: hPos=0;}');
			writeln('iWidth = document.images[0].width - iWidth;iHeight = document.images[0].height - iHeight;');
			writeln('window.resizeBy(iWidth+sc, iHeight+sc);');
			writeln('window.moveBy(hPos,vPos)}}');
			writeln('function doTitle(){document.title="'+unescape(imageTitle)+'";}'+'</sc'+'ript>');
			var cT=(!AutoClose)?"":"onBlur=\"sdstr=setTimeout('window.close(this)',1000)\"";
			//Prevent closing in IE
			var fL=(!AutoClose)?"":"onfocus=\"clearTimeout(sdstr)\"";
			var safari_fix=(is_safari)?" onload='resizeWin()'":"";
			var opera9_fix= (window.opera && window.getSelection)?" onload='resizeWin();doTitle();'":"";
			if(!CopyRight){var cr1="";var cr2=""}else{var cr1=" galleryimg=\"no\" title=\"Copyright Protected\" onmousedown=\"window.close()\" ";var cr2="oncontextmenu=\"return false\" "}
			writeln('</head><body  leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor=\"FFFFFF\"  onload="'+ ((!is_safari)?"resizeWin();doTitle();":"")+'self.focus()" '+cT+' '+fL+' '+cr2+'>');
			writeln('<div '+fL+' align=\"center\" style=\"width:100%;height:100%;overflow:auto\"><img src="'+imageURL+'" '+cr1+safari_fix+opera9_fix+' ></div></body></html>');
			close();
		}
	}
}
///pages
function Trim(nStr)
{
	return nStr.replace(/(^\s*)|(\s*$)/g, "");
}
function fnEmailvalidate()
{
	if(document.getElementById('txtEmail').value=="")
	{
			document.getElementById('txtmailmsg').innerHTML=nokimg+"Email required."
			document.getElementById('txtEmail').focus();
			return false;
	}
	else if(document.getElementById('txtEmail').value!="")
	{ 	
				   if(!isEmail(document.getElementById('txtEmail').value))
				   {
					document.getElementById('txtEmail').focus();
					return false;
					}
					
	 }
	else
	{
		document.getElementById('txtmailmsg').innerHTML=okimg;
		return true;
	}
}
function fnLnvalidate(){
var txtusername=document.getElementById('txtusername');
var txtpwd=document.getElementById('txtpwd');
	if(txtusername.value==""){
	   document.getElementById('txtusernamemsg').innerHTML=nokimg+" User Name is required.";
	   txtusername.focus();
	   return false;   
	}
	else if(fnChkAlphaNum(document.getElementById('txtusername'),"User Name"))return false;
	else {
		document.getElementById('txtusernamemsg').innerHTML=okimg;
		if(txtpwd.value==""){
		   document.getElementById('txtpwdmsg').innerHTML=nokimg +" Password is required";
		   txtpwd.focus();
		   return false;   
		}
		else  {
			document.getElementById('txtpwdmsg').innerHTML=okimg;
			return true;
			}
		return true;
	 }
}
function fnSnvalidate(){
	var txtusername=document.getElementById('txtusername');
	var txtpwd=document.getElementById('txtpwd');
	if(Trim(txtusername.value)==""){
	   document.getElementById('txtusernamemsg').innerHTML=nokimg+" User Name is required.";
	   txtusername.focus();
	   return false;  
	}
	 else if(fnChkAlphaNum(document.getElementById('txtusername'),"User Name"))return false;
	else {
		document.getElementById('txtusernamemsg').innerHTML=okimg;
		if(txtpwd.value==""){
		   document.getElementById('txtpwdmsg').innerHTML=nokimg +" Password is required";
		   txtpwd.focus();
		   return false;   
		}
		else
		{
			document.getElementById('txtpwdmsg').innerHTML=okimg;
			if(document.getElementById('txtconpwd').value=="")
			{
				document.getElementById('txtconpwdmsg').innerHTML=nokimg+"Confirm password required."
				document.getElementById('txtconpwd').focus();
				return false;
			}
			else if(document.getElementById('txtconpwd').value!=document.getElementById('txtpwd').value)
			{
				//document.getElementById('generalerrmsg').innerHTML=alertimg+" Password and Confirm password must be same."
				document.getElementById('txtconpwdmsg').innerHTML="Password and Confirm password must be same";
				document.getElementById('txtpwd').focus();
				return false;
			}
			else 
			{
				 document.getElementById('txtconpwdmsg').innerHTML=okimg;
				if(Trim(document.getElementById('txtName').value)=="")
				{
					document.getElementById('txtnamemsg').innerHTML=nokimg+"Name required."
					document.getElementById('txtName').focus();
					return false;
				}
				else if(fnChkAlpha(document.getElementById('txtName'),"Name"))return false;
				else
				{
				  document.getElementById('txtnamemsg').innerHTML=okimg;
				  if(document.getElementById('txtEmail').value=="")
			 	 {
					document.getElementById('txtmailmsg').innerHTML=nokimg+"Email required."
					document.getElementById('txtEmail').focus();
					return false;
				 }
				 else
				  if(document.getElementById('txtEmail').value!="")
			 	 {
				   if(!isEmail(document.getElementById('txtEmail').value))
				   {
					document.getElementById('txtEmail').focus();
					return false;
					}
					
				 }
				 else
				 {
					document.getElementById('txtmailmsg').innerHTML=okimg; 
					
				 }
			
			    }
			}
		}
		
		return true;
	 }
}

				 
function fnCpvalidate(){

	if(document.getElementById('txtoldpwd').value=="")
	{
   
		document.getElementById('txtoldpwdmsg').innerHTML=nokimg+" Enter old password."
		
		document.getElementById('txtoldpwd').focus();

		return false;
	}
	else{
	    document.getElementById('txtoldpwdmsg').innerHTML=okimg;
		if(document.getElementById('txtnewpwd').value=="")
		{
			document.getElementById('txtnewpwdmsg').innerHTML=nokimg+" Enter New password."
			document.getElementById('txtnewpwd').focus();
			return false;
		}
		else
		{
			document.getElementById('txtnewpwdmsg').innerHTML=okimg;
			if(document.getElementById('txtconfrpwd').value=="")
			{
				document.getElementById('txtconfrpwdmsg').innerHTML=nokimg+" Enter confirm password."
				document.getElementById('txtconfrpwd').focus();
				return false;
			}
			else if(document.getElementById('txtnewpwd').value!=document.getElementById('txtconfrpwd').value)
			{
				document.getElementById('generalerrmsg').innerHTML=alertimg+" New password and confirm password must be same."
				document.getElementById('txtconfrpwdmsg').innerHTML="";
				document.getElementById('txtnewpwd').focus();
				return false;
			}
		}
	 
	}
	 return true;
}


function fnAdvalidate()
{	
	if(document.addwebsitepfrm.menu_title.value=="")
	{
		alert("Enter the Webpage Name");
		document.addwebsitepfrm.menu_title.focus();
		return false;
	}
	else if(document.addwebsitepfrm.menu_page_title.value=="")
	{
		alert("Enter the Page Title");
		document.addwebsitepfrm.menu_page_title.focus();
		return false;
	}
	else if(document.addwebsitepfrm.menu_keyword.value=="")
	{
		alert("Enter the Keyword");
		document.addwebsitepfrm.menu_keyword.focus();
		return false;
	}
   else if(document.addwebsitepfrm.menu_meta_desc.value=="")
	{
		alert("Enter the Meta Description");
		document.addwebsitepfrm.menu_meta_desc.focus();
		return false;
	}
   else if(document.addwebsitepfrm.gallerypage.value=="")
	{
		alert("Kindly mention is this a Gallery Page?");
		document.addwebsitepfrm.gallerypage.focus();
		return false;
	}
	
}
function fnEdvalidate()
{	
	
	if(document.editwebsitepfrm.menu_title.value=="")
	{
		alert("Enter the Webpage Name");
		document.editwebsitepfrm.menu_title.focus();
		return false;
	}
	else if(document.editwebsitepfrm.menu_page_title.value=="")
	{
		alert("Enter the Page Title");
		document.editwebsitepfrm.menu_page_title.focus();
		return false;
	}
	else if(document.editwebsitepfrm.menu_keyword.value=="")
	{
		alert("Enter the Keyword");
		document.editwebsitepfrm.menu_keyword.focus();
		return false;
	}
	else if(document.editwebsitepfrm.menu_meta_desc.value=="")
	{
		alert("Enter the Meta Description");
		document.editwebsitepfrm.menu_meta_desc.focus();
		return false;
	}
	else if(document.editwebsitepfrm.menu_status.value=="")
	{
		alert("Please select menu status");
		document.editwebsitepfrm.menu_status.focus();
		return false;
	}
	else if(document.editwebsitepfrm.gallerypage.value=="")
	{
		alert("Please select gallery page type ");
		document.editwebsitepfrm.gallerypage.focus();
		return false;
	}
    else if(document.editwebsitepfrm.containtext.value=="")
	{
		alert("Kindly select Does this page contain text?");
		document.editwebsitepfrm.containtext.focus();
		return false;
	}

}


//Front end forms 

function fnValidate()
{
    if(Trim(document.frmContact.txtName.value)=="") 
	{
		alert("Please enter your name ");
		return false;
	}
	if(Trim(document.frmContact.txtCompany.value)=="") 
	{
		alert("Please enter company name ");
		return false;
	}
	if(Trim(document.frmContact.txtAddress.value)=="") 
	{
		alert("Please enter your address ");
		return false;
	}
	if(Trim(document.frmContact.txtEmail.value)=="") 
	{
		alert("Please enter your email ");
		return false;
	}
	 if(document.frmContact.txtEmail.value!="")
	{
		if(!isEmail(document.frmContact.txtEmail.value))
		{
		document.frmContact.txtEmail.value.focus();
		return false;
		}
	}	
	if(Trim(document.frmContact.txtState.value)=="") 
	{
		alert("Please enter your state ");
		return false;
	}
	if(Trim(document.frmContact.txtZip.value)=="") 
	{
		alert("Please enter your Zip ");
		return false;
	}
}
function fnprovalidate()
{
	var reg  = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.profrm.txtemail.value;	
	
	var iChars = "!#$%^&*()+=-[]\\\';,./{}|\":<>?0123456789";

	for (var i = 0; i < document.profrm.txtname.value.length; i++) {

	if(iChars.indexOf(document.profrm.txtname.value.charAt(i)) != -1) {

		alert ("Please enter characters only.");
		document.profrm.txtname.value="";
		document.profrm.txtname.focus();
		return false;

		}
	}
	
	if(Trim(document.profrm.txtname.value)=="")
	{
			alert("Enter the Name");
			document.profrm.txtname.focus();
			return false;
	}
	if(Trim(document.profrm.txtemail.value)=="") 
	{
		alert("Please enter your email address ");
		document.profrm.txtemail.focus();
		return false;
	}
	if(document.profrm.txtemail.value!="")
	{
		if(reg.test(address) == false)
		{
		alert("Invalid Email id ! Please enter valid email id");
		document.profrm.txtemail.value="";
		document.profrm.txtemail.focus();
		return false;
		}
 	}
	
}
