function CreateBookmarkLink() {

 title = document.title; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = document.location.href;
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function bookmark_us(url, title){

if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
}
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}

function bookmarksite(title,url){
if (document.all)
window.external.AddFavorite(url,title);
else if (window.sidebar)
window.sidebar.addPanel(title,url,"")
}
function cal_sponsor_balance(siteid ,siteurl)
{
	postStr = "sponsorsiteid="+siteid

	new Ajax.Updater('test','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	//location.href = siteurl;
	return false;
}

function checkamount(id,divid)
{
	var bidamount = document.getElementById(id).value
	postStr = "amount="+bidamount
	new Ajax.Updater(divid,'includes/checkamount.php',{method:'post', postBody: postStr });
	return false;
}

function livecounter(char)
{
	curlnght=char.length+1;

	totval=document.getElementById('txtcharcount').value
	if((totval>=0) && (curlnght<=255))
	{
		document.getElementById('txtcharcount').value=(255-curlnght);
	}
	else
	{
		alert("Text size is full");
		return false;
	}
	
}
function showhide(id)
{
	if(id=='myprofile')
	{
		$('myprofile').style.display = 'block';
		$('addnewsite').style.display = 'none';
		$('viewsites').style.display = 'none';
		$('addfunds').style.display = 'none';
		$('changepassword').style.display = 'none';
		
		$('myprofiletab').className = 'activetab';
		$('addnewsitetab').className =  '';
		$('viewsitestab').className = '';
		$('addfundstab').className = '';
		$('changepasstab').className = '';
		
	}
	if(id=='addnewsite')
	{
		$('myprofile').style.display = 'none';
		$('addnewsite').style.display = 'block';
		$('viewsites').style.display = 'none';
		$('addfunds').style.display = 'none';
		$('changepassword').style.display = 'none';
		
		$('myprofiletab').className = '';
		$('addnewsitetab').className =  'activetab';
		$('viewsitestab').className = '';
		$('addfundstab').className = '';
		$('changepasstab').className = '';

	}
	if(id=='viewsites')
	{
		$('myprofile').style.display = 'none';
		$('addnewsite').style.display = 'none';
		$('viewsites').style.display = 'block';
		$('addfunds').style.display = 'none';
		$('changepassword').style.display = 'none';
		
		$('myprofiletab').className = '';
		$('addnewsitetab').className =  '';
		$('viewsitestab').className = 'activetab';
		$('addfundstab').className = '';
		$('changepasstab').className = '';
	}
	if(id=='addfunds')
	{
		$('myprofile').style.display = 'none';
		$('addnewsite').style.display = 'none';
		$('viewsites').style.display = 'none';
		$('addfunds').style.display = 'block';
		$('changepassword').style.display = 'none';
		
		$('myprofiletab').className = '';
		$('addnewsitetab').className =  '';
		$('viewsitestab').className = '';
		$('addfundstab').className = 'activetab';
		$('changepasstab').className = '';
	}
	if(id=='changepassword')
	{
		$('myprofile').style.display = 'none';
		$('addnewsite').style.display = 'none';
		$('viewsites').style.display = 'none';
		$('addfunds').style.display = 'none';
		$('changepassword').style.display = 'block';
		
		$('myprofiletab').className = '';
		$('addnewsitetab').className =  '';
		$('viewsitestab').className = '';
		$('addfundstab').className = '';
		$('changepasstab').className = 'activetab';
	}
}
function edit_profile(sponsorid)
{
	postStr = "sponsorid="+sponsorid
	new Ajax.Updater('myprofile','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	return false;
}
function update_profile(sponsorid)
{	
	postStr = "username="+$F('txtname')+"&email="+$F('txtemail')+"&website="+$F('txtwebsite')+"&updatesponsorsid="+sponsorid;
	new Ajax.Updater('myprofile','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	return false;
}

function add_new_site(sponsorid)
{
	if(validateform(sponsorid))
	{
		if($('hidesiteid'))
		{
			
			if($F('hidesiteid') != 0)	
			{
				var str = $F('hidesiteid');
				/***BOF this code add for adding prices with keywords each keyword should have uniq price******/
				var keystring = ''
				var keycnt = $F('inputcount'+str);
				for(i=0; i < parseInt(keycnt)+1; i++)
				{
					myid = 'txtkey'+str+''+i;
					myid1 =  'txtkey'+i;
					mybid = 'txtbid'+str+''+i;
					mybid1 = 'txtbid'+i;
					
					if(trim($F(myid),' ')!='' && trim($F(mybid),' ')!='')
					{
						keystring = keystring+'&'+myid1+'='+$F(myid)+'&'+mybid1+'='+$F(mybid);
					}
					alert(keystring);
				}
				keystring = keystring+'&inputcount='+parseInt(keycnt)+1;
				/***EOF this code add for adding prices with keywords each keyword should have uniq price******/
				
				
				//postStr = "site_title="+$F('sit_title'+str)+"&site_url="+$F('site_url'+str)+"&site_keywords="+$F('site_key'+str)+"&site_dec="+$F('site_dec'+str)+"&sp_balance="+$F('sp_balance'+str)+"&sitefrom="+$F('sitefrom'+str)+"&siteto="+$F('siteto'+str)+"&siteinsert_sponsorsid="+sponsorid+"&hidesiteid="+$F('hidesiteid')+keystring;
				postStr = "site_title="+$F('sit_title'+str)+"&site_url="+$F('site_url'+str)+"&site_dec="+$F('site_dec'+str)+"&sitefrom="+$F('sitefrom'+str)+"&siteto="+$F('siteto'+str)+"&siteinsert_sponsorsid="+sponsorid+"&hidesiteid="+$F('hidesiteid')+keystring;
				new Ajax.Updater('viewsites','includes/ajaxcalls.php',{method:'post', postBody: postStr });
				new Effect.BlindDown('viewsites',{delay: .1, duration:1});
				return false;
			}else{
				/***BOF this code add for adding prices with keywords each keyword should have uniq price******/
				var keystring = ''
				var str = 0;
				var keycnt = $F('inputcount0');
				for(i=0; i < parseInt(keycnt)+1; i++)
				{
					myid = 'txtkey'+str+''+i;
					myid1 =  'txtkey'+i;
					mybid = 'txtbid'+str+''+i;
					mybid1 = 'txtbid'+i;
					
					if(trim($F(myid),' ')!='' && trim($F(mybid),' ')!='')
					{
						keystring = keystring+'&'+myid1+'='+$F(myid)+'&'+mybid1+'='+$F(mybid);
					}
				}
				keystring = keystring+'&inputcount='+parseInt(keycnt)+1;
				/***EOF this code add for adding prices with keywords each keyword should have uniq price******/
				postStr = "site_title="+$F('sit_title'+str)+"&site_url="+$F('site_url'+str)+"&site_dec="+$F('site_dec'+str)+"&sitefrom="+$F('sitefrom'+str)+"&siteto="+$F('siteto'+str)+"&siteinsert_sponsorsid="+sponsorid+keystring;
				new Ajax.Updater('addnewsite','includes/ajaxcalls.php',{method:'post', postBody: postStr });
				new Effect.BlindDown('addnewsite',{delay: .1, duration:1});
				return false;
			}
		}else
		{
			/***BOF this code add for adding prices with keywords each keyword should have uniq price******/
			var keystring = ''
			var str = 0;
			var keycnt = $F('inputcount0');
			for(i=0; i < parseInt(keycnt)+1; i++)
			{
				myid = 'txtkey'+str+''+i;
				myid1 =  'txtkey'+i;
				mybid = 'txtbid'+str+''+i;
				mybid1 = 'txtbid'+i;
				
				if(trim($F(myid),' ')!='' && trim($F(mybid),' ')!='')
				{
					keystring = keystring+'&'+myid1+'='+$F(myid)+'&'+mybid1+'='+$F(mybid);
				}
			}
			keystring = keystring+'&inputcount='+parseInt(keycnt)+1;
			/***EOF this code add for adding prices with keywords each keyword should have uniq price******/
			postStr = "site_title="+$F('sit_title'+str)+"&site_url="+$F('site_url'+str)+"&site_dec="+$F('site_dec'+str)+"&sitefrom="+$F('sitefrom'+str)+"&siteto="+$F('siteto'+str)+"&siteinsert_sponsorsid="+sponsorid+keystring;
	
			new Ajax.Updater('addnewsite','includes/ajaxcalls.php',{method:'post', postBody: postStr });
			new Effect.BlindDown('addnewsite',{delay: .1, duration:1});
			return false;
		}
	}
}

function edit_site(siteid)
{
	postStr = "siteid="+siteid;
	new Ajax.Updater('viewsites','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	return false;
}
function update_password()
{
	postStr = "oldpassword="+$F('txtoldpass')+"&newpassword="+$F('txtnewpass')+"&passwordchange=ok";
	new Ajax.Updater('changepassword','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	return false;
}
function forgot_pass()
{
	postStr = "emailid="+$F('txtemailid')+"&forgotpass=1";
	new Ajax.Updater('forgotpassword','includes/ajaxcalls.php',{method:'post', postBody: postStr });
	return false;
}
function delete_site(siteid)
{
	if(confirm("You really want to delete this record"))
	{
		postStr = "delete_siteid="+siteid;
		new Ajax.Request('includes/ajaxcalls.php',{method:'post', postBody: postStr , onComplete:alert('Record deleted successfully')});
		new Effect.Fade('site_row'+siteid,{duration:3});
		return false;
	}else
	{
		return false;
	}
}
function setfocus()
{
	document.getElementById('query').focus();
}
function send_request(type)
{
	if(document.getElementById('query').value=="")
	{
		location.href="index.php?ref="+type+"&query="+document.getElementById('query').value;
	}else
	{
		if(type == "PhoneBook")
		{
			location.href="searchme.php?type="+type+"&name="+document.getElementById('query').value;
		}else
		{
			if(type == "YellowPages")
			{
				location.href="searchme.php?type="+type+"&name="+document.getElementById('query').value;
			}else
			{
				location.href="searchme.php?type="+type+"&query="+document.getElementById('query').value;
			}
		}
	}
}
/********* function for add new keywords***********/
function addnewkeyword(id)
{
	var cnt = $F('inputcount'+id);
	var myhtml = '<div style="float:left">Keyword</div><div style="float:left; padding-left:190px;">Bid Amount</div><br clear="all">';
	var newcnt = parseInt(cnt)+1;
	
	for(i = 0; i < newcnt; i++)
	{
		myid = 'txtkey'+id+''+i;
		var keyval = new String($F(myid));
		functionid = id+''+i;
		mybid = 'txtbid'+id+''+i;
		spanid = 'spanbid'+id+''+i;
		innerhtml_span =  $(spanid).innerHTML;
		bidval = $F(mybid);
		myhtml = myhtml+"<input type=\"text\" name=\""+myid+"\" id=\""+myid+"\" size=\"35\" class=\"inputbox\" value=\""+keyval+"\">&nbsp;&nbsp;$&nbsp;<input type=\"text\" name=\""+mybid+"\" size=\"6\" id=\""+mybid+"\" class=\"inputbox\" value=\""+bidval+"\">&nbsp;&nbsp; <span id='"+spanid+"'>"+innerhtml_span+"</span><br><br>";
	}
	if($('spanbid'+id+''+newcnt))
		innerhtml_spanbid = $('spanbid'+id+''+newcnt).innerHTML;  
	else
		innerhtml_spanbid = "";
	myhtml = myhtml+"<input type=\"text\" name=\"txtkey"+id+''+newcnt+"\" size=\"35\" id=\"txtkey"+id+''+newcnt+"\" class=\"inputbox\" value=\"\">&nbsp;&nbsp;$&nbsp;<input type=\"text\" name=\"txtbid"+id+''+newcnt+"\" id=\"txtbid"+id+''+newcnt+"\" class=\"inputbox\" size=\"6\" value=\"\"><input type=\"hidden\" name=\"inputcount"+id+"\" id=\"inputcount"+id+"\" class=\"inputbox\" value=\""+newcnt+"\">&nbsp;&nbsp;<span id=\"spanbid"+id+''+newcnt+"\">"+innerhtml_spanbid+"</span>";
	$('kaywordval'+id).innerHTML = myhtml;
	$('inputcount'+id).value = newcnt;
}
function showpreviousbids(id)
{
	var keyword = 'txtkey'+id;
	postStr = "keyword="+$F(keyword)+"&checkbid=1";
	new Ajax.Updater('spanbid'+id,'includes/ajaxcalls.php',{method:'post', postBody: postStr });
	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"), "");
}
/**********Function for check url is valid or invalid*********************/
function check_it(urlval)
{
	var theurl=urlval;
	/*var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	if (tomatch.test(theurl))
	{
		return true;
	}
	else
	{
		return false;
	}*/
	var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(theurl)){
        return true;
    }else{
        return false;
    } 
}
/******** Javascript validation for site add/edit*************/
function validateform(id)
{
	if($('hidesiteid'))
	{
		var str = $F('hidesiteid');
	}else{
		var str = 0;
	}
	//postStr = "site_title="+$F('sit_title'+str)+"&site_url="+$F('site_url'+str)+"&site_keywords="+$F('site_key'+str)+"&site_dec="+$F('site_dec'+str)+"&sp_balance="+$F('sp_balance'+str)+"&sitefrom="+$F('sitefrom'+str)+"&siteto="+$F('siteto'+str)+"&siteinsert_sponsorsid="+sponsorid+"&hidesiteid="+$F('hidesiteid')+keystring;
	if(trim($F('sit_title'+str),' ') == '')
	{
		alert('Please enter site title!');
		$('sit_title'+str).focus();
		return false;
	}
	if(!check_it($F('site_url'+str)))
	{
		alert('Please enter valid URL!');
		$('site_url'+str).focus();
		return false;
	}
	if(trim($F('txtkey00'),' ') == '')
	{
		alert('Please enter Keywords!');
		$('txtkey00'+str).focus();
		return false;
	}
	if(trim($F('txtbid00'),' ') == '')
	{
		alert('Please enter Keywords and bid amount!');
		$('txtbid'+str).focus();
		return false;
	}else{
		return true;	
	}
	
}
function validatelogin_form()
{
	if($F('txtusername')=="" || $F('txtpassword')=="")
	{
		alert("Please enter user name and password")	
		return false;
	}
}

function validateloginaffi_form()
{
	if($F('txtusername')=="" || $F('txtpassword')=="")
	{
		alert("Please enter user name and password")	
		return false;
	}
}


function validatepaypal()
{
	if($F('txtamount')<=0)
	{
		alert("Please enter valid amount")	
		return false;
	}else
	{
		var objRegExp  = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	  //check for integer characters
		if(objRegExp.test($F('txtamount')))
		{	
			return true;
		}
		else
		{
			alert("Please enter valid number.");
			return false;
		}	
	}	
}

function validatecoupan()
{
	if($F('txtcoupancode')<=0)
	{
		alert("Please enter coupan no.")	
		return false;
	}
	if($F('txtcoupancode')=="")
	{
		alert("Please enter coupan no.")	
		return false;
	}else
	{
		var objRegExp  = /(^-?\d\d*$)/;
	  //check for integer characters
		if(objRegExp.test($F('txtcoupancode')))
		{	
			return true;
		}
		else
		{
			alert("Please enter valid coupan no.");
			return false;
		}	
	}	
}
function validate_forgotpass()
{
	if($F('txtemailid')=="")
	{
		alert("Please enter email address");
		return false;
	}
	else if(!checkemail($F('txtemailid')))
	{
		alert("Please enter valid email address");
		return false;	
	}
}
function isValidEmail(str) {
	

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}
function validate_regiter()
{
	if($F('txtemailid')=="" ||  $F('txtname')=="")
	{
		alert("Please fill all mandatory fields");
		return false;
	}
	else if(!checkemail($F('txtemailid')))
	{
		alert("Please enter valid email address");
		return false;	
	}
	if(document.getElementById('checkbox').checked == false)
	{
		alert("You have not accepted terms and conditions");
		return false;
	}
	
}


function validate_regiter_affiliate()
{
	/*if($F('txtemailid')=="" ||  $F('txtname')=="")
	{
		alert("Please fill all mandatory fields");
		return false;
	}
	else if(!checkemail($F('txtemailid')))
	{
		alert("Please enter valid email address");
		return false;	
	}	
	
	if($F('ddcountry')=="0")
	{
		alert("Please select country");	
		return false;
	}
	if(trim($F('txtstate'))=="")
	{
		alert("Please enter state");	
		return false;
	}
	if(trim($F('txtcity'))=="")
	{
		alert("Please enter city");	
		return false;
	}
	if($F('ddcountry')=="226" && $F('txtstate')=="florida")
	{
		if(trim($F('txttaxid'))=="")
		{
			alert("Please enter taxid");	
			return false;
		}
	}
	if(document.getElementById('checkbox').checked == false)
	{
		alert("You have not accepted terms and conditions");
		return false;
	}
	*/

	var url = "http://"+$F('txturl');
	if($F('txtcompanyname')=="")
	{
		alert("Please fill all mandatory fields");
		return false;
	}
	if($F('txturl')=="")
	{
		alert("Please fill url");	
		return false;
	}else if(!is_valid_url(url))
	{
		alert("Please Enter Valid URL");	
		return false;
	}
	
	if($F('txtaddress')=="")
	{
		alert("Please Enter Address");	
		return false;
	}
	
	if(trim($F('txtcity'))=="")
	{
		alert("Please enter city");	
		return false;
	}
	if(trim($F('txtstate'))=="")
	{
		alert("Please enter state");	
		return false;
	}
	if(trim($F('txtzipcode'))=="")
	{
		alert("Please Enter Zip Code");	
		return false;	
	}
	if($F('ddcountry')=="0")
	{
		alert("Please select country");	
		return false;
	}
	if(trim($F('txtbustype'))=="0")
	{
		alert("Please Enter Buisness Type");	
		return false;	
	}
	if(trim($F('txtbuzclass'))=="0")
	{
		alert("Please Enter Buisness classification");	
		return false;	
	}
	if($F('ddcountry')=="226" && $F('txtstate')=="florida")
	{
		if(trim($F('txttaxid'))=="")
		{
			alert("Please enter taxid");	
			return false;
		}
	}
	
	if(trim($F('txtcaptcha'))=="")
	{
		alert("Please Enter Varification Code");	
		return false;
	}
	
	
	if(document.getElementById('checkbox').checked == false)
	{
		alert("You have not accepted terms and conditions");
		return false;
	}

}

/*****Function validate email*****/

function checkemail(emailid)
{
//	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
	var filter=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	if (filter.test(emailid))
	return true
	else
	return false;	
}

/************************/
function is_valid_url(url)
{
     //return url.match(/^(ht|f)tps?:\/\/www.[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/);
	    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    } 
}
function validate_newsite(id)
{
	

	var emailid = "http://"+$F('site_url');	
	if($F('sit_title')=="")
	{
		alert("Please enter site title");
		return false;
	}	
	else if($F('site_url')=="")
	{
		alert("Please enter the URL ");
		return true;
	}
	else if(!is_valid_url(emailid))
	{
		alert("Please enter valid URL ");
		return true;
	}
	else if($('site_dec').value=="")
	{
		alert("Please enter description");
		return false;
	}
	else if($F('sitefrom')=="")
	{
		alert("Please enter start date");
		return false;
	}
	else if($F('siteto')=="")
	{
		alert("Please enter end date");
		return false;
	}
	else 
	{
			var keycnt = $F('inputcount'+id);		
			/**************prashant@veblogy.com start here**************/
			var arr_keywirds = new Array();
			var arr_bids = new Array();
			var arr_bidinput = new Array();
			
			for(i=0; i < parseInt(keycnt)+1; i++)
			{
				myid = 'txtkey'+id+''+i;
				myid1 =  'txtkey'+i;
				mybid = 'txtbid'+id+''+i;
				mybid1 = 'txtbid'+i;
				
				if(((trim($F('txtkey'+id+i),' ')!='' && trim($F('txtbid'+id+i),' ')!='')))
				{
					arr_keywirds.push(trim($F('txtkey'+id+i),' '));
					arr_bids.push(trim($F('txtbid'+id+i),' '));						  
					arr_bidinput.push('txtbid'+id+i);
				}else if(((trim($F(myid),' ')!='' && trim($F(mybid),' ')=='')) || ((trim($F(myid),' ')=='' && trim($F(mybid),' ')!=''))){
						alert("Please enter keyword and bid amount ")
						$(myid).focus();
						return false;
						break;
				}
			}
			
			if(arr_keywirds.length > 0)
			{
				for(x=0; x < arr_keywirds.length; x++)
				{
					
					var minni = document.getElementById('minimumbid').value
							
					var objRegExp  = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
				  //check for integer characters
					if(parseFloat(arr_bids[x]))
					{	

						if(parseFloat(arr_bids[x]) < parseFloat(minni))
						{
							alert("Bid amount should be greater than or equal to $"+minni)
							$(arr_bidinput[x]).focus();
							return false;
						}
					}else{
		
						alert("Bid amount should be greater than or equal to $"+minni)
						$(arr_bidinput[x]).focus();
						return false;
					}
				}
			}else{
					if($('chkkeyfile').checked != true)
					{
						alert("Please insert at least one keyword with bid amount.");	
						return false;
					}
			}
		/*********prashant@veblogy.com ends here***********/
		document.getElementById('issubmit').value= 1;
		document.frmaddnewsite.submit();
	}
}


function val_profile()
{		
	if($F('txtsponsor_name')=="")
	{
		alert("Please fill all mandatory fields");
		return false;
	}	
	
	if($F('ddcountry')=="0")
	{
		alert("Please select country");	
		return false;
	}
	if(trim($F('txtstate'))=="")
	{
		alert("Please enter state");	
		return false;
	}
	if(trim($F('txtcity'))=="")
	{
		alert("Please enter city");	
		return false;
	}
	if($F('ddcountry')=="226" && $F('txtstate')=="florida")
	{
		if(trim($F('txttaxid'))=="")
		{
			alert("Please enter taxid");	
			return false;
		}
	}
}

function vali_siteinfo()
{
	var tomatch= /[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	var emailid_web = "http://"+$F('txtaffi_website');	
	if($F('txttitle')=="")
	{
		alert("Please enter site title");
		return false;
	}	
	else if(emailid_web =="")
	{
		alert("Please enter the URL");
		return false;
	}
	else if (!is_valid_url(emailid_web))
	{
		alert("Please enter valid URL");
		return false;
	}	
}

function state_change()
{	
	var myid = 'txttax';
	var state_lo = $F('txtstate'); 
 	var str_lo = ""+state_lo.toLowerCase()+"";

	if($F('ddcountry')=="226" && str_lo == "florida")
	{
		if($(myid).style.display=='none')
		{	
			$(myid).style.display=='block';
			new Effect.BlindDown(myid,{delay: .1, duration:1});
			return true;		
		}
	}else
	{
		$(myid).style.display=='none';	
		new Effect.BlindUp(myid,{delay: .1, duration:1});
		return true;
	}
	
	
}
function pagination_allsites(pagecount, pageno, totalrecords)
{			
	var postStr = "pagecount="+pagecount+"&pageno="+pageno+"&totalrecords="+totalrecords;
	$('div_allsites').style.display = 'none';
	new Ajax.Updater ('div_allsites','pagination/viewsites.php', {method:'post',postBody:postStr , onComplete:function(){ hideme();} });
	$('pagecount').value = pagecount;
	$('pageno').value = pageno;
	$('totalrecords').value = totalrecords;
	return false;
}
function hideme()
{
	$('div_allsites').style.display = 'block';
}

/******prashant@veblogy.com*****/

function validate_secondform()
{

/*	if($F('bnkcountry')=="0")
	{
		alert("Please Select Country");
		return false;
	}
	if($F('txbankname')=="")
	{
		alert("Please Enter Bank Name");
		return false;
	}
	
		if($F('txtaccname')=="")
	{
		alert("Please Enter Account holder Name");
		return false;
	}
		if($F('acctype')=="")
	{
		alert("Please Select account type");
		return false;
	}
	if($F('txtaccnumber')=="")
	{
		alert("Please Enter Account Number");
		return false;
	}
	if($F('txtrtncode')=="")
	{
		alert("Please Enter Routing Number/Sort Code ");
		return false;
	}
	if($F('txtpayname')=="")
	{
		alert("Please Enter Payees Name ");
		return false;
	}	*/
}

function validate_thirdform()
{
	var specialchar="!@#$%^&*()_+|?><';][\=-";
	var emailchar="!#$%^&*()_+|?><';][\=-";
	var digits="0123456789";
	var mobile="+0123456789";
	var dot=".";
	var phonedigit="+0123456789";
	
	if($F('seltype')=="0")
	{
		alert("Please Select Title");
		return false;
	}
	if($F('txtname')=="")
	{
		alert("Please Enter First Name");
		return false;
	}
	if($F('txtlname')=="")
	{
		alert("Please Enter Last Name");
		return false;
	}
	if($F('txtphone')=="")
	{
		alert("Please Enter Phone no.");
		return false;
	}
	phone=document.getElementById('txtphone').value;
	if(phone.length != "")
	{
		/* validation of phone */
		for (var i=0;i < phone.length; i++)
		{
			phonenumber=phone.charAt(i);
			if(phonedigit.indexOf(phonenumber)==-1)
			{
				alert ("Please use only digits and special charachters '-''+' in phone");
				//document.frmreg.txtphone.value = ""
				document.getElementById('txtphone').focus()
				return false;
			}
		}
	}
	
	fax=document.getElementById('txtfax').value;
	if(fax.length != "")
	{
		/* validation of phone */
		for (var i=0;i < fax.length; i++)
		{
			phonenumber=fax.charAt(i);
			if(phonedigit.indexOf(phonenumber)==-1)
			{
				alert ("Please use only digits and special charachters '-''+' in phone");
				//document.frmreg.txtphone.value = ""
				document.getElementById('txtfax').focus()
				return false;
			}
		}
	}
	var emailid=trim(document.getElementById('txtemail').value);
	 if(document.getElementById('txtemail').value=="")
	{
		alert("Please enter your email");
		document.getElementById('txtemail').focus();
		return false;
	}
	else if(!checkemail(emailid))
	{
		alert("Please enter valid emailid");
		document.getElementById('txtemail').focus();
		return false;
	}	
}

function checkemail(emailid)
{

    var filter=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
    if (filter.test(emailid))
    return true
    else
    return false;   
}

function validate_fourthform()
{
//	alert ($F('opt1'));
//	alert (document.getElemntById('opt1').value);

//	return false;
}

function div_show1(id)
{
	if(id=='div_1');
	{
		myid='div_info1';
	}
	
	if($(myid).style.display=='none')
	{
		new Effect.BlindDown(myid,{delay: .1, duration:1});
		return true;
	}else
	{
		new Effect.BlindUp(myid,{delay: .1, duration:1});
		return true;
	}
	
}


function showhidediv(id)
{
	if(id=='processcodediv')
	{
		// IMEI codes div
		if($('pane1'))
			$('pane1').className = 'active'
		if($('pane2'))
		$('pane2').className = ''
		if($('pane3'))
		$('pane3').className = ''
		$(id).style.display = 'block';
		if($('fileprocessdiv'))
			$('fileprocessdiv').style.display = 'none';
		if($('processlogdiv'))
			$('processlogdiv').style.display = 'none';
		//new Effect.BlindUp('fileprocessdiv');
		//new Effect.BlindDown(id);
	}
	else if(id=='fileprocessdiv')
	{	
		// Files Div
		if($('pane1'))
			$('pane1').className = ''
		if($('pane3'))
			$('pane3').className = ''
		if($('pane2'))
			$('pane2').className = 'active'
		if($('processcodediv'))
			$('processcodediv').style.display = 'none';
		if($('processlogdiv'))
			$('processlogdiv').style.display = 'none';
		
		$(id).style.display = 'block';
		//new Effect.SlideUp('processcodediv');
		//new Effect.SlideDown(id);
	}else
	{
		if($('pane1'))
			$('pane1').className = ''
		if($('pane3'))
			$('pane3').className = 'active'
		if($('pane2'))
			$('pane2').className = ''
		if($('processcodediv'))
			$('processcodediv').style.display = 'none';
		if($('fileprocessdiv'))
			$('fileprocessdiv').style.display = 'none';
		$(id).style.display = 'block';
	}
}
function isemailid(affid)
{
	var postStr = "affid="+affid+"&emailid="+$F('txtemail');
	$('errmsg').style.display = 'none';	
	$('loading').style.display = 'block';
	var  t ="";
	new Ajax.Updater ('errmsg','includes/ajaxcalls.php', {method:'post',postBody:postStr , onComplete:function(){ hideme_email();} });
}
function hideme_email(t)
{

	$('errmsg').style.display = 'block';	
	$('loading').style.display = 'none';
}

function user_out()
{
	if(document.getElementById('name').value == "")
	{
		document.getElementById('name').value = "Name"
	}else
	{
		document.getElementById('name').value = ""
	}
}

function user_out1()
{
	if(document.getElementById('name').value == "")
	{
		document.getElementById('name').value = "Name"
	}
}

function user_out_yp()
{
	if(document.getElementById('name').value == "")
	{
		document.getElementById('name').value = "Business Name"
	}else
	{
		document.getElementById('name').value = ""
	}
}

function user_out1_yp()
{
	if(document.getElementById('name').value == "")
	{
		document.getElementById('name').value = "Business Name"
	}
}

function city_out()
{
	if(document.getElementById('cityquery').value == "")
	{
		document.getElementById('cityquery').value = "City"
	}else
	{
		document.getElementById('cityquery').value = ""
	}
}

function city_out1()
{
	if(document.getElementById('cityquery').value == "")
	{
		document.getElementById('cityquery').value = "City"
	}
}

function city_out_yp()
{
	if(document.getElementById('cityquery').value == "")
	{
		document.getElementById('cityquery').value = "City"
	}else
	{
		document.getElementById('cityquery').value = ""
	}
}

function city_out1_yp()
{
	if(document.getElementById('cityquery').value == "")
	{
		document.getElementById('cityquery').value = "City"
	}
}