// JavaScript Document
function calldel(m)
{
  if(!confirm(m))
  {
    return false;
  }
  else
  return true;
}
function  frontlog()
{
	if(document.Frmlogin.txtUsername.value=="")
	{
	   alert("Enter the Username");
	   document.Frmlogin.txtUsername.focus();
	   return false;
	}
	if(document.Frmlogin.txtPassword.value=="")
	{
	   alert("Enter the Password");
	   document.Frmlogin.txtPassword.focus();
	   return false;
	}	
	
	return true;
}
//subscribe validations
function newsletter_validation()
{
			if(document.subscribe.fromname.value=="")
			{
			   alert("Enter the name");
			   document.subscribe.fromname.focus();
			   return false;
			}
	 if(!validateEmail(document.subscribe.frommail.value,1,1))
	{
	   document.subscribe.frommail.focus();
	   return false;
	}
}
function sendnewsletter_validation(){
	if(document.snewsletter.newstitle.value == "") 
	{
		alert ("Enter the newsletter title.");
		document.snewsletter.newstitle.focus();
		return false;
	}
}
function editor_validation(){
	if(document.msgeditor.fromname.value == "") 
	{
		alert ("Enter the From name.");
		document.msgeditor.fromname.focus();
		return false;
	}
	if(!validateEmail(document.msgeditor.fromemail.value,1,1)) 
	{
		document.msgeditor.fromemail.focus();
		return false;
	}
}

function newsletter_validation1()
{
	if(document.newsletter.fromname.value == "") 
	{
		alert ("Enter the From name.");
		document.newsletter.fromname.focus();
		return false;
	}
	if(!validateEmail(document.newsletter.frommail.value,1,1)) 
	{
		document.newsletter.frommail.focus();
		return false;
	}
}
//subscribe editvalidations
function newsletter_validation1()
{
			if(document.sub_edit.fromname.value=="")
			{
			   alert("Enter the name");
			   document.sub_edit.fromname.focus();
			   return false;
			}
	 if(!validateEmail(document.sub_edit.frommail.value,1,1))
	{
	   document.sub_edit.frommail.focus();
	   return false;
	}
}

//newsvalidations
function news_validation()
{
			if(document.frm_new.txtFromName.value=="")
			{
			   alert("Enter the FromName");
			   document.frm_new.txtFromName.focus();
			   return false;
			}
	 if(!validateEmail(document.frm_new.txtFromEmail.value,1,1))
	{
	   document.frm_new.txtFromEmail.focus();
	   return false;
	}
			if(document.frm_new.txtSubject.value=="")
			{
			   alert("Enter the Subject");
			   document.frm_new.txtSubject.focus();
			   return false;
			}
/*			if(document.frm_new.txtMessage.value=="")
			{
			   alert("Enter the Message");
			   document.frm_new.txtMessage.focus();
			   return false;
			}
*/
}
function changeList( box ) 
{
	list = lists[box.options[box.selectedIndex].value];
	if(box.options[box.selectedIndex].value != "select")
	{
		emptyList( box.form.subCategory );
		fillList( box.form.subCategory,list);
	}
}

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="index.php?task=eventcategoryorder";
	}
	
	//Function Priority
function submitForm() {
	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="index.php?do=category&task=categoryorder";
	}


function submitForm1() {
	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="index.php?task=subcategoryorder";
	}
	
//material validations
function material_validate()
{
      	if(document.frm_promaterial.txt_matname.value=="")
			{
			   alert("Please enter the material name");
			   document.frm_promaterial.txt_matname.focus();
			   return false;
			}
}
function subcategory_validation()
{
		if(document.frm_subcategory.txtCategory.value=="Select")
			{
			   alert("Please select the category name");
			   document.frm_subcategory.txtCategory.focus();
			   return false;
			}
      	if(document.frm_subcategory.txtSubCategory.value=="")
			{
			   alert("Please enter the sub category name");
			   document.frm_subcategory.txtSubCategory.focus();
			   return false;
			}
		if(document.frm_subcategory.txtStatus.value=="")
			{
			   alert("Please select the status");
			   document.frm_subcategory.txtStatus.focus();
			   return false;
			}
}


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;
	}
}

