foodgroup = new Array;
var working=true;
function chkvalid()
{
	if(document.advsearch.companyname.value=="" && document.advsearch.category.value=="" && document.advsearch.special.value=="" && document.advsearch.brand.value=="" && document.advsearch.keyword.value=="")
	{
		alert("Select Any One Search Criteria.");
		return false;
	}
	else if(document.advsearch.region.value=="")
	{
		alert("Select Region.");
		document.advsearch.region.focus();
		return false;
	}
	else
	{
		var TmpBN=document.advsearch.companyname.value;
		TmpBn1=TmpBN.replace("&","--");
		
		var TmpBT=document.advsearch.category.value;
		TmpBT1=TmpBT.replace("&","--");
		
		document.advsearch.action="adv_search_result.php?post=1&companyname=" + TmpBn1 + "&category=" + TmpBT1 + "&special=" + document.advsearch.special.value + "&brand=" + document.advsearch.brand.value + "&keyword=" + document.advsearch.keyword.value + "&adregion=" + document.advsearch.region.value;
		return true;
	}
}	
function chkvalid2()
{
	if(document.advsearch.companyname.value=="" && document.advsearch.category.value=="" && document.advsearch.special.value=="" && document.advsearch.brand.value=="" && document.advsearch.keyword.value=="")
	{
		alert("Select Any One Search Criteria.");
		return false;
	}
	else if(document.advsearch.strregion.value=="")
	{
		alert("Select Region.");
		return false;
	}
	else
	{
		var TmpBN=document.advsearch.companyname.value;
		TmpBn1=TmpBN.replace("&","--");
		
		var TmpBT=document.advsearch.category.value;
		TmpBT1=TmpBT.replace("&","--");
		
		document.advsearch.action="adv_search_result.php?post=1&companyname=" + TmpBn1 + "&category=" + TmpBT1 + "&special=" + document.advsearch.special.value + "&brand=" + document.advsearch.brand.value + "&keyword=" + document.advsearch.keyword.value + "&adregion=" + document.advsearch.strregion.value;
		return true;
	}
}	
function barg_chkvalidation()
{
	if(document.bargainsearch.MCatId.value=="" && document.bargainsearch.SCatId.value=="" && document.bargainsearch.keyword.value=="")
	{
		alert("Select Any One Search Criteria.");
		return false;
	}
	if(document.bargainsearch.Days[0].checked==false && document.bargainsearch.Days[1].checked==false)
	{
		alert("select Last 7 days or All records.");
		return false;
	}
	else
	{
		document.bargainsearch.action="deals_search_result.php";
		document.bargainsearch.submit();
	}
}
function barg_chkvalidation1()
{
		var TmpDays;
		if(document.barsearch.Days[0].checked==true)
			TmpDays = document.barsearch.Days[0].value;
		else if(document.barsearch.Days[1].checked==true)
			TmpDays = document.barsearch.Days[1].value;
		
		document.barsearch.action="deals_search_result.php?MCatId=" + document.barsearch.MCatId.value + "&SCatId=" + document.barsearch.SCatId.value + "&keyword=" + document.barsearch.keyword.value + "&Days=" + TmpDays;
		document.barsearch.submit();
	
}
function bar_chkvalidation()
{
	
	var TmpMc="";
	if(document.bargainsearch.MCatId[0].selected==true)
	{
		TmpMc="All";
	}
	else
	{
		for(var i=1;i<=7;i++)
		{
			if(document.bargainsearch.MCatId[i].selected==true)
			{
				if(TmpMc=="")
					TmpMc=document.bargainsearch.MCatId[i].value;
				else
					TmpMc= TmpMc + "," + document.bargainsearch.MCatId[i].value;
			}
		}
	}
	
	var TmpSc="";
	if(document.bargainsearch.SCatId[0].selected==true)
	{
		TmpSc="All";
	}
	else
	{	
		for(var i=1;i<=document.bargainsearch.SCTot.value;i++)
		{
			if(document.bargainsearch.SCatId[i].selected==true)
			{
				if(TmpSc=="")
					TmpSc=document.bargainsearch.SCatId[i].value;
				else
					TmpSc= TmpSc + "," + document.bargainsearch.SCatId[i].value;
			}
		}
	}
	
	if(document.bargainsearch.Days[0].checked==false && document.bargainsearch.Days[1].checked==false)
	{
		alert("select Last 7 days or All records.");
		return false;
	}
	else
	{
		if(document.bargainsearch.Days[0].checked==true)
			var TmpDays = document.bargainsearch.Days[0].value;
		else if(document.bargainsearch.Days[1].checked==true)
			var TmpDays = document.bargainsearch.Days[1].value;
				
		document.bargainsearch.action="deals_search_result.php?MCatId=" + TmpMc + "&SCatId=" + TmpSc + "&keyword=" + document.bargainsearch.keyword.value + "&Days=" + TmpDays;
		document.bargainsearch.submit();
	}
}
function bar_ChangeCat()
{
	var TmpMc="";
	if(document.bargainsearch.MCatId[0].selected==true)
	{
		TmpMc="All";
	}
	else
	{
		for(var i=1;i<=7;i++)
		{
			if(document.bargainsearch.MCatId[i].selected==true)
			{
				if(TmpMc=="")
					TmpMc=document.bargainsearch.MCatId[i].value;
				else
					TmpMc= TmpMc + "," + document.bargainsearch.MCatId[i].value;
			}
		}
	}
	
	//document.bargainsearch.action="bargains.php?MCatId=" + document.bargainsearch.MCatId.value;
	document.bargainsearch.action="deals.php?MCatId=" + TmpMc;
	document.bargainsearch.submit();
}

