var flag=0;var setting=0;
var flagcheck=false;

function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function popfilewindow(url)
{
	filewindow=window.open(url,'AttachFile','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes,status=yes');
	if (window.focus) {filewindow.focus()}
}
//Script Validation for Admin panel
function admin_validation(){
var txtUsername=document.Login.txtUsername.value;
	 if(txtUsername == "")
			 {
			 alert("User name  is empty");
			 document.Login.txtUsername.focus();
			 return false;
			 }
var txtPassword=document.Login.txtPassword.value;
	 if(txtPassword == "")
			 {
			 alert("Password  is empty");
			 document.Login.txtPassword.focus();
			 return false;
			 }
}
//Script validation for change password

function pwd_validation(){
var oldpwd=document.changepwd.oldpwd.value;
	 if(oldpwd == "")
			 {
			 alert("Old password is empty");
			 document.changepwd.oldpwd.focus();
			 return false;
			 }
	 var txtNewPassword1=document.changepwd.txtNewPassword1.value;
	 if(txtNewPassword1 == "")
			 {
			 alert("New password is empty");
			 document.changepwd.txtNewPassword1.focus();
			 return false;
			 }
	var txtNewPassword2=document.changepwd.txtNewPassword2.value;
	 if(txtNewPassword2 == "")
			 {
			 alert("Confirm  password is empty");
			 document.changepwd.txtNewPassword2.focus();
			 return false;
			 }
	if(txtNewPassword2 != txtNewPassword1){
	alert("Type the confirm password corredtly");
	document.changepwd.txtNewPassword2.focus();
	return false;
	}
}

//Move the Settings
function move(index,to) {
		var list = document.form.list;
		var total = list.options.length-1;
		if (index == -1) return false;
		if (to == +1 && index == total) return false;
		if (to == -1 && index == 0) return false;
		var items = new Array;
		var values = new Array;
		for (i = total; i >= 0; i--) {
		items[i] = list.options[i].text;
		values[i] = list.options[i].value;
		}
		for (i = total; i >= 0; i--) {
		if (index == i) {
		list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
		list.options[i] = new Option(items[i + to], values[i]);
		i--;
		}
		else {
		list.options[i] = new Option(items[i], values[i]);
		   }
		}
		list.focus();
}

//Function Priority
function submitCategoryForm() {
	var list = document.form.list;
	theList="";
	// start with a "?" to make it look like a real query-string
	for (i = 0; i <= list.options.length-1; i++) { 
	theList += list.options[i].text;
	// a "&" only BETWEEN the items, so not at the end
	if (i != list.options.length-1) theList += "&;";
	}
	document.form.priority.value=theList;
	document.form.action="classifiedcategoryorder.php?do=classic";
	}


//Function Change Color
function ChangeColor(s,dest)
  {
  	var newcolor=showModalDialog("../../include/select_color.html","","resizable: no; help: no; status: no; scroll: no;");
	if(newcolor != null)
	document.getElementById(s).value="#"+newcolor;
	document.getElementById(dest).style.background="#"+newcolor;
  }
  
//Validation for add category for blog
function cat_validate(){
 if (document.frm_addcatblog.txt_blogcategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatblog.txt_blogcategory.focus();
				return false;
		}
}


function showState(passcountry){
		if (passcountry == "United States of America"){
			
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="block";
				postate.style.visibility="visible";
			}
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="none";
				pootherstate.style.visibility="hidden";
			}
		}
		else{
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="block";
				pootherstate.style.visibility="visible";
			}
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="none";
				postate.style.visibility="hidden";
			}
		}
	}


//validation for add blog
function addblog_validate(){
		if (document.frm_addblog.submenu.value == "") 
			{
					alert ("Please Select the Submenu.");
					document.frm_addblog.submenu.focus();
					return false;
			}	 
		if (document.frm_addblog.catid.value == "") 
			{
					alert ("Please Enter the Category Name.");
					document.frm_addblog.catid.focus();
					return false;
			}
		
		 if (document.frm_addblog.title.value == "") 
			{
					alert ("Please Enter the Title.");
					document.frm_addblog.title.value == ""
					document.frm_addblog.title.focus();
					return false;
			}
		 if (document.frm_addblog.author.value == "") 
			{
					alert ("Please Enter the Author Name.");
					document.frm_addblog.author.value == ""
					document.frm_addblog.author.focus();
					return false;
			}
		 if (document.frm_addblog.sdesc.value == "") 
			{
					alert ("Please Enter the Short Description.");
					document.frm_addblog.sdesc.value == ""
					document.frm_addblog.sdesc.focus();
					return false;
			}
			
}

//Function alert message Display  
  function confirmMsg(msg){
	if(!confirm(msg)){
		return false;
	} else {
		return true;
	}
}

function changecat_blog()
	{
	var catname=document.frm_viewblog.catid.value;
	var dof="blog";
		if (catname=="All")
			{
				window.location.href="viewblog.php?do="+dof;
			}
		else
			{
				window.location.href="viewblog.php?orders="+document.frm_viewblog.catid.value+"&do="+dof;
			}
	}
	
function changecat_blog_submenu()
	{
	var catname=document.frm_viewblog.submenu.value;
	var dof="blog";
		if (catname=="All")
			{
				window.location.href="viewblog.php?do="+dof;
			}
		else
			{
				window.location.href="viewblog.php?submenu="+document.frm_viewblog.submenu.value+"&do="+dof;
			}
	}
	
	function changecat_cusad()
	{
	var catname=document.frm_viewcusad.catid.value;
	var dof="classic";
		if (catname=="All")
			{
				window.location.href="cusad.php?do="+dof;
			}
		else
			{
				window.location.href="cusad.php?li="+document.frm_viewcusad.catid.value+"&do="+dof;
			}
	}
	
	function changecat_cusprofile()
	{
	var catname=document.frm_viewcusad.clprofile.value;
	var dof="classic";
		if (catname=="All")
			{
				window.location.href="cusad.php?do="+dof;
			}
		else
			{
				window.location.href="cusad.php?profileid="+document.frm_viewcusad.clprofile.value+"&do="+dof;
			}
	}
	
	
	function changecat_viewnews()
	{
	var catname=document.frm_viewnews.catid.value;
	var dof="news";
		if (catname=="All")
			{
				window.location.href="viewnews.php?do="+dof;
			}
		else
			{
				window.location.href="viewnews.php?li="+document.frm_viewnews.catid.value+"&do="+dof;
			}
	}
	
	function changecat_viewsecondarynews()
	{
	var catname=document.frm_viewnews.catid.value;
	var dof="news";
		if (catname=="All")
			{
				window.location.href="viewsecondaryarchives.php?do="+dof;
			}
		else
			{
				window.location.href="viewsecondaryarchives.php?li="+document.frm_viewnews.catid.value+"&do="+dof;
			}
	}
	
	function changecat_viewcurrentnews()
	{
	var catname=document.frm_viewnews.catid.value;
	var dof="news";
		if (catname=="All")
			{
				window.location.href="viewcurrentnews.php?do="+dof;
			}
		else
			{
				window.location.href="viewcurrentnews.php?li="+document.frm_viewnews.catid.value+"&do="+dof;
			}
	}
	
	
	
	
	function changecat_viewprofile()
	{
	var catname=document.frm_viewprofile.catid.value;
	var dof="directory";
		if (catname=="All")
			{   
				window.location.href="index.php?task=profile_view&do="+dof;
			}
		else
			{	
				window.location.href="index.php?task=profile_view&li="+document.frm_viewprofile.catid.value+"&do="+dof;
			}
	}
	
	
	
	function changecat_viewclassic()
	{
	var catname=document.frm_viewclassic.catid.value;
	var dof="classic";
		if (catname=="All")
			{
				window.location.href="viewclassic.php?do="+dof;
			}
		else
			{
				window.location.href="viewclassic.php?li="+document.frm_viewclassic.catid.value+"&do="+dof;
			}
	}
	
	function changecat_banner()
	{
	var catname=document.frm_bannerad.comid.value;
	var dof="cusad";
		if (catname=="All")
			{
				window.location.href="viewcustomerad.php?do="+dof;
			}
		else
			{
				window.location.href="viewcustomerad.php?li="+document.frm_bannerad.comid.value+"&do="+dof;
			}
	}
	
	function changecat_viewcustomer()
	{
	var catname=document.frm_viewcustomer.catid.value;
	var dof="customer";
		if (catname=="All")
			{
				window.location.href="viewcustomer.php?do="+dof;
			}
		else
			{
				window.location.href="viewcustomer.php?li="+document.frm_viewcustomer.catid.value+"&do="+dof;
			}
	}
	function changecat_viewlinks()
	{
	var catname=document.frm_viewlinks.catid.value;
	var dof="link";
		if (catname=="All")
			{
				window.location.href="viewlink.php?do="+dof;
			}
		else
			{
				window.location.href="viewlink.php?li="+document.frm_viewlinks.catid.value+"&do="+dof;
			}
	}
	
	function changecat_viewproduct()
	{
	var catname=document.frm_viewproduct.catid.value;
	var dof="shop";
		if (catname=="All")
			{
				window.location.href="viewproduct.php?do="+dof;
			}
		else
			{
				window.location.href="viewproduct.php?li="+document.frm_viewproduct.catid.value+"&do="+dof;
			}
	}
	
	
	
//validation for add category(classified)
function catclass_validate(){
	
 if (document.frm_addcatclass.submenu.value == "") 
		{
				alert ("Please Choose the Submenu.");
				document.frm_addcatclass.submenu.focus();
				return false;
		}
	
 if (document.frm_addcatclass.txt_classiccategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatclass.txt_classiccategory.focus();
				return false;
		}
}

//Validation for files Place Ad
function adfilevalidate(){
	if(document.frm_PlaceAdfileadd.hiddenlogo.value == ""){
		if(document.frm_PlaceAdfileadd.filename.value == ""){
		        alert("Please select the file to upload");
				document.frm_PlaceAdfileadd.filename.focus();
				return false;
		}
	}
}
//Validation for files classifieds
function clfilevalidate(){
	if(document.frm_Adfileadd.hiddenlogo.value == ""){
	if(document.frm_Adfileadd.filename.value == ""){
		        alert("Please select the file to upload");
				document.frm_Adfileadd.filename.focus();
				return false;
		}
	}
}


//validation for addclassified
function addclass_validate(){
	
       if (document.frm_addclass.submenu.value == "") 
		{
				alert ("Please select the Submenu.");
				document.frm_addclass.submenu.focus();
				return false;
		}
	
       if (document.frm_addclass.catid.value == "") 
		{
				alert ("Please select the Category Name.");
				document.frm_addclass.catid.focus();
				return false;
		}
		 if (document.frm_addclass.heading.value == "") 
		{
				alert ("Please enter the title.");
				document.frm_addclass.heading.value == ""
				document.frm_addclass.heading.focus();
				return false;
		}
		if (document.frm_addclass.dateissue22.value == "") 
		{
				alert ("Please choose the starting date");
				document.frm_addclass.dateissue22.value == ""
				document.frm_addclass.dateissue22.focus();
				return false;
		}
		if (document.frm_addclass.dateissue2.value == "") 
		{
				alert ("Please choose the ending date");
				document.frm_addclass.dateissue2.value == ""
				document.frm_addclass.dateissue2.focus();
				return false;
		}
		if(document.frm_addclass.dateissue22.value != "" && document.frm_addclass.dateissue2.value!="")
		 if (!date_valid(document.frm_addclass.dateissue22.value,document.frm_addclass.dateissue2.value)) 
		{
				alert ("Please State the ending date in Date Picker.");
				document.frm_addclass.dateissue2.value == ""
				document.frm_addclass.dateissue2.focus();
				return false;
		}
}

//validation for addcustomer
function addcust_validate(){
		if (document.frm_custad.comid.value == "") 
		{
				alert ("Please Select the Company Name.");
				document.frm_custad.comid.focus();
				return false;
		}
		if (document.frm_custad.heading.value == "") 
		{
				alert ("Please Enter the Contract Description.");
				document.frm_custad.heading.focus();
				return false;
		}
		if (document.frm_custad.eventdate.value == "") 
		{
				alert ("Please choose the Starting date");
				document.frm_custad.eventdate.value == ""
				document.frm_custad.eventdate.focus();
				return false;
		}
		if (document.frm_custad.eventdate2.value == "") 
		{
				alert ("Please choose the ending date");
				document.frm_custad.eventdate2.value == ""
				document.frm_custad.eventdate2.focus();
				return false;
		}
		if(document.frm_custad.eventdate.value != "" && document.frm_custad.eventdate2.value!="")
		 if (!date_valid(document.frm_custad.eventdate.value,document.frm_custad.eventdate2.value)) 
		{
				alert ("Please State the starting date in Date Picker.");
				document.frm_custad.eventdate.focus();
				return false;
		}
}
//validation for placead
function placead_validate(){
		if (document.placead.first.value == "") 
		{
				alert ("Please enter the first name.");
				document.placead.first.focus();
				return false;
		}
		if (document.placead.last.value == "") 
		{
				alert ("Please enter the last name.");
				document.placead.last.focus();
				return false;
		}
		if (document.placead.address.value == "") 
		{
				alert ("Please enter the address.");
				document.placead.address.focus();
				return false;
		}
		if (document.placead.city.value == "") 
		{
				alert ("Please enter the city.");
				document.placead.city.focus();
				return false;
		}
		if(document.placead.country.value == "")
		{
		        alert("Please select the country");
				document.placead.country.focus();
				return false;
		}
		if(document.placead.country.value == "United States of America" && document.placead.state1.value == "")
		{
		        alert("Please select the state");
				document.placead.state1.focus();
				return false;
		}
		if(document.placead.country.value != "United States of America" && document.placead.state.value == "")
		{
		        alert("Please enter the state");
				document.placead.state.focus();
				return false;
		}
		if (document.placead.zip.value == "") 
		{
				alert ("Please enter the zip code.");
				document.placead.zip.focus();
				return false;
		}
		if (document.placead.phone.value == "") 
		{
				alert ("Please enter the phone number.");
				document.placead.phone.focus();
				return false;
		}
		phone = document.placead.phone;
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}
			
		if (!validateEmail(document.placead.emailaddr.value,1,1)) 
		{
				document.placead.emailaddr.focus();
				return false;
		}
		if (document.placead.catid.value == "") {
						alert ("Please select the category name.");
						document.placead.catid.focus();
						return false;
		}
		recordvalue = document.placead.addays.value;
			if( (recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) || (recordvalue > 65535) ){
				alert ("Please enter the valid number of ad days.");
				document.placead.addays.focus();
				return false;
		}
		
		if (document.placead.title.value == "") {
							alert ("Please enter the classified title.");
							document.placead.title.focus();
							return false;
			}
			
		if (document.placead.submenu.value == "") {
							alert ("Please Choose the Submenu.");
							document.placead.submenu.focus();
							return false;
			}
			
		if (document.placead.catid.value == "") {
							alert ("Please Choose the Category Name.");
							document.placead.catid.focus();
							return false;
			}
			
		if (document.placead.insertdate.value == "") 
		{
				alert ("Please enter the insertion date.");
				document.placead.insertdate.focus();
				return false;
		}

		
		
					
}


//Validation for add category in customer
function addcatcus_validate(){
 if (document.frm_addcatcust.txt_customercategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatcust.txt_customercategory.focus();
				return false;
		}
}

//Validation for add customer
function customeradd_validate(){
	if (document.frm_customeradd.catid.value == "") 
		{
				alert ("Please Select the Category Name.");
				document.frm_customeradd.catid.focus();
				return false;
		}
		if (document.frm_customeradd.companyname.value == "") 
		{
				alert ("Please Enter the Company Name.");
				document.frm_customeradd.companyname.value == ""
				document.frm_customeradd.companyname.focus();
				return false;
		}
//Phone number validation		  
			var phone=document.frm_customeradd.phone;
			if(phone.value == ""){
			alert("Phone number is mandatory");
			phone.focus();
			return false;
			}
			if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}
		if (document.frm_customeradd.dateissue22.value == "") 
		{
				alert ("Please choose the starting date");
				document.frm_customeradd.dateissue22.value == ""
				document.frm_customeradd.dateissue22.focus();
				return false;
		}
		if (document.frm_customeradd.dateissue2.value == "") 
		{
				alert ("Please choose the ending date");
				document.frm_customeradd.dateissue2.value == ""
				document.frm_customeradd.dateissue2.focus();
				return false;
		}
		if(document.frm_customeradd.dateissue22.value != "" && document.frm_customeradd.dateissue2.value!="")
		 if (!date_valid(document.frm_customeradd.dateissue22.value,document.frm_customeradd.dateissue2.value)) 
		{
				alert ("Please State the ending date in Date Picker.");
				document.frm_customeradd.dateissue2.value == ""
				document.frm_customeradd.dateissue2.focus();
				return false;
		}
}
//Validation for community events
function editevent_validate(){
	if(document.frm_editevent.name.value == "")
		{
					alert("Please enter the name.");
					document.frm_editevent.name.focus();
					return false;
		}

		if (!validateEmail(document.frm_editevent.emailaddr.value,1,1)) 
		{
					document.frm_editevent.emailaddr.focus();
					return false;
		}
		if (document.frm_editevent.eventdate.value == "") 
		{
				alert ("Please choose the event date from date picker");
				document.frm_editevent.eventdate.value == ""
				document.frm_editevent.eventdate.focus();
				return false;
		}
		if (document.frm_editevent.heading.value == "") 
		{
				alert ("Please Enter the Heading.");
				document.frm_editevent.heading.focus();
				return false;
		}
		if(document.frm_editevent.location.value == "")
		{
					alert("Please enter the location name.");
					document.frm_editevent.location.focus();
					return false;
		}
		
}
//Validation for event date
function addevent_validate(){
	   if (document.frm_addevent.heading.value == "") 
		{
				alert ("Please Enter the Heading.");
				document.frm_addevent.heading.focus();
				return false;
		}
		if (document.frm_addevent.eventdate.value == "") 
		{
				alert ("Please choose the event date from date picker");
				document.frm_addevent.eventdate.value == ""
				document.frm_addevent.eventdate.focus();
				return false;
		}
		
}

//validation for add category(link)
function addcatlink_validate(){
 	if (document.frm_addcatlink.txt_linkcategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatlink.txt_linkcategory.focus();
				return false;
		}
}

//Validation for add  link
function addlink_validate(){
		if (document.frm_addlink.catid.value == "") 
		{
				alert ("Please Select the Category Name.");
				document.frm_addlink.catid.focus();
				return false;
		}
		if (document.frm_addlink.txt_linktitle.value == "") 
		{
				alert ("Please Enter the Website Title.");
				document.frm_addlink.txt_linktitle.focus();
				return false;
		}
		if (document.frm_addlink.txt_fulllink.value == "") 
		{
				alert ("Please Enter the Website URL.");
				document.frm_addlink.txt_fulllink.focus();
				return false;
		}
		re = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|in|cd|nw)$/i
		 if (!(re.test(document.frm_addlink.txt_fulllink.value))) {
		 alert ("Invalid URL.");
		 document.frm_addlink.txt_fulllink.focus();
		 return false;
		 }
}

//validation for menu setting
function menuset_validate(){
	if (document.MENUSETTING.menuname.value == "") 
		{
				alert ("Please Enter the Menu Name.");
				document.MENUSETTING.menuname.focus();
				return false;
		}
}

//validation for submenu setting
function submenu_validate(){
	if (document.submenusetting.submenuname.value == "") 
		{
				alert ("Please Enter the Submenu Name.");
				document.submenusetting.submenuname.focus();
				return false;
		}
}

//validation for add category  news
function addcatnews_validate(){
	   /* if (document.frm_addcatnews.txt_newscategory.value == "") 
		{
				alert ("Please enter the source line.");
				document.frm_addcatnews.txt_newscategory.focus();
				return false;
		}
		if (document.frm_addcatnews.srcstatus.value == "") 
		{
				alert ("Please choose the source line status.");
				document.frm_addcatnews.srcstatus.focus();
				return false;
		}*/
		if (document.frm_addcatnews.txt_byline.value == "") 
		{
				alert ("Please enter the By Line.");
				document.frm_addcatnews.txt_byline.focus();
				return false;
		}
		/*if (document.frm_addcatnews.bylinestatus.value == "") 
		{
				alert ("Please choose the By Line Status.");
				document.frm_addcatnews.bylinestatus.focus();
				return false;
		}*/
}

//validation for add news
function addnews_validate(){
	if (document.newsadd.heading.value == "") 
		{
				alert ("Please Enter the Heading.");
				document.newsadd.heading.focus();
				return false;
		}
	if (document.newsadd.issuedate.value == "") 
		{
				alert ("Please Enter the Issue Date.");
				document.newsadd.issuedate.focus();
				return false;
		}
	var dt=document.newsadd.issuedate;
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
	if (document.newsadd.dateissue.value == "") 
		{
				alert ("Please choose the starting date");
				document.newsadd.dateissue.value == "";
				document.newsadd.dateissue.focus();
				return false;
		}
	if (document.newsadd.dateissue2.value == "") 
		{
				alert ("Please choose the ending date");
				document.newsadd.dateissue2.value == "";
				document.newsadd.dateissue2.focus();
				return false;
		}
	if(document.newsadd.dateissue.value != "" && document.newsadd.dateissue2.value!="")
	if (!date_valid(document.newsadd.dateissue.value,document.newsadd.dateissue2.value)) 
		{
				alert ("Please State the starting date in Date Picker.");
				document.newsadd.dateissue2.value == "";
				document.newsadd.dateissue2.focus();
				return false;
		}
}


//validation for newsrate
function newsrate_validate(){
	if (document.frm_newsrate.newsrate.value == "") 
		{
				alert ("Please Enter the rate.");
				document.frm_newsrate.newsrate.focus();
				return false;
		}
}		

//Validation for add category in newsletter
function newscategory_validate(){
 		if (document.frm_addcatletter.txt_newslettercategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatletter.txt_newslettercategory.focus();
				return false;
		}
}
		
//Validation for addsubscrber
function addsub_validate(){
		if (document.subscribe.txtfirst.value == "") 
		{
				alert ("Please enter the first name.");
				document.subscribe.txtfirst.focus();
				return false;
		}
		
		if(!validateEmail(document.subscribe.txtemail.value,1,1)) 
		{
				document.subscribe.txtemail.focus();
				return false;
		}
		
		if(document.subscribe.txt_stdate.value != "" && document.subscribe.eventdate2.value!=""){
			 if (!date_valid(document.subscribe.txt_stdate.value,document.subscribe.eventdate2.value)) 
			{
					alert ("Please choose the ending date in Date Picker.");
					document.subscribe.eventdate2.value == "";
					document.subscribe.eventdate2.focus();
					return false;
			}
		}
		
		if (document.subscribe.txt_username.value == "") 
		{
				alert ("Please enter the user name.");
				document.subscribe.txt_username.focus();
				return false;
		}
		if (document.subscribe.txt_password.value == "") 
		{
				alert ("Please enter the password.");
				document.subscribe.txt_password.focus();
				return false;
		}
}

//validation for blog
function poll_validate(){
 		if (document.frm_addpoll.txt_question.value == "") 
		{
				alert ("Please enter the question.");
				document.frm_addpoll.txt_question.focus();
				return false;
		}
		if (document.frm_addpoll.txt_ans1.value == "") 
		{
				alert ("Please enter the answer.");
				document.frm_addpoll.txt_ans1.focus();
				return false;
		}
		if (document.frm_addpoll.txt_ans2.value == "") 
		{
				alert ("Please enter the answer.");
				document.frm_addpoll.txt_ans2.focus();
				return false;
		}
}	

//validation for addcategory(shop)
function catshop_validate(){
 if (document.frm_addcatshop.txt_shopcategory.value == "") 
		{
				alert ("Please Enter the Category Name.");
				document.frm_addcatshop.txt_shopcategory.focus();
				return false;
		}
}

//validation for addproduct
function addproduct_validate(){
 if (document.frm_addproduct.catid.value == "") 
		{
				alert ("Please enter the category name.");
				document.frm_addproduct.catid.focus();
				return false;
		}
		 if (document.frm_addproduct.heading.value == "") 
		{
				alert ("Please Enter the product name.");
				document.frm_addproduct.heading.focus();
				return false;
		}
		if (document.frm_addproduct.dateissue.value == "") 
		{
				alert ("Please choose the starting date");
				document.frm_addproduct.dateissue.value == "";
				document.frm_addproduct.dateissue.focus();
				return false;
		}
	if (document.frm_addproduct.dateissue2.value == "") 
		{
				alert ("Please choose the ending date");
				document.frm_addproduct.dateissue2.value == "";
				document.frm_addproduct.dateissue2.focus();
				return false;
		}
	if(document.frm_addproduct.dateissue.value != "" && document.frm_addproduct.dateissue2.value!="")
	if (!date_valid(document.frm_addproduct.dateissue.value,document.frm_addproduct.dateissue2.value)) 
		{
				alert ("Please state the ending date in Date Picker.");
				document.frm_addproduct.dateissue2.value == "";
				document.frm_addproduct.dateissue2.focus();
				return false;
		}
}

//validation for add responsibility
function addresp_validate(){
	 if (document.frm_addresp.response.value == "") 
		{
				alert ("Please choose the responsibility.");
				document.frm_addresp.response.focus();
				return false;
		}
}

//validation for addusers
function addusers_validate(){
	 if (document.frm_adduser.user.value == "") 
		{
				alert ("Please enter the user name.");
				document.frm_adduser.user.focus();
				return false;
		}
		if (document.frm_adduser.password.value == "") 
		{
				alert ("Please enter the password.");
				document.frm_adduser.password.focus();
				return false;
		}
		if (!validateEmail(document.frm_adduser.email.value,1,1)) 
		{
				document.frm_adduser.email.focus();
				return false;
		}
}	

//Validation for  message editor
function msgedit_validate(){
	 if (document.msgeditor.fromname.value == "") 
		{
				alert ("Please enter the from name.");
				document.msgeditor.fromname.focus();
				return false;
		}
	 if (!validateEmail(document.msgeditor.fromemail.value,1,1)) 
		{
				document.msgeditor.fromemail.focus();
				return false;
		}
	if (document.msgeditor.thanksmsg.value == "") 
		{
				alert ("Please enter the message.");
				document.msgeditor.thanksmsg.focus();
				return false;
		}
}

//Validation for Classified Users
function check_validation()
{
	
	if (document.clprofile.first.value == ""){
				alert ("Please enter the first name.");
				document.clprofile.first.focus();
				return false;
		}
		if (document.clprofile.last.value == ""){
				alert ("Please enter the last name.");
				document.clprofile.last.focus();
				return false;
		}
		if (document.clprofile.address.value == ""){
				alert ("Please enter the Address1.");
				document.clprofile.address.focus();
				return false;
		}
		
		if (document.clprofile.city.value == ""){
				alert ("Please enter the City.");
				document.clprofile.city.focus();
				return false;
		}
		if(document.clprofile.country.value == "")
		{
		        alert("Please select the country");
				document.clprofile.country.focus();
				return false;
		}
		if(document.clprofile.country.value == "United States of America" && document.clprofile.state1.value == "")
		{
		        alert("Please select the state");
				document.clprofile.state1.focus();
				return false;
		}
		if(document.clprofile.country.value != "United States of America" && document.clprofile.state.value == "")
		{
		        alert("Please enter the state");
				document.clprofile.state.focus();
				return false;
		}
		if (document.clprofile.zip.value == "") 
		{
				alert ("Please enter the zip code.");
				document.clprofile.zip.focus();
				return false;
		}
				if (document.clprofile.phone.value == "") 
		{
				alert ("Please enter the phone number.");
				document.clprofile.phone.focus();
				return false;
		}
		phone = document.clprofile.phone;
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}
		if (!validateEmail(document.clprofile.emailaddr.value,1,1)){
				document.clprofile.emailaddr.focus();
				return false;
		}
		if (document.clprofile.txtUsername.value == "") {
				alert ("Please enter the User name.");
				document.clprofile.txtUsername.focus();
				return false;
		}
		var namelen = document.clprofile.txtUsername.value;
		if(parseInt(namelen.length) < 6){
			alert ("Please enter the User name with atleast 6 characters.");
			document.clprofile.txtUsername.focus();
			return false;
		}
        if (document.clprofile.txtPassword.value == "") 
		{
				alert ("Please enter the password.");
				document.clprofile.txtPassword.focus();
				return false;
		}
		var passlen = document.clprofile.txtPassword.value;
		if(parseInt(passlen.length) < 6){
			alert ("Please enter the Password with atleast 6 characters.");
			document.clprofile.txtPassword.focus();
			return false;
		}
		 if (document.clprofile.txtPassword.value != document.clprofile.txtConfPassword.value) 
		{
				alert ("Password Mismatch. Please enter the confirm password correctly.");
				document.clprofile.txtConfPassword.focus();
				return false;
		}

}


//validation for newsletter
function newslr_validate(){
	 if (document.newslr.newstitle.value == "") 
		{
				alert ("Please enter the subject.");
				document.newslr.newstitle.focus();
				return false;
		}
}	

//Script validation for displaying the submenu-category
var lists=new Array();
		function emptyList( box ) {
			 while ( box.options.length ) box.options[0] = null;
			}
			function fillList( box, arr ) {
		   for ( i = 0; i < arr[0].length; i++ ) {
			option = new Option( arr[0][i], arr[0][i+1] );
			box.options[box.length] = option;
			i=i+1;
		  }
		  box.selectedIndex=0;
			}
		function changeList( box ) {
		list = lists[box.options[box.selectedIndex].value];
		emptyList( box.form.catid );
		fillList( box.form.catid, list );
		}

 //Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

//Email Validation Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}
	
function date_valid(txt_Disfrom,txt_Disto){
	var stdate=txt_Disfrom.split("/");
	var enddate=txt_Disto.split("/");
	var prostdate = new Date();
	prostdate.setFullYear(stdate[2]);
	prostdate.setMonth(stdate[0]-1);
	prostdate.setDate(stdate[1]);
	
	var proenddate = new Date();
	proenddate.setFullYear(enddate[2]);
	proenddate.setMonth(enddate[0]-1);
	proenddate.setDate(enddate[1]);
	
	var startingdate = prostdate.getTime();
	var endingdate = proenddate.getTime();

	if(startingdate > endingdate)
	{
		return false;
	}
	return true;
}

//Date Validation format mm/dd/yyyy
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=2000;
var maxYear=3100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	
	return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))?29:28
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function profilevalidation()
{
	var username=document.form1.txt_username.value;
	 if(username == "")
			 {
			 alert("Enter Username");
			 document.form1.txt_username.focus();
			 return false;
			 }
			 
	var password=document.form1.txt_password.value;
	
	 if(password == "")
			 {
			 alert("Enter Password");
			 document.form1.txt_password.focus();
			 return false;
			 }
	 if(password.length < 6)
			 {
			 alert("Password should above 6 characters");
			 document.form1.txt_password.focus();
			 return false;
			 } 
	
	var submenu=document.form1.submenu.value;
	 if(submenu == "")
			 {
			 alert("Select Category");
			 document.form1.submenu.focus();
			 return false;
			 }
	
	var firstname=document.form1.txt_fname.value;
	 if(firstname == "")
			 {
			 alert("FirstName  is empty");
			 document.form1.txt_fname.focus();
			 return false;
			 }
			 
	var lastname=document.form1.txt_lname.value;
	 if(lastname == "")
			 {
			 alert("LastName  is empty");
			 document.form1.txt_lname.focus();
			 return false;
			 }
			 
	var address=document.form1.txt_address1.value;
	 if(address == "")
			 {
			 alert("Addressline1 is empty");
			 document.form1.txt_address1.focus();
			 return false;
			 }
			 
	var city=document.form1.txt_city.value;
	 if(city == "")
			 {
			 alert("City Field is empty");
			 document.form1.txt_city.focus();
			 return false;
			 }
			 
	var state=document.form1.txt_state.value;
	 if(state == "")
			 {
			 alert("State Field is empty");
			 document.form1.txt_state.focus();
			 return false;
			 }
			 
	var member=document.form1.member.value;
	 if(member == "")
			 {
			 alert("Select any one membership");
			 document.form1.member.focus();
			 return false;
			 }
			 
	var day=document.form1.day.value;
	 if(day == "")
			 {
			 alert("Select Date");
			 document.form1.day.focus();
			 return false;
			 }
			 
	var month=document.form1.month.value;
	 if(month == "")
			 {
			 alert("Select Month");
			 document.form1.month.focus();
			 return false;
			 }
			 
	/*var year=document.form1.year.value;
	 if(year == "")
			 {
			 alert("Enter Year");
			 document.form1.year.focus();
			 return false;
			 }
	if(isNaN(year))
			{
				 alert("Enter only Nubers");
				 document.form1.year.focus();
				 return false;
			}
	if(year.length > 4 && year.length < 4)
			{
				 alert("Enter valid Year");
				 document.form1.year.focus();
				 return false;
			}
			
	var email=document.form1.txt_email.value;
	
		if (!validateEmail(document.form1.txt_email.value,1,1)) 
		{
				document.form1.txt_email.focus();
				return false;
		}*/
	
	
		phone = document.form1.txt_phonehome;
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}
			 
			 
		var flag=0;
		var chklen = document.form1.task_profile.length;
		for(index=0;index <chklen; index++){
			if(document.form1.task_profile[index].checked == false){
				flag++;
			}
		}
		if(flag == chklen){
			alert("Please choose any one of the task choice");
			return false;
		}
			 
			 
	var profile=document.form1.txt_profile.value;
	
	 if(profile == "")
			 {
			 alert("Select Profile");
			 document.form1.txt_profile.focus();
			 return false;
			 }
}

function reportvalidation()
{
	var searchval=document.form1.search1.value;
	 if(searchval == "")
			 {
			 alert("Enter Search phrase");
			 document.form1.search1.focus();
			 return false;
			 }
}
function directory_validate()
{
	if(document.frm_optset.tablebgcolor.value == "")
	{
		alert("Enter Table BG Color");
		return false;
	}
	if(document.frm_optset.tableheadbgcolor.value == "")
	{
		alert("Enter Table Heading BG Color");
		return false;
	}
	if(document.frm_optset.headfontcolor.value == "")
	{
		alert("Enter Table Heading Font Color");
		return false;
	}
	if(document.frm_optset.linkcolor.value == "")
	{
		alert("Enter Link Color");
		return false;
	}
	if(document.frm_optset.mouseovercolor.value == "")
	{
		alert("Enter Mouse Over Link Color");
		return false;
	}
	if(document.frm_optset.classheadcolor.value == "")
	{
		alert("Enter Class head Link Color");
		return false;
	}
	if(document.frm_optset.classheadcolor.value == "")
	{
		alert("Enter Subheading Link Color");
		return false;
	}
	
	return true;
}

