function check_publisher()
{

	if(document.reg.password.value != document.reg.confirm_password.value) 
	{ 
 		alert("Passwords Don't Match");
 		return false;
	}	 
	var FormError = "Please fill in the following fields: \n";
	var errorMessage = '';

	if(document.reg.fname.value.replace(/ /g,'')=="")
	{
		errorMessage = errorMessage + "First Name\n";
	}

	if( document.reg.lname.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Last Name\n";
	}
	if( document.reg.add1.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Address Line 1\n";
	}
	if( document.reg.city.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "City\n";
	}
	if( document.reg.stat.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "State/Province/Region\n";
	}
	if( document.reg.postal.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Zip/Postal Code\n";
	}
	if( document.reg.country.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Country\n";
	}

        var p1=document.reg.phone.value
	if( p1 == null)
	{
		errorMessage = errorMessage + "Phone Number\n";
	}
	else
	{
		if(!p1.toString().match(/^[-]?\d*\.?\d*$/))
		{
			errorMessage = errorMessage + "Please enter a valid Phone number\n";
		}
	}
	if( document.reg.phone.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Phone Number\n";
	}
	if( document.reg.curr)
	{
		if(document.reg.curr.value == '')
		{
			errorMessage = errorMessage + "Currency\n";
		}
	}
	if( document.reg.email_add.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Email Address\n";
	}
	if(document.reg.email_add.value)
	{
		with (document.reg.email_add)
		{
			apos=value.indexOf("@");
			dotpos=value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) 
  				errorMessage = errorMessage + "Please Enter Valid Email Address\n";
		}
	}
	if( document.reg.username.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "User Name\n";
	}

	if( document.reg.password.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Password\n";
	}
	if( document.reg.confirm_password.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Confirm Password\n";
	}

	if(!document.reg.policy.checked)
	{
		alert("You Must agree to our Program Policy to continue.");
 		return false;
	}

	if(errorMessage)
	{
		errorMessage = FormError + errorMessage;
		window.alert(errorMessage);
		return false;
	}
	return true;
}

function get_encypto(vars_data)
{
var url = 'get_encypto.php?'+vars_data;
//var url = 'encypt.php'
if(navigator.appName == "Microsoft Internet Explorer") 
	{
	http = new ActiveXObject("Microsoft.XMLHTTP");
	} 
else 
	{
	http = new XMLHttpRequest();
	} 
alert('1');
http.open('GET', url, true);
alert('2');
http.onreadystatechange=function() 
	{
 	if(http.readyState == 4) 
		{
		var enc_var = http.responseText;
      		alert(enc_var);
		return enc_var;
    		}
  	}
http.send(null);
}