function prsnextmonth(m,y,c)
{
	if(m==12)
	{
		m=1;
		y=y+1;
	}
	else
	{
		m=m+1;
	}
	document.prsfrm.month.value=m;
	document.prsfrm.year.value=y;
	document.prsfrm.ecat.value=c;
	document.prsfrm.submit()
}
function prsprimonth(m,y,c)
{
	if(m==1)
	{
		m=12;
		y=y-1;
	}
	else
	{
		m=m-1;
	}
	document.prsfrm.month.value=m;
	document.prsfrm.year.value=y;
	document.prsfrm.ecat.value=c;
	document.prsfrm.submit()
}
function prsnewsearch(d,m,y,c)
{	
	document.prsfrm.day.value=d;
	document.prsfrm.month.value=m;
	document.prsfrm.ecat.value=c;
	document.prsfrm.year.value=y;
	document.prsfrm.submit()
}
function prsnewcat(d,m,y,c)
{	
	document.prsfrm.day.value=d;
	document.prsfrm.month.value=m;
	document.prsfrm.year.value=y;
	document.prsfrm.ecat.value=c;
	document.prsfrm.submit()
}
function get_rates(val){
	var start = 0;
	var leng = 0;
	var len = val.length;
	if(len == 10){
		start = 5;
		leng = 5;
	}
	if(len == 8){
		start = 4;
		leng = 4;
	}
	//document.ratecheck.rate800.value = val.substr(0,leng);
	
	document.ratecheck.fixtext.value="011   +";
	document.ratecheck.ratelocal.value = val.substr(start,leng);
}
function classi_chkform()
{
	var Fromemail 	= document.sendmail.fromemail.value;
	
	if(document.sendmail.fromname.value=="")
	{
		alert("Your name cannot be blank.");
		document.sendmail.fromname.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Fromemail)))
	{
		alert("Please enter valid email address for yourself.");
		document.sendmail.fromemail.focus();
		return false;
	}
	else if(document.sendmail.message.value=="")
	{
		alert("Please Enter Your Message.");
		document.sendmail.message.focus();
		return false;
	}
	else
	{
		return true;
	}
	
	
}

function isBlank(s)
{
	for(var i=0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if((c!=' ')&&(c!="\n")&&(c!="\t"))
		return false;
	}
	return true;
}
function changeaction()
{
	
	var flag ="N";
	var imgflag="N";
	
	for(i= 1; i < document.postadd.length; i++)
	{
		if(document.postadd.elements[i].type =="text")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				document.postadd.elements[i].focus();
				flag ="Y";
				break;
			}
		}
		if(document.postadd.elements[i].type =="textarea")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				document.postadd.elements[i].focus();
				flag ="Y";
				break;
			}
		}
		if(document.postadd.elements[i].type =="file")
		{
			if(!isBlank(document.postadd.elements[i].value))
			{
				imgflag="N";	
				if(!DoPreview(document.postadd.elements[i].value))
				{
					imgflag="R";
					document.postadd.elements[i].focus();
					break;
				}
			}
		}
	}
	if(flag =="Y")
	{
		alert("Please fill up complete the details");
		return false;
	}	
	else if(imgflag=="R")
	{
		//alert("Please Upload image file width lessthen 800 and height lessthen 600");
		alert("The image you are trying to upload is too large.\nPlease select an image which is less than 800 pixels wide by 600 pixels high.\nPlease also ensure that you do not upload a file size greater than 100k as this will take too long too download.");
		return false;
	}
	else
	{
		document.postadd.action="classifiedvars.php";
		document.postadd.submit();
	}
}


function changeaction1()
{
	var flag ="N";
	var imgflag="N";
	for(i= 1; i < document.postadd.length; i++)
	{
		if(document.postadd.elements[i].type =="text")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				flag ="Y";
				document.postadd.elements[i].focus();
				break;
			}
		}
		if(document.postadd.elements[i].type =="textarea")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				flag ="Y";
				document.postadd.elements[i].focus();
				break;
			}
		}
		if(document.postadd.elements[i].type =="file")
		{
			if(!isBlank(document.postadd.elements[i].value))
			{
				imgflag="N";	
				if(!DoPreview(document.postadd.elements[i].value))
				{
					imgflag="R";
					document.postadd.elements[i].focus();
					break;
				}
			}	
		}	
	}
	if(flag =="Y")
	{
		alert("Please fill up all fields");
		return false;
	}
	else if(imgflag=="R")
	{
		//alert("Please Upload image file width lessthen 800 and height lessthen 600");
		alert("The image you are trying to upload is too large.\nPlease select an image which is less than 800 pixels wide by 600 pixels high.\nPlease also ensure that you do not upload a file size greater than 100k as this will take too long too download.");
		return false;
	}
	else
	{
		document.postadd.action="classifiedvars.php";
		document.postadd.submit();
	}
}	
function MainCt()
{
	document.postadd1.action="classifiedpost.php?idcat=" + document.postadd1.idcat1.value;
	document.postadd1.submit();
}

function SubCt()
{
	document.postadd1.action="classifiedpost.php?idcat=" + document.postadd1.idcat1.value + "&idsubcat=" + document.postadd1.idsubcat1.value;
	document.postadd1.submit();
}
function chkdonatefrm()
{
	if(document.donateauctionfrm.conname.value=="")
	{
		alert("Enter Contact Name.");
		document.donateauctionfrm.conname.focus();
		return false;
	}
	else if(document.donateauctionfrm.add.value=="")
	{
		alert("Enter Address.");
		document.donateauctionfrm.add.focus();
		return false;
	}
	else if(document.donateauctionfrm.phone.value=="" || !IsNumeric(document.donateauctionfrm.phone.value))
	{
		alert("Enter a valid number.");
		document.donateauctionfrm.phone.focus();
		return false;
	}
	else if (!chkEmail(document.donateauctionfrm.email.value))
	{
		alert("Please enter a valid 'Email' address");
		document.donateauctionfrm.email.focus();
		return false;
	}
	else if(document.donateauctionfrm.description.value=="")
	{
		alert("Enter Description of the item.");
		document.donateauctionfrm.description.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function events_chkvalidation()
{
	/*	
	if(document.eventsearch.EveType.value=="" && document.eventsearch.Keyword.value=="")
	{
		alert("Select Event Type or Enter keyword.");
		return false;
	}
	else
	{
	*/
		var frdt="";
		var todt="";
		var tmpfrdt;
		var tmptodt;
		
		if(document.eventsearch.fromday.value!="" && document.eventsearch.frommonth.value!="" && document.eventsearch.fromyear.value!="")
		{
			if(document.eventsearch.fromday.value<=9)
				tmpfrdt="0"+document.eventsearch.fromday.value;
			else
				tmpfrdt=document.eventsearch.fromday.value;
				
			frdt=document.eventsearch.fromyear.value + "-" + document.eventsearch.frommonth.value + "-" + tmpfrdt;
		}
		
		if(document.eventsearch.today.value!="" && document.eventsearch.tomonth.value!="" && document.eventsearch.toyear.value!="")
		{
			if(document.eventsearch.today.value<=9)
				tmptodt="0"+document.eventsearch.today.value;
			else
				tmptodt=document.eventsearch.today.value;
				
			todt=document.eventsearch.toyear.value + "-" + document.eventsearch.tomonth.value + "-" + tmptodt;
		}
		
		
		document.eventsearch.action="events_search_result.php?EveType=" + document.eventsearch.EveType.value + "&keyword=" + document.eventsearch.Keyword.value + "&EveRegion=" + document.eventsearch.EveRegion.value + "&Frdt=" + frdt + "&Todt=" + todt;
		document.eventsearch.submit();
		return true;
	//}
}
function camlocation()
{
	if(document.form1.costcamlocation.value!="")
	{
		theURL="costcam.php?CamId=" + document.form1.costcamlocation.value;
		winName="";
		features="scrollbars=auto,width=390,height=375";
		
		window.open(theURL,winName,features);
	}
}
function Otherlocation()
{
	if(document.form1.city.value!="")
	{
		document.form1.action="weather.php?city=" + document.form1.city.value;
		document.form1.submit();
	}
}

function order_changeguest(tc)
{
	if(document.order.ticketsrequired.value==0 || document.order.ticketsrequired.value==1)
	{
		document.getElementById("guestdiv").style.display="none";				
		document.getElementById("GuestNo").value=0;
	}
	else
	{
		document.getElementById("guestdiv").style.display="inline";
		var i = 0;
		var tot = document.order.ticketsrequired.value - 1;
		
		for(i=0;i<tot;i++)
		{
			document.getElementById("guest["+i+"]").style.display="inline";		
		}
		for(i=tot;i<=10;i++)
		{
			document.getElementById("guest["+i+"]").style.display="none";	
		}
		document.getElementById("GuestNo").value = tot;
   }
}

function order_chkform()
{

	if (document.order.name.value=="")
	{
		alert("Plase enter the Name/Company ")
		document.order.name.focus();
		return false;
	}
	else if (document.order.contact.value=="")
	{
		alert("Please enter a Contact Name")
		document.order.contact.focus();
		return false;
	}
	else if (document.order.phone.value=="" || document.order.phone.value.length < 10)
	{
		alert("Please enter a ten digit telephone number, commencing with your area code")
		document.order.phone.focus();
		return false;
	}
	else if (document.order.email.value=="")
	{
		alert("Please enter the contact email address")
		document.order.email.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.order.email.value))){
			alert("Please enter a valid email address");
			document.order.email.focus();
			return false;
	}	
	else
	{
		return true;
	}
}

function checkvalidatePasswordRetrival()
{
	if (!chkEmail(document.passwordretrieval.email.value))
	{
		alert("Please enter a valid Email address");
		return false;
	}
}

function polls_submitresult(pollid) 
{ 
	
	theURL="pollsresult.php?pollid=" + pollid  + "&pollans=";
	winName="";
	features="scrollbars=yes,width=650,height=300";
	
	for(var pi=0;pi<document.frmpoll.POTot.value;pi++)
	{
		if(eval("document.frmpoll.pollans[" + [pi] + "]").checked)
		{
			var TmpVal=(eval("document.frmpoll.pollans[" + [pi] + "]").value);
			theURL=theURL + TmpVal;
		}
		
	}
		
	window.location.href=theURL;
	//window.open(theURL,winName,features);
}

function reg_chkvalid()
{
	
	if(document.register.username.value=="")
	{
		alert("Enter Username.");
		document.register.username.focus();
		return false;
	}
	else if(!((/^([A-Za-z0-9])+$/.test(document.register.username.value))))
	{
		alert("Enter Username Only Characters and digites.");
		document.register.username.focus();
		return false;
	}
	else if(document.register.email.value=="")
	{
		alert("Enter valide email address.");
		document.register.email.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.register.email.value)))
	{
		alert("Your email address does not seem to be valid.");
		document.register.email.focus();
		return false;
	}
	else if(document.register.email.value!=document.register.cemail.value)
	{
		alert("Your email addresses do not match.");
		document.register.cemail.value="";
		document.register.cemail.focus();
		return false;
	}
	else if(document.register.password.value=="")
	{
		alert("Enter Password.");
		document.register.password.focus();
		return false;
	}
	else if(document.register.cpassword.value=="")
	{
		alert("Enter Confirm Password.");
		document.register.cpassword.focus();
		return false;
	}
	else if(document.register.password.value!=document.register.cpassword.value)
	{
		alert("Confirm Password is not match.");
		document.register.cpassword.value="";
		document.register.cpassword.focus();
		return false;
	}
	else if(document.register.mediatype.value=="" && document.register.othermediatype.value=="")
	{
		alert("Select Where did you hear about Top5.");
		document.register.mediatype.focus();
		return false;
	}
	else if(document.register.mediatype.value=="Other" && document.register.othermediatype.value=="")
	{
		alert("Enter Where did you hear about Top5.");
		document.register.othermediatype.focus();
		return false;
	}
	else if(document.register.terms.checked!=true)
	{
		alert("Please check Terms & Condition.");
		return false
	}
	else
	{
		return true;
	}
}	

function reg_mediatxt()
{
	if(document.register.mediatype.value=="Other")
	{
		document.register.othermediatype.disabled=false;
	}
	else
	{
		document.register.othermediatype.value="";
		document.register.othermediatype.disabled=true;
	}
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+MM_validateForm.arguments[i+1]+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Enter '+MM_validateForm.arguments[i+1]+'.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function rp_validterms()
{
	if(document.contact.terms.checked!=true)
	{
		alert("Please check Terms & Condition.");
		return false
	}
}
function ser_bookmarkthis_site()
{
	var url = this.location;
	var who = document.title;
	var ver = navigator.appName
	var num = parseInt(navigator.appVersion)
	if ((ver =="Microsoft Internet Explorer")&&(num >= 4)) {
			window.external.AddFavorite(url,who) ;
	}else{
		//alert("no");
	} 
}
function SF_chkform()
{
	var Toemail 	= document.sendmail.toemail.value;
	var Fromemail 	= document.sendmail.fromemail.value;
	
	if(document.sendmail.toname.value=="")
	{
		alert("Your friend's name cannot be blank.");
		document.sendmail.toname.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail)))
	{
		alert("Please enter valid email address for your friend.");
		document.sendmail.toemail.focus();
		return false;
	}
	else if(document.sendmail.fromname.value=="")
	{
		alert("Your name cannot be blank.");
		document.sendmail.fromname.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Fromemail)))
	{
		alert("Please enter valid email address for yourself.");
		document.sendmail.fromemail.focus();
		return false;
	}
	else if(document.sendmail.message.value=="")
	{
		alert("Please Enter Your Message.");
		document.sendmail.message.focus();
		return false;
	}
	else
	{
		return true;
	}
	
	
}

function stf_chkform()
{
	
	var Toemail1 	= document.sendmail.toemail1.value;
	var Toemail2 	= document.sendmail.toemail2.value;
	var Toemail3 	= document.sendmail.toemail3.value;
	var Toemail4 	= document.sendmail.toemail4.value;
	var Toemail5 	= document.sendmail.toemail5.value;
	
	var Fromemail 	= document.sendmail.fromemail.value;
	
	if(Toemail1=="" && Toemail2=="" && Toemail3=="" && Toemail4=="" && Toemail5=="")
	{
		alert("Enter atlest one friend name and email address.");
		return false;
	}
	
	if(document.sendmail.toname1.value!="" || Toemail1!="")
	{
		if(document.sendmail.toname1.value=="")
		{
			alert("Your first friend's name cannot be blank.");
			document.sendmail.toname1.focus();
			return false;
		}
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail1)))
		{
			alert("Please enter valid email address for your first friend.");
			document.sendmail.toemail1.focus();
			return false;
		}
	}
	
	if(document.sendmail.toname2.value!="" || Toemail2!="")
	{
		if(document.sendmail.toname2.value=="")
		{
			alert("Your second friend's name cannot be blank.");
			document.sendmail.toname2.focus();
			return false;
		}
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail2)))
		{
			alert("Please enter valid email address for your second friend.");
			document.sendmail.toemail2.focus();
			return false;
		}
	}

	if(document.sendmail.toname3.value!="" || Toemail3!="")
	{
		if(document.sendmail.toname3.value=="")
		{
			alert("Your third friend's name cannot be blank.");
			document.sendmail.toname3.focus();
			return false;
		}
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail3)))
		{
			alert("Please enter valid email address for your third friend.");
			document.sendmail.toemail3.focus();
			return false;
		}
	}
	
	if(document.sendmail.toname4.value!="" || Toemail4!="")
	{
		if(document.sendmail.toname4.value=="")
		{
			alert("Your fourth friend's name cannot be blank.");
			document.sendmail.toname4.focus();
			return false;
		}
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail4)))
		{
			alert("Please enter valid email address for your fourth friend.");
			document.sendmail.toemail4.focus();
			return false;
		}
	}

	if(document.sendmail.toname5.value!="" || Toemail5!="")
	{
		if(document.sendmail.toname5.value=="")
		{
			alert("Your fifth friend's name cannot be blank.");
			document.sendmail.toname5.focus();
			return false;
		}
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Toemail5)))
		{
			alert("Please enter valid email address for your fifth friend.");
			document.sendmail.toemail5.focus();
			return false;
		}
	}
		
	if(document.sendmail.fromname.value=="")
	{
		alert("Your name cannot be blank.");
		document.sendmail.fromname.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Fromemail)))
	{
		alert("Please enter valid email address for yourself.");
		document.sendmail.fromemail.focus();
		return false;
	}
	if(document.sendmail.message.value=="")
	{
		alert("Please Enter Your Message.");
		document.sendmail.message.focus();
		return false;
	}

	return true;
}
function sitesearch_checkvalid()
{
	var Tmpkey=document.pagesearchfrm.keyword.value;
	var Tmpkey1=Tmpkey.replace("&","--");
	
	if(Tmpkey1!="")
	{
		document.pagesearchfrm.action="sitepages_search.php?keyword=" + Tmpkey1;
	}
	else
	{
		document.pagesearchfrm.action="sitepages_search.php";
	}
	document.pagesearchfrm.submit();
		return true;
}
function timezone_get_rates(val){
	var start = 0;
	var leng = 0;
	var len = val.length;
	if(len == 10){
		start = 5;
		leng = 5;
	}
	if(len == 8){
		start = 4;
		leng = 4;
	}
	//document.ratecheck.rate800.value = val.substr(0,leng);
	
	if(val.substr(start,leng))
	{
		document.ratecheck.fixtext.value="00 11  +";
	}
	else
	{
		document.ratecheck.fixtext.value="";
	}
	document.ratecheck.ratelocal.value = val.substr(start,leng);
}

function timezonesrc_nationtime()
{
	if(document.timezonefrm.nation.value=="")
	{
		alert("Please Select First Letter for the Country Name.");
		return false;
	}
	else
	{
		document.timezonefrm.action="timezone.php?CNTID=" + document.timezonefrm.nation.value;
		document.timezonefrm.submit();
	}
}

function ttools_chkvalid()
{
	
	if(document.Form1.tbUsername.value=="")
	{
		alert("Enter Username.");
		document.Form1.tbUsername.focus();
		return false;
	}
	else if(document.Form1.tbPassword.value=="")
	{
		alert("Enter Password.");
		document.Form1.tbPassword.focus();
		return false;
	}
	else
	{
		return true;
	}
}
function editchangeaction()
{
	
	var flag ="N";
	var imgflag="N";
	for(i= 1; i < document.postadd.length; i++)
	{
		if(document.postadd.elements[i].type =="text")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				flag ="Y";
				document.postadd.elements[i].focus();
				break;
			}
		}
		if(document.postadd.elements[i].type =="textarea")
		{
			if(isBlank(document.postadd.elements[i].value))
			{
				flag ="Y";
				document.postadd.elements[i].focus();
				break;
			}
		}
		if(document.postadd.elements[i].type =="file")
		{
			if(!isBlank(document.postadd.elements[i].value))
			{
				imgflag="N";	
				if(!DoPreview(document.postadd.elements[i].value))
				{
					imgflag="R";
					document.postadd.elements[i].focus();
					break;
				}
			}	
		}
	}
	if(flag =="Y")
	{
		alert("Please fill up complete the details");
		return false;
	}
	else if(imgflag=="R")
	{
		//alert("Please Upload image file width lessthen 800 and height lessthen 600");
		alert("The image you are trying to upload is too large.\nPlease select an image which is less than 800 pixels wide by 600 pixels high.\nPlease also ensure that you do not upload a file size greater than 100k as this will take too long too download.");
		return false;
	}	
	else
	{
		document.postadd.action="editclassified.php";
		document.postadd.submit();
	}
}
function spWin(win_nm,nm,w,h)
{
    	w = eval(w) + 32;
    	h = eval(h) + 62;
    	
    	if(w<400)
    		w=400;
    	if(h<250)
    		h=250;
    	var hs=screen.height; hs=hs-80;
    	var ws=screen.width; ws=ws-10;
        if(h>hs) h = hs;
        if(w>ws) w = ws ;
    	
    	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,top=0';
        var newImg = open(win_nm,nm,myfeatures);
    	newImg.focus();
}
//function begintimer()
//{ 
//	var parselimit=1;
////	if (!document.images) 
////		return 
////	if (parselimit==1) 
////		var x=window.confirm("You were way to slow.. Click Ok") 
////	if (x) 
////		self.location="wronganswer.html" 
////	else
////	{ 
//		parselimit-=1 
//		curmin=Math.floor(parselimit/60) 
//		cursec=parselimit%60 
//		if (curmin!=0) 
//			curtime=curmin+" minutes and "+cursec+" seconds left" 
//		else 
//			curtime=cursec+" seconds left" 
//		window.status=curtime
//		setTimeout("begintimer()",1000)
//	//} 
//}
function DoPreview(imagesource)
{
  
  var filename="";
  var imcounter=1;
  var Img = new Image();
  var newid=1;
  var tmpwidth=0;
  var tmpheight=0; 
  for(newid=1;newid<4;newid++)
  {
	  filename = imagesource;
	  //var imcounter=1;
	  var Img = new Image();
	  Img.src = filename;
	  tmpwidth=Img.width;
	  tmpheight=Img.height;
//	  alert("current" + newid);
//	  alert("0 flas " + tmpwidth);
//	  alert("0 fals " + tmpheight);
	  
	  if(eval(tmpwidth) <= 0 || eval(tmpheight) <= 0)
	  {
	      
//	      alert("1 flas " + tmpwidth);
//		  alert("1 fals " + tmpheight);
//	      filename = imagesource;
//		  //var imcounter=1;
		  var Img = new Image();
		  Img.src = filename;
	      tmpwidth=Img.width;
	  	  tmpheight=Img.height;
	  	  
      	 if(eval(tmpwidth) > 805 || eval(tmpheight) > 605)
	  	 {
//		  	  alert("2 flase " + tmpwidth);
//		  	  alert("2 false " + tmpheight);
		  	  newid=6;
		  	  Img="";
			  tmpwidth=0;
			  tmpheight=0;
		  	  return false;
		  	  break;
		  	  
		 }
		 if(eval(tmpwidth) > 0 || eval(tmpheight) > 0)
		 {
//		 		alert("3 truen " + tmpwidth);
//			    alert("3 truen " + tmpheight);
			    newid=6;
			    Img="";
				tmpwidth=0;
			    tmpheight=0;
			    return true;
		 		break;
		  	  	
		 }
		 if(eval(tmpwidth)==0 || eval(tmpheight)==0)
		 {
			    newid=6;
			    Img="";
				tmpwidth=0;
			    tmpheight=0;
			    return true;
		 		break;
		 }
		 
	  }
	  else
	  {
	  	  if(eval(tmpwidth) > 805 || eval(tmpheight) > 605)
	  	  {
//		  	  alert("4 false " + tmpwidth);
//			  alert("4 false " + tmpheight);
		      newid=6;
		  	  Img="";
			  tmpwidth=0;
			  tmpheight=0;
		  	  return false;
		  	  break;
		  	  
		  }
		  else
		  {
//		  	  alert("4test " + tmpwidth);
//			  alert("4test " + tmpheight);
			  newid=6;
			  Img="";
			  tmpwidth=0;
			  tmpheight=0;
			  return true;
		  	  break;
		  	  
		  }
	  }
	}
}

/// Affiliate Registration
function affiliatereg_chkvalid()
{
	if(document.frmAffreg.cname.value=="")
	{
		alert("Enter Contact name.");
		document.frmAffreg.cname.focus();
		return false;
	}
	else if(document.frmAffreg.compname.value=="")
	{
		alert("Enter Company name.");
		document.frmAffreg.compname.focus();
		return false;
	}
	else if(document.frmAffreg.country.value=="")
	{
		alert("Select Country.");
		document.frmAffreg.country.focus();
		return false;
	}
	else if(document.frmAffreg.cemail.value=="")
	{
		alert("Enter valide email address.");
		document.frmAffreg.cemail.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmAffreg.cemail.value)))
	{
		alert("Your email address does not seem to be valid.");
		document.frmAffreg.cemail.focus();
		return false;
	}
	else if(document.frmAffreg.cphone.value=="")
	{
		alert("Enter Telephone.");
		document.frmAffreg.cphone.focus();
		return false;
	}
	else if(document.frmAffreg.sitename.value=="")
	{
		alert("Enter Site Name.");
		document.frmAffreg.sitename.focus();
		return false;
	}
	else if(document.frmAffreg.siteurl.value=="")
	{
		alert("Enter Site URL.");
		document.frmAffreg.siteurl.focus();
		return false;
	}
	else if(document.frmAffreg.content1.value=="")
	{
		alert("Select Primary Content Type.");
		document.frmAffreg.content1.focus();
		return false;
	}
	else if(document.frmAffreg.content2.value=="")
	{
		alert("Select Secondary Content Type.");
		document.frmAffreg.content2.focus();
		return false;
	}
	else if(document.frmAffreg.sitedesc.value=="")
	{
		alert("Enter Site Description.");
		document.frmAffreg.sitedesc.focus();
		return false;
	}
	else if(isNaN(document.frmAffreg.univisitor.value))
	{
		alert("Enter only Numeric Value.");
		document.frmAffreg.univisitor.focus();
		return false;
	}
	else if(document.frmAffreg.pass.value=="")
	{
		alert("Enter Password.");
		document.frmAffreg.pass.focus();
		return false;
	}
	else
	{	
		return true;
	}	
}

function smsg(msgStr) { //v1.0
  status=msgStr;
  document.prs_return = true;
}
function nosmsg(msgStr) { //v1.0
  status=msgStr;
  document.prs_return = true;
}
function deleteconfirm(str,strurl)
{
	if (confirm(str)) 
	{
		this.location=strurl;
	}
}