function custsearch_validation(){
	if(document.frm_cust.searchval.value=="")
			{
			   alert("Please enter the search text");
			   document.frm_cust.searchval.focus();
			   return false;
			}
}

function confirmMsg(msg){
	if(!confirm(msg)){
		return false;

	} else {
		return true;

	}
}

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 popup(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popservices(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function showsubcat(catid,mid){
	window.location.href = "index.php?task=addproduct&catname="+catid+"&m_id="+mid;
}
function addproduct_showsubcat(catid){
	window.location.href = "index.php?task=addproduct&catname="+catid;
}
function showhide(){
		if (!(document.frm_register.chkDelivery.checked)){
		delistyle=document.getElementById("delivery");
		    if(delistyle){
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById("delivery");
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
	}
	
//function for poll 
function pollscript() {
	var pollvalue = document.PostNewPoll.polloption.value;
	//window.location.href("index.php?task=poll_add&cnt="+pollvalue);
	document.PostNewPoll.action="index.php?task=poll_add&cnt="+pollvalue;
	document.PostNewPoll.submit();
}
function pollscriptedit(id) {
	var pollvalue = document.PostNewPoll.polloption.value;
	//window.location.href("index.php?task=poll_add&cnt="+pollvalue);
	document.PostNewPoll.action="index.php?task=poll_edit&id="+id+"&cnt="+pollvalue+"&action=true";
	document.PostNewPoll.submit();
}

//validation for General Setting
function generalsetting_validate(){
	if (document.form_general.txt_website.value == "") 
		{
			alert ("Please Enter the Website URL.");
			document.form_general.txt_website.focus();
			return false;
		}
		re = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|in|cd|nw)$/i
		 if (!(re.test(document.form_general.txt_website.value))) {
		 alert ("Invalid URL.");
		 document.form_general.txt_website.focus();
		 return false;
		 }
		
	if (document.form_general.txt_numrows.value == "") 
		{
			alert ("Please Enter the number of rows displayed per page.");
			document.form_general.txt_numrows.focus();
			return false;
		}
	recordvalue = document.form_general.txt_numrows.value;
		if((recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) || (recordvalue > 65535) ){
			alert ("Please enter the valid number of rows per page.");
			document.form_general.txt_numrows.focus();
			return false;
		}
	if (document.form_general.txt_admintitle.value == "") 
		{
			alert ("Please Enter the Admin title.");
			document.form_general.txt_admintitle.focus();
			return false;
		}
	if (document.form_general.txt_hometitle.value == "") 
		{
			alert ("Please Enter the Home page title.");
			document.form_general.txt_hometitle.focus();
			return false;
		}
}


//Myprofile validation
function myprofile_validate(){
	if (document.form_myprofile.txt_contactperson.value == "") 
		{
			alert ("Please Enter the Contact Person name.");
			document.form_myprofile.txt_contactperson.focus();
			return false;
		}
		if (!validateEmail(document.form_myprofile.txt_email.value,1,1)) 
		{
			document.form_myprofile.txt_email.focus();
			return false;
		}
		if (!validateEmail(document.form_myprofile.txt_email.value,1,1)) 
		{
			document.form_myprofile.txt_email.focus();
			return false;
		}
		if (document.form_myprofile.txt_address1.value == "") 
		{
			alert ("Please Enter the Address1.");
			document.form_myprofile.txt_address1.focus();
			return false;
		}
		if (document.form_myprofile.txt_city.value == "") 
		{
			alert ("Please Enter the City.");
			document.form_myprofile.txt_city.focus();
			return false;
		}
		if (document.form_myprofile.txt_state.value == "") 
		{
			alert ("Please Enter the State.");
			document.form_myprofile.txt_state.focus();
			return false;
		}
		recordvalue = document.form_myprofile.txt_postcode.value;
		if( (recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) ){
			alert ("Please enter the valid Postcode.");
			document.form_myprofile.txt_postcode.focus();
			return false;
		}
		if (document.form_myprofile.txt_country.value == "") 
		{
			alert ("Please Enter the Country.");
			document.form_myprofile.txt_country.focus();
			return false;
		}
		if (document.form_myprofile.txt_phone.value == "") 
		{
			alert ("Please Enter the Phone Number.");
			document.form_myprofile.txt_phone.focus();
			return false;
		}
		phone = document.form_myprofile.txt_phone;
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}
		if (document.form_myprofile.txt_username.value == "") 
		{
			alert ("Please Enter the User Name.");
			document.form_myprofile.txt_username.focus();
			return false;
		}
		if (document.form_myprofile.txt_password.value == "") 
		{
			alert ("Please Enter the Password.");
			document.form_myprofile.txt_password.focus();
			return false;
		}
}



//Function to get the 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;
  }

//Function for Department
function changecat_events(){
	var catname=document.frm_viewevents.catid.value;
		if (catname=="All"){
				window.location.href="index.php?task=eventview";
		}
		else{
				window.location.href="index.php?task=eventview&calmode="+document.frm_viewevents.catid.value;
		}
	}

//Add More Fields
function insertMoreUpload_form() 
{ 
	var nUploads = parseInt(document.getElementById('NumberOfUploads').value)+1;		 
	var tbody = document.getElementById("tabUpload").getElementsByTagName("tbody")[1]; 
	var row = document.createElement("TR"); 

	//insert second <td>
	var cell2 = document.createElement("TD");
	//cell2.setAttribute("colspan","2");
	cell2.setAttribute("valign","middle");
	cell2.setAttribute("align","center");
	//File
	var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","labelname" + nUploads);
	eInput.setAttribute("id","Label");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-serif; text-decoration:none;");	
	cell2.appendChild(eInput);
	
	// append all <td> to <tr>
	//insert second <td>
	var cell3 = document.createElement("TD");
	cell3.setAttribute("valign","middle");
	cell3.setAttribute("align","center");
	//File
	/*var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","fieldtype" + nUploads);
	eInput.setAttribute("id","fieldtype" + nUploads);
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");	
	cell3.appendChild(eInput);*/
	
	//File
	listarray = new Array("TextBox","TextArea","ListBox","RadioButton","CheckBox","FileField");
	var eInput = document.createElement("select"); 
	eInput.setAttribute("name","fieldtype" + nUploads);
	eInput.setAttribute("id","Type");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");
		var doc = eInput.ownerDocument;
		if (!doc)
			doc = eInput.document;
		for(listindex = 0; listindex < 6; listindex++){
			var opt = doc.createElement('OPTION');
			opt.value = listarray[listindex];
			opt.text = listarray[listindex];
			eInput.options.add(opt,listindex);
		}

	//eInput.new Option("TextBox","TextBox");
	cell3.appendChild(eInput);
	
	

	var cell4 = document.createElement("TD");
	//cell2.setAttribute("colspan","2");
	cell4.setAttribute("valign","top");
	cell4.setAttribute("align","center");
	//File
	var eInput = document.createElement("INPUT"); 
	eInput.setAttribute("type","text");
	eInput.setAttribute("name","fieldvalue" + nUploads);
	eInput.setAttribute("id","FieldValue");
	eInput.setAttribute("style", "FONT: 11px Verdana, Arial, Helvetica, sans-seri; text-decoration:none; color: #006699;");	
	cell4.appendChild(eInput);
	

	row.appendChild(cell2); 
	row.appendChild(cell3); 
	row.appendChild(cell4); 
	tbody.appendChild(row);
	document.frm_updateform.NumberOfUploads.value = nUploads;
	return false;
}


//image Gallery
function addimg_validate(){
	if (document.addimage.filename.value == "") 
		{
				alert ("Please Browse the Image name.");
				document.addimage.filename.focus();
				return false;
		}
}

 function showState(passcountry){
		if (document.getElementById(passcountry).value == "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";
			}
		}
	}


//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 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);
}

//script validation for date 
function date_valid(dateissue,dateissue2){
	var stdate=dateissue.split("/");
	var enddate=dateissue2.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;
}


//Move priority & Select Date
function showEventCalendar(){
		if (document.frm_addevent.rdoEventType[0].checked ){
			onetimest = document.getElementById("onetime");
			
			if(onetimest){
				onetimest.style.display="block";
				onetimest.style.visibility="visible";
			}
			multitimest = document.getElementById("multitime");
			if(multitimest){
				multitimest.style.display="none";
				multitimest.style.visibility="hidden";
			}
		}
		if (document.frm_addevent.rdoEventType[1].checked){
			onetimest = document.getElementById("onetime");
			
			if(onetimest){
				onetimest.style.display="none";
				onetimest.style.visibility="hidden";
			}
			multitimest = document.getElementById("multitime");
			if(multitimest){
				multitimest.style.display="block";
				multitimest.style.visibility="visible";
			}
			
		}
		
	}


//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 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 pay_search()
	{
	var payname=document.payform.paystatus.value;
	var dof="member";
		if (payname=="All")
			{
				window.location.href="index.php?do=member&task=view_member";
			}
		else
			{
				window.location.href="index.php?paystatus="+document.payform.paystatus.value+"&do=member&task=view_member";
			}
	}
function category_validate(){
		if(document.frm_procategory.txt_catname.value == "")
		{
		   alert("Please enter the Category name");
		   document.frm_procategory.txt_catname.focus();
		   return false;
		}
}
//Validation for subcategory
function subcategory_validate()
{
		if(document.frm_subcategory.txt_category.value == "")
		{
		   alert("Please choose the Category name");
		   document.frm_subcategory.txt_category.focus();
		   return false;
		}
		if(document.frm_subcategory.txt_subcatname.value == "")
		{
		   alert("Please enter the SubCategory name");
		   document.frm_subcategory.txt_subcatname.focus();
		   return false;
		}
}

//validation of bulk product 
function bulkproduct_validate()
{
		if(document.frm_bulkproduct.productsfile.value == "")
		{
		   alert("Please enter the file name");
		   document.frm_bulkproduct.productsfile.focus();
		   return false;
		}
	return true;
}
//Validation for product
function product_validate()
{
	if(document.frm_product.txt_catname.value == "")
	{
	   alert("Please choose the Category name");
	   document.frm_product.txt_catname.focus();
	   return false;
	}
	if(document.frm_product.txt_subcatname.value == "")
	{
	   alert("Please enter the SubCategory name");
	   document.frm_product.txt_subcatname.focus();
	   return false;
	}
	if(document.frm_product.material.value == "")
	{
	   alert("Please enter the material name");
	   document.frm_product.material.focus();
	   return false;
	}
	if(document.frm_product.txt_proname.value == "")
	{
	   alert("Please Enter the Product name");
	   document.frm_product.txt_proname.focus();
	   return false;
	}
	if(document.frm_product.txt_procode.value == "")
	{
	   alert("Please Enter the Product Code");
	   document.frm_product.txt_procode.focus();
	   return false;
	}
	if(document.frm_product.txt_rprice.value == "")
	{
	   alert("Please Enter the Regular Price");
	   document.frm_product.txt_rprice.focus();
	   return false;
	}
	if(document.frm_product.txt_saleprice.value == "")
	{
	   alert("Please Enter the  Sale Price");
	   document.frm_product.txt_saleprice.focus();
	   return false;
	}
	/*if(document.frm_product.filethumb.value == "")
	{
	   alert("Please browse the Thumb Image");
	   document.frm_product.filethumb.focus();
	   return false;
	}*/
	/*if(document.frm_product.txt_stock.value == "")
	{
	   alert("Please Enter the Product Stock");
	   document.frm_product.txt_stock.focus();
	   return false;
	}
	if(document.frm_product.txt_short.value == "")
	{
	   alert("Please Enter the ShortDescriptions");
	   document.addproduct.txt_short.focus();
	   return false;
	}
	if(document.frm_product.txt_status.value == "")
	{
	   alert("Please Select the Status");
	   document.frm_product.txt_status.focus();
	   return false;
	}*/
	
}

//Validation for Currency
function currency_validate()
{
		if(document.frm_currency.txt_currname.value == "")
		{
		   alert("Please enter the Currency name");
		   document.frm_currency.txt_currname.focus();
		   return false;
		}
		if(document.frm_currency.txtcode.value == "")
		{
		   alert("Please enter the Currency Code");
		   document.frm_currency.txtcode.focus();
		   return false;
		}
		if(document.frm_currency.intvalue.value == "")
		{
		   alert("Please enter the Currency Value");
		   document.frm_currency.intvalue.focus();
		   return false;
		}
}
//Validation for Price 
function price_validate()
{
		if(document.frm_price.start.value == "")
		{
		   alert("Please enter the price start range");
		   document.frm_price.start.focus();
		   return false;
		}
	if(isNaN(document.frm_price.start.value ))
	{
		alert("Must be  numeric value");
		document.frm_price.start.value = "";
		document.frm_price.start.focus();
		return false;
	}
		if(document.frm_price.end.value == "")
		{
		   alert("Please enter the price end range");
		   document.frm_price.end.focus();
		   return false;
		}
	if(isNaN(document.frm_price.end.value ))
	{
		alert("Must be  numeric value");
		document.frm_price.end.value = "";
		document.frm_price.end.focus();
		return false;
	}
}

function cust_validate(){
		if(document.frm_register.txtUser.value == "")
		{
		   alert("Please Enter the User name");
		   document.frm_register.txtUser.focus();
		   return false;
		}
		if(document.frm_register.txtPassword.value == "")
		{
		   alert("Please Enter the Password");
		   document.frm_register.txtPassword.focus();
		   return false;
		}
		if(document.frm_register.txtConfirmPassword.value == "")
		{
		   alert("Please Enter the Confirm Password");
		   document.frm_register.txtConfirmPassword.focus();
		   return false;
		}
		if (!validateEmail(document.frm_register.txtEmail.value,1,1)) 
		{
			document.frm_register.txtEmail.focus();
			return false;
		}
		if(document.frm_register.txtFirst.value == "")
		{
		   alert("Please Enter the First name");
		   document.frm_register.txtFirst.focus();
		   return false;
		}
		if(document.frm_register.txtLast.value == "")
		{
		   alert("Please Enter the Last name");
		   document.frm_register.txtLast.focus();
		   return false;
		}
		if(document.frm_register.txtPostcode1.value == "")
		{
		   alert("Please Enter the PostalAddressLine1");
		   document.frm_register.txtPostcode1.focus();
		   return false;
		}
		if(document.frm_register.txtPostState.value == "")
		{
		   alert("Please choose the state");
		   document.frm_register.txtPostState.focus();
		   return false;
		}
		if(document.frm_register.txtPostCountry.value == "")
		{
		   alert("Please choose the Country");
		   document.frm_register.txtPostCountry.focus();
		   return false;
		}
		if(document.frm_register.txtPostZip.value == "")
		{
		   alert("Please Enter the Zipcode");
		   document.frm_register.txtPostZip.focus();
		   return false;
		}
	if(document.frm_register.txtBusinessph.value == "")
		{
		   alert("Please Enter the Phone");
		   document.frm_register.txtBusinessph.focus();
		   return false;
		}
		phone = document.frm_register.txtBusinessph;
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
			}

}

//Poll Validation
function pollvalidate() {
	var varSubject=document.PostNewPoll.varSubject.value;
	if (varSubject=="" )
	{ 
		alert ("Please enter the Subject");
		document.PostNewPoll.varSubject.focus();
		return false;
	}	
	var varQst=document.PostNewPoll.varQst.value;
	if (varQst=="" )
	{ 
		alert ("Please enter the Poll Question");
		document.PostNewPoll.varQst.focus();
		return false;
	}	
	var varFromDate=document.PostNewPoll.varFromDate.value;
	if (varFromDate=="" )
	{ 
		alert ("Please enter the From Date");
		document.PostNewPoll.varFromDate.focus();
		return false;
	}	
	currentdate= new Date();
	curmonth = currentdate.getMonth() + 1;
	var curdate =  curmonth + "/" + currentdate.getDate() + "/" + currentdate.getFullYear();		
	if (!date_valid(curdate,varFromDate)) 
	{
			alert ("From date can't be less than today");
			//document.PostNewPoll.varFromDate.value == "";
			document.PostNewPoll.varFromDate.focus();
			return false;
	}

	var varToDate=document.PostNewPoll.varToDate.value;
	if (varToDate=="" )
	{ 
		alert ("Please enter the To Date");
		document.PostNewPoll.varToDate.focus();
		return false;
	}
	/*toDate = new Date(varToDate);
	if(!(fromDate.getYear()<=toDate.getYear() && fromDate.getMonth()<=toDate.getMonth() && fromDate.getDate()<=toDate.getDate()))
	{
		alert("To date can't be less than from date");
		return false;
	}*/
		if(document.PostNewPoll.varFromDate.value != "" && document.PostNewPoll.varToDate.value!="")
		if (!date_valid(document.PostNewPoll.varFromDate.value,document.PostNewPoll.varToDate.value)) 
			{
					alert ("Please choose the  To date is greater than From date");
					document.PostNewPoll.varToDate.value == "";
					document.PostNewPoll.varToDate.focus();
					return false;
			}

	return true;
}
//News  Validation


//validation for register validations(admin reg & frontregister page)
function register_validate()
{
	 /*if (document.frm_register.txtUser.value == "")
	 {
		alert("Enter the user name");
		document.frm_register.txtUser.focus();
		return false;
	 }*/
	 var emailid = document.frm_register.txtEmail.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the Email Address");
	 document.frm_register.txtEmail.focus();
	 return false;
	 }	
	 if(!validateEmail(document.frm_register.txtEmail.value,1,1))
	{
	   document.frm_register.txtEmail.focus();
	   return false;
	}
	 if (document.frm_register.txtPassword.value == "")
	 {
		alert("Enter the password");
		document.frm_register.txtPassword.focus();
		return false;
	 }
	 if (document.frm_register.txtConfirmPassword.value == "")
	 {
		alert("Enter the confirm password");
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	  if (document.frm_register.txtPassword.value != document.frm_register.txtConfirmPassword.value)
	 {
		alert("Enter the same password");
		document.frm_register.txtConfirmPassword.value="";
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	if (document.frm_register.txtFirst.value == "")
	 {
		alert("Enter the first name");
		document.frm_register.txtFirst.focus();
		return false;
	 }
	 if (document.frm_register.txtLast.value == "")
	 {
		alert("Enter the last name");
		document.frm_register.txtLast.focus();
		return false;
	 }
	 if(!validateEmail(document.frm_register.txtEmail.value,1,1))
	{
	   document.frm_register.txtEmail.focus();
	   return false;
	}
	/* if (document.frm_register.txtCompany.value == "")
	 {
		alert("Enter the Company name");
		document.frm_register.txtCompany.focus();
		return false;
	 }
	 
	 if (document.frm_register.txtAbout.value == "")
	 {
		alert("Enter the aboutarea");
		document.frm_register.txtAbout.focus();
		return false;
	 }*/
		if(document.frm_register.txtBusinessph.value=="")
			{
			   alert("Enter the Business phone number");
			   document.frm_register.txtBusinessph.focus();
			   return false;
			}
		phone = document.frm_register.txtBusinessph;
		if (checkInternationalPhone(phone.value)==false)
		{
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus();
			return false;
		}
	 
	 if (document.frm_register.txtPostcode1.value == "")
	 {
		alert("Enter the post address ");
		document.frm_register.txtPostcode1.focus();
		return false;
	 }
	
	/*if (document.frm_register.txtPostcode2.value == "")
	 {
		alert("Enter the address line2");
		document.frm_register.txtPostcode2.focus();
		return false;
	 }
	 if (document.frm_register.txtPostCity.value == "")
	 {
		alert("Enter the city");
		document.frm_register.txtPostCity.focus();
		return false;
	 }*/
	
	if(document.frm_register.txtPostCountry.value == "Choose")
		{
		   alert("Select the country");
		   document.frm_register.txtPostCountry.focus();
		   return false;
		}
	 if (document.frm_register.txtPostState.value == "")
	 {
		alert("Enter the Post State");
		document.frm_register.txtPostState.focus();
		return false;
	 }
	 if (document.frm_register.txtPostZip2.value == "")
	 {
		alert("Enter the zipcode");
		document.frm_register.txtPostZip2.focus();
		return false;
	 }
	
	if(!(document.frm_register.chkDelivery.checked))
		{
		    if(document.frm_register.txtDelicode1.value=="")
			{
			   alert("Enter the delivery address line1");
			   document.frm_register.txtDelicode1.focus();
			   return false;
			} 
			if(document.frm_register.txtDelicode2.value=="")
			{
			   alert("Enter the delivery address line2");
			   document.frm_register.txtDelicode2.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCity.value=="")
			{
			   alert("Enter the city");
			   document.frm_register.txtDeliCity.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCountry.value == "Choose")
			{
			   alert("Select the country");
			   document.frm_register.txtDeliCountry.focus();
			   return false;
			}
			if(document.frm_register.txtDeliState.value=="")
			{
			   alert("Enter the state");
			   document.frm_register.txtDeliState.focus();
			   return false;
			}
			if(document.frm_register.txtDeliZip.value=="")
			{
			   alert("Enter the zipcode");
			   document.frm_register.txtDeliZip.focus();
			   return false;
			}
			
		}
		
		/*if(document.frm_register.txtHomeph.value=="")
			{
			   alert("Enter the Home phone number");
			   document.frm_register.txtHomeph.focus();
			   return false;
			}
			if(document.frm_register.txtFax.value=="")
			{
			   alert("Enter the Fax number");
			   document.frm_register.txtFax.focus();
			   return false;
			}*/
}
///Add Product Page RELATIVE PRODUCT TABLE HIDDEN FUNCTION
function call()
{
		if (!(document.frm_product.chk_relative.checked))
		{
			var list = "relativeprotable";
			delistyle=document.getElementById(list);
			if(delistyle)
			{
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}				
		}
}

function showrelativeprotable()
{
		var list = "relativeprotable";
		if (document.frm_product.chk_relative.checked)
		{
			delistyle=document.getElementById(list);
			if(delistyle)
			{
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById(list);
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
		
}/// End of show relative table in Add product page
//function chack all the check boxes in prelative product in add product page
<!-- Begin
var checkflag = "false";
function check(field,groupid,value) 
{
	var checkflag = value;
	len = field.length;
	if (checkflag == "on") 
	{
		if(len==null)
		{
			field.checked=true;
		}
		else
		{
			for (i = 0; i < len; i++) 
			{
				var chkname	=	field[i].name;				
				var suffix  = chkname.substring(chkname.lastIndexOf('_'));
				if(suffix == "_g"+groupid)
					field[i].checked = true;
			}
		}
		checkflag = "off";
		return "off"; 
	}
	else 
	{
		if(len==null)
		{
			field.checked=false;
		}
		else
		{
			for (i = 0; i < len; i++) 
			{
				var chkname	=	field[i].name;
				var suffix = chkname.substring(chkname.lastIndexOf('_'));
				if(suffix == "_g"+groupid)
				field[i].checked = false; 
			}
		}
		checkflag = "on";
		return "on"; 
	}
}
//Forum validation
function forum_validation()
{
	if(document.form_addforum.cat_name.value == "")
	{
		alert("Please Choose the Category Name");
		document.form_addforum.cat_name.focus();
		return false;
	}
	if(document.form_addforum.forumname.value == "")
	{
		alert("Please Enter the Forum Name");
		document.form_addforum.forumname.focus();
		return false;
	}
	if(document.form_addforum.desc.value == "")
	{
		alert("Please Enter the Forum Description");
		document.form_addforum.desc.focus();
		return false;
	}
return true;
}
//Category Validation
function addcategory_validate()
{
	if(document.add_c.cat_name.value == "")
	{
		alert("Please Enter the Category Name");
		document.add_c.cat_name.focus();
		return false;
	}
return true;
}

//  End -->
function help_validate(){
	
	if(document.frm_help.txtfirstname.value == "")
	{
		alert("Please enter the  name");
		document.frm_help.txtfirstname.focus();
		return false;
	}
	
	if(document.frm_help.txtemail.value == "")
	{
		alert("Please enter the email address");
		document.frm_help.txtemail.focus();
		return false;
	}
	 if (!validateEmail(document.frm_help.txtemail.value,1,1)) 
	 {
	 document.frm_help.txtemail.focus();
	 return false;
	 }
	if(document.frm_help.txtcontent.value == "")
	{
		alert("Please enter the Message");
		document.frm_help.txtcontent.focus();
		return false;
	}
}

function fun1()
{
	if (document.login.varEmail.value == "")
	{
		alert("Please enter email id");
		document.login.varEmail.focus();
		return false;
	}
	if(!validateEmail(document.login.varEmail.value,1,1))
	{
	   document.login.varEmail.focus();
	   return false;
	}
	
}