function samp_code()
{
	var num_ads1=document.getElementById('num_ads');
	var typ=document.getElementById('opti');
	var uid=document.getElementById('uid');
	var site_url=document.getElementById('site_url');
	var web_id=document.getElementById('web_id');
	var x1=document.getElementById('samp_table').rows[3].cells;
	var xdat=document.getElementById('samp_table').rows[5].cells;
	var xdat1 = document.getElementById('samp_table').rows[7].cells;
	if(typ.checked==true)
	{
		var optiontype="h";
	}	
	else
	{
		var optiontype="v";
	}

	var vars_data = "clientid="+uid.value+"&webid="+web_id.value+"&num="+num_ads1.value+"&type="+optiontype;

//  ajax starts here
	var url = 'get_encypto.php?'+vars_data;
	if(navigator.appName == "Microsoft Internet Explorer") 
		{
		http = new ActiveXObject("Microsoft.XMLHTTP");
		} 
	else 
		{
		http = new XMLHttpRequest();
		} 
	http.open('GET', url, true);
	http.onreadystatechange=function() 
		{
 		if(http.readyState == 4) 
			{
			var enc_var = http.responseText;
      			//alert(enc_var);
			if(typ.checked==true)
			{
			var textareadat="&nbsp;<textarea cols=90 rows=9 readonly><!-- Begin: Xapads -->\n<style type=\"text/css\">\na.xaphead:link {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:visited {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:hover {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:active {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\n\na.xaptext:link    {font-size: 8pt; font-weight: normal;color: #333333;text-decoration:none;}\na.xaptext:visited {font-size: 8pt; font-weight: normal;color: #333333;text-decoration:none;}\na.xaptext:hover   {font-size: 8pt; font-weight: normal;color: #333333; text-decoration:underline;}\na.xaptext:active  {font-size: 8pt; font-weight: normal;color: #333333; text-decoration:underline;}\n\n.xaptd{font-family: Verdana; font-size: 8pt; font-weight: normal; color: #000000;}\n.xapborderall{border-left:1px solid #999999;border-right:1px solid #999999;border-top:1px solid #999999;border-bottom:1px solid #999999; }\n.xapbg1{background-color:#f3f3f3;}.xapbg2{background-color:#999999;}</style>\n<script type=\"text/javascript\" src=\""+site_url.value+"getlinks.php?"+enc_var+"\"></script>\n<!-- End: Xapads -->\n</textarea>";
			var textareadat1="&nbsp;Ad Id&nbsp;&nbsp;<input type=\"text\" readonly size=25 value="+enc_var+">";
			}	
			else
			{	
			var textareadat="&nbsp;<textarea cols=90 rows=9 readonly><!-- Begin: Xapads -->\n<style type=\"text/css\">\na.xaphead:link {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:visited {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:hover {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\na.xaphead:active {font-size: 10pt; font-weight: bold;color: #333333;text-decoration:underline;}\n\na.xaptext:link    {font-size: 8pt; font-weight: normal;color: #333333;text-decoration:none;}\na.xaptext:visited {font-size: 8pt; font-weight: normal;color: #333333;text-decoration:none;}\na.xaptext:hover   {font-size: 8pt; font-weight: normal;color: #333333; text-decoration:underline;}\na.xaptext:active  {font-size: 8pt; font-weight: normal;color: #333333; text-decoration:underline;}\n\n.xaptd{font-family: Verdana; font-size: 8pt; font-weight: normal; color: #000000;}\n.xapborderall{border-left:1px solid #999999;border-right:1px solid #999999;border-top:1px solid #999999;border-bottom:1px solid #999999; }\n.xapbg1{background-color:#f3f3f3;}.xapbg2{background-color:#999999;}</style>\n<script type=\"text/javascript\" src=\""+site_url.value+"getlinks.php?"+enc_var+"\"></script>\n<!-- End: Xapads -->\n</textarea>";
			var textareadat1="&nbsp;Ad Id&nbsp;&nbsp;<input type=\"text\" readonly size=25 value="+enc_var+">";
			}
			if((num_ads1.value==0)||(num_ads1.value>10))
				var num=3;
			else
				var num = num_ads1.value;	
			if(typ.checked==true)
			{
				var dat = "<table width=700><tr>";
				while(num)
				{
					dat=dat+"<td><a href=xaprio.com class=sampHeadline>Xaprio Solutions</a><br><a href=xaprio.com class=sampText>Xaprio Xaprio</a></td>";
					num--;	
				}
				dat=dat+"</tr></table>";
				x1[0].innerHTML="";
				x1[0].innerHTML=dat;
			}	
			else
			{
				var dat = "<table>";
				while(num)
				{
					dat=dat+"<tr><td><a href=xaprio.com class=sampHeadline>Xaprio Solutions</a><br><a href=xaprio.com class=sampText>Xaprio Xaprio</a><br><br></td></tr>";
					num--;	
				}
				dat=dat+"</table>";
				x1[0].innerHTML="";
				x1[0].innerHTML=dat;
			}	
			xdat[0].innerHTML="";
			xdat[0].innerHTML=textareadat;
			xdat1[0].innerHTML="";
			xdat1[0].innerHTML=textareadat1;
    			}   // if(http.readyState == 4)  ends here
  		}
	http.send(null);
//  ajax ends here

	
}

function chtit()
{
	var wname = document.getElementById('wname');
	var tit = document.getElementById('tit');	
	tit.innerHTML="<var class=\"sampHead\">"+wname.value+"</var>";
}

function chdescri()
{
	var wname = document.getElementById('wdesc');
	var descri = document.getElementById('descri');	
	descri.innerHTML="<var class=\"sampText\">"+wname.value+"</var>";
}

function check_advertiser()
{
	
	var FormError = "Please fill in the following fields: \n";
	var errorMessage = '';

	if( document.reg.wname.value == '')
	{
		errorMessage = errorMessage + "Website Title\n";
	}
	if( document.reg.wurl.value == '')
	{
		errorMessage = errorMessage + "Website URL\n";
	}
	if( document.reg.wdesc.value == '')
	{
		errorMessage = errorMessage + "Website Description\n";
	}
	if( document.reg.cpc.value == '')
	{
		errorMessage = errorMessage + "Cost Per Click Bid\n";
	}
	if( document.reg.daily_cap.value == '')
	{
		errorMessage = errorMessage + "Daily Cap\n";
	}
	if( document.reg.total_bud.value == '')
	{
		errorMessage = errorMessage + "Total Budget\n";
	}
	
	if(errorMessage)
	{
		errorMessage = FormError + errorMessage;
		window.alert(errorMessage);
		return false;
	}
	if(!document.reg.policy.checked)
	{
		alert("You Must agree to our Program Policy to continue.");
 		return false;
	}
//	if( document.reg.total_bud.value > funds)
//	{
//		alert("Your Budget is exceeding Unallocated Funds");
//		return false;
//	}
	return true;
}


function isEmpty(val)
{
	if (val.match(/^s+$/) || val == "")
	{
		return true;
	}
	else
	{
		return false;
	}	
}
function check_cpm_ads1()
{
var FormError = "Please fill in the following fields: \n";
	var errorMessage = '';

	if( document.reg.wname.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Website Title\n";
	}
	var v1=document.reg.wurl.value.split("//");
	if(v1 != "http:")
	{
		document.reg.wurl.value="http://" + document.reg.wurl.value.replace("http://","");
	}
	if( document.reg.wurl.value.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ').replace('http://','') == '')
	{
		errorMessage = errorMessage + "Website URL\n";
	}
	
	if( document.reg.wdesc.value.replace(/ /g,'') == '')
	{
		errorMessage = errorMessage + "Website Description\n";
	}
	if(isNaN(document.reg.avg_imp.value.replace(/ /g,'')))
	{
	   errorMessage = errorMessage + "Please enter numeric value in Average Monthly Impressions\n";
	}
	if(!document.reg.policy.checked)
	{
		errorMessage = errorMessage + "You Must agree to our Program Policy to continue.\n";
		//alert("You Must agree to our Program Policy to continue.");
 		//return false;
	}
	if(errorMessage)
	{
		errorMessage = FormError + errorMessage;
		window.alert(errorMessage);
		return false;
	}
	
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


<!-- Begin
var mikExp = /\$|,|@|\/|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\"|\<|\>|\?|\||\\|\!|\$|[0-9]|\./g;
function dodacheck(val)
	{
		/*
		 * Edited by Arif :: Start
		 */
		/*
		 * The following piece of code was added by Arif for getting integer and special character free value.
		 */
			var str = val.value
			strReplaced = str.replace(mikExp,'');
			val.value = strReplaced;
			val.focus;
/*
 * The following code was commented by Arif for getting integer and special character free value.
 */
/*
		var strPass = val.value;
		var strLength = strPass.length;
		var lchar = val.value.charAt((strLength) - 1);
		if(lchar.search(mikExp) != -1) 
		{
			var tst = val.value.substring(0, (strLength) - 1);
			val.value = tst;
		}

*/
/*
 * Edited by Arif :: End
 */
	}
function doanothercheck(form) {
if(form.value.length < 1) {
alert("Please enter something.");
return false;
}
if(form.value.search(mikExp) == -1) {
alert("Correct Input");
return true;
}
else {
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ =  | \n\r\n\rare not allowed!\n");
form.select();
form.focus();
return false;
}
alert("Correct Input");
return true;
}


function validatephone(xxxxx) 
		{
			var maintainplus = '';
			var numval = xxxxx.value
			if ( numval.charAt(0)=='+' ){ var maintainplus = '+';}
			curphonevar = numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
			xxxxx.value = maintainplus + curphonevar;
			var maintainplus = '';
			xxxxx.focus;
		}