/*************************************************REUSABLE FUNCTIONS STARTS********************************************************/

/***********HELP : STARTS**************
FUNCTION NAME : Trim -> To trim the values entered in text box(it will call the LTrim and RTrim functions inside automatically.
FUNCTION NAME : CharAndSpace -> This function will allow only character and space not digits(use for city, relation textbox).
FUNCTION NAME : DigitsAndDot -> This function will allow only Digits and Dot not characters(use for price textbox).
FUNCTION NAME : DigitsOnly -> This function will allow only Digits and not characters even dot also.
FUNCTION NAME : telephoneno -> This function will allow only Digits, +, and -(for eg. telephone no: IN +91  2221113456  Call ).
FUNCTION NAME : GetMonthDays -> This function will will return number of days in the current month.
FUNCTION NAME : GetDays -> This function will will returns the diff betn two dates for month 1=jan,12=Dec
FUNCTION NAME : isNumeric,isInteger -> This function will Checks the number is integer or not.
FUNCTION NAME : daysInFebruary -> This function will checks the posted date is valid or not.
FUNCTION NAME : isDate -> This function will Checks the febraury month.
FUNCTION NAME : closewindow -> This function will Close the window.
FUNCTION NAME : checkimage -> This function will checks the entered image is in .jpg,.gif,.jpeg,.png formot or not.
FUNCTION NAME : backToMain -> This function will redirect to specifie file.
FUNCTION NAME : ageValidate -> This function will to checks age the user's age.
FUNCTION NAME : ValidateDateAfter -> This function will to checks the date after some days.
FUNCTION NAME : SameOrAfterDate -> This function will to checks the date or after some days.
FUNCTION NAME : NotFutureDate -> This function will to checks whether the date is future date or not.
FUNCTION NAME : checkEmail -> This function will to checks for valid email-id.
FUNCTION NAME : selectall -> This function will check and uncheck the checkbox.
FUNCTION NAME : atleastone -> This function will Ask conformation before doing ant task like make active, inactive,delete operations.

/***********HELP : ENDS**************/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

window.onLoad="MM_preloadImages('images/home_up.jpg','images/company_up.jpg','images/tech_up.jpg','images/prod_up.jpg','images/partner_up.jpg','images/news_up.jpg','images/forums_up.jpg','images/investor_up.jpg')"


//General funtion to prevent the JS error...
function xerr()
{
     return(true);
}
onerror=xerr; 
  
//  Trim functions...
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While

	return strTemp;
} //End Function

//Function for field name that only allowed Character and Space not Digits...
function CharAndSpace(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChar = "0123456789~`!@#$%^&*()_+|\\=-][{}:';?><,./'";
		var ValidChars = ValidChar+'"';
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) != -1)
			{
				return  false;
			}
		}
		return true;
	}
}

//Function for field name that only allowed Digits and Dot...
function DigitsAndDot(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChars = "0123456789.";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
		return true;
	}
}

//Function for field name that only allowed Digits...
function DigitsOnly(FieldName)
{
	if(FieldName.value != '')
	{
		var ValidChars = "0123456789";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
	}
}

//Function for field name that only allowed Digits, +, and -(for eg. telephone no: IN +91  2221113456  Call )...
function telephoneno(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChars = "0123456789-+  ";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
		return true;
	}
}

/* the function GetMonthDays will return number of days in the current month. */
function GetMonthDays()
{
	DateObj = new Date();
	var CurYear=DateObj.getMonth();
	var FebDays=28;

	if(CurYear%4==1)
	{
		FebDays=29;
	}

	days= new Array(31,FebDays,31,30,31,30,31,31,30,31,30,31);
	return days;
}

//returns the diff betn two dates for month 1=jan,12=Dec
function GetDays(toyear, tomonth, today, fromyear, frommonth, fromday)
{
	DDate= new Date(toyear,tomonth-1,today);
	NDate=	new Date(fromyear,frommonth-1,fromday);
	
	var Days = new String((NDate-DDate)/86400000);   	
	
	return Math.floor(Days);
}

//Check the number is integer or not...
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 IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}

//Check the febraury month...
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    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;
}

//check the posted date is valid or not...
function isDate(dtStr)
{
	var daysInotifymonth = 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 > daysInotifymonth[month]){
		alert("-Please enter a valid day.");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minotifyyear || year>maxYear){
		alert("-Please enter a valid 4 digit year between "+minotifyyear+" 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;
}

//Close the window
function closewindow()
{
	window.close();
}

//Function to check the entered image is in .jpg,.gif,.jpeg,.png formot or not...
function checkimage(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];
                
                if((imageextention != 'jpg') & (imageextention != 'JPG') & (imageextention != 'gif') & (imageextention != 'jpeg') & (imageextention != 'png')) 
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.gif\n.jpeg\n.jpg\n.png.");
			return false;
		}
	}
	return true;
}

//Function to check the entered image is in .jpg,.gif,.jpeg,.png formot or not...
function checkfile(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];
                
                if((imageextention != 'jpg') & (imageextention != 'JPG') & (imageextention != 'gif') & (imageextention != 'jpeg') & (imageextention != 'png') & (imageextention != 'pdf') & (imageextention != 'doc') & (imageextention != 'txt') & (imageextention != 'mp3')) 
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.gif\n.jpeg\n.jpg\n.png\n.pdf\n.doc\n.txt\.mp3.");
			return false;
		}
	}
	return true;
}

//Common function to redirect....
function backToMain(frm)
{
	with(frm)
	{
		document.location	=	module_name.value;
	}
}

//This function is using for to check age the user's age */
function ageValidate()
{		
	var d= new Date();
	var cyear = d.getFullYear();
	
	var chkage = 0;
	
	with(document.complateapp) 
	{
		if(isDate(month.value+"/"+day.value+"/"+year.value))
		{
			chkage = displayage(year.value, month.value, day.value);//cyear - main_age.value; //Age validation
			//alert(chkage);
			//if((year.value != chkage) && ((year.value < (chkage - 1)) || (year.value > (chkage + 1))))
			if(main_age.value != chkage && age_valid_status.value != 1)
			{
				alert("-The Age calculated from the Date of Birth just entered doesn't match that entered when asking for a quotation.");
				age_valid_status.value = 1;
				day.focus();
				return false;
			}
		}
		else
		{
			day.focus();
			return false;
		}
	}
}

//The function ValidateDateAfter() checks the cancellation date.
function ValidateDateAfter(year, month, day, startyear, startmonth, startday)
{
	if( parseInt(year.value) < parseInt(startyear.value))
	{
		//alert(year.value+" "+startyear.value);
		return false;
	}        //        End of if year.
	else if(parseInt(year.value) == parseInt(startyear.value))
	{
		//alert(month.value+" "+startmonth.value);

		if(parseInt(month.value) < parseInt(startmonth.value))
		{
			//alert(month.value+" "+startmonth.value);
			return false;
		}        //        End of if month.
		else if(parseInt(month.value) == parseInt(startmonth.value))
		{
			if(parseInt(day.value) < parseInt(startday.value))
			{
				//alert(day.value+" "+startday.value);
				return false;
			}        //        End of if day.
			else
			{return true;}
		}        //        End of if month.
		else
		{return true;}
	}        //        End of else if month.
	else
	{
		return true;
	}        //        End of else.
}       //        End of function.

//The function SameOrAfterDate() checks the authorization date and notification date.
function SameOrAfterDate(authyear, authmonth, authday, notifyyear, notifymonth, notifyday)
{

	//        Check for authorization date.
	if( parseInt(authyear.value) > parseInt(notifyyear.value))
	{
		//alert("-Date of notification must be a date after the Policy Start Date.");
		return true;
	}        //        End of if year.
	else if(parseInt(authyear.value) == parseInt(notifyyear.value))
	{
		//alert("compare"+month.value+" "+startmonth.value);

		if(parseInt(authmonth.value) > parseInt(notifymonth.value))
		{
			//alert("-Date of notification must be a date after the Policy Start Date.");
			return true;
		}        //        End of if month.
		else if(parseInt(authmonth.value) == parseInt(notifymonth.value))
		{
			if(parseInt(authday.value) >= parseInt(notifyday.value))
			{
				//alert("-Date of notification must be a date after the Policy Start Date.");
				return true;
			}        //        End of if day.
			else
			{return false;}
		}        //        End of if month.
		else
		{return false;}
	}        //        End of else if month.
	else
	{
		return false;
	}        //        End of else.
}       //        End of function.

//The function NotFutureDate(...) checks if the entered date is not a future date.
function NotFutureDate(year, month, day)
{
	// Get Current Date in variables.
	dateobj = new Date();
	yearobj = dateobj.getFullYear();
	monthobj= dateobj.getMonth()+1;
	dayobj  = dateobj.getDate();

	// Compare if entered year is a future year.
	if(year > parseInt(yearobj))
	{
		return false;
	}
	else if(year == parseInt(yearobj)) // if current year.
	{
		// Compare if entered month is a future month.
		if(month > parseInt(monthobj))
		{
			return false;
		}
		else if(month == parseInt(monthobj)) // current month.
		{
			// Compare if entered date is not a future date.
			if(day > parseInt(dayobj))
			{
				return false;
			}
			else { return true; }
		}
		else { return true; }
	}
	else { return true; }
} 

//check email validation
function checkEmail(email)
{        
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid contact E-Mail address! please re-enter.")
		return false;
	}else{
		alert("-Please enter your contact E-Mail address.")
		return false;
	}
}

//Function to open popup...
function openpopup(url,popup_name,height,width,other_properties)
{
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)
	var win_options = 'height='+height+',width='+width+',resizable=no,'
	+ 'scrollbars=1,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options);
}

//Function to check and uncheck the checkbox...
function selectall(ids,frmname)
{					
	var id=ids		
	var fname= frmname			
	var f1=document.fname.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
		
	}
}

//Ask conformation before doing ant task like make active, inactive,delete operations...
function atleastone(frm)
{
	with(frm)
	{
		var count = check.length;	
		var i;
		for(i=0; i<count; i++)
		{
			if(check[i].checked) 
			{ 
				var confirmation = confirm("-Do you want to do this operation.");
				if(confirmation) { return true; } else { return false; }
			} 
		}
		alert('-Please select atleast one.'); 
		return false; 
	}
}	

//AJAX General Function...Check the browser compactibility...
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//check email ids to your friends
function checkEmailsent(email)
{        
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid E-Mail address! Please re-enter.")
		return false;
	}else{
		alert("-Please enter your friend E-Mail address.")
		return false;
	}
}

//check email ids to of admin...
function checkEmailadmin(email)
{        
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid E-Mail address! Please re-enter.");
		return false;
	}else{
		alert("-Please enter E-Mail address.");
		return false;
	}
}

/*************************************************REUSABLE FUNCTIONS ENDS********************************************************/
//This is test file...for AJAX...
function ajaxFunction(str)
{
	//alert(str);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
 	{
  		alert ("-Your browser does not support AJAX!");
  		return;
   } 
	var url="test.php";
	url=url+"?id="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

//This function for show and hide of all details in admin/user_details.php....
function showhideuserdetails(showhideuserdetailsid)
{
	var showhideid = document.getElementById(showhideuserdetailsid);
	var style = showhideid.style.display;

	if (style=='none')
	{
		showhideid.style.display = "block";

	}
	else
	{
		showhideid.style.display = "none";

	}
}

function validatelogin(frm)
{
	with(frm)
	{
		if(Trim(username.value) == '')
		{
			alert("-Please enter username.");
			username.focus();
			return false;
		}
	}
	return true;
}

//Validate admin change password...
function chpassadminValidate(frm)
{
	with(frm)
	{
		if(Trim(opwd.value) == '')
		{
			alert("-Please enter your old password.");
			opwd.focus();
			return false;
		}
		if(Trim(npwd.value) == '')
		{
			alert("-Please enter your new password.");
			npwd.focus();
			return false;
		}
		if(Trim(rpwd.value) == '')
		{
			alert("-Please re-enter your new password.");
			rpwd.focus();
			return false;
		}
		if(Trim(npwd.value) != Trim(rpwd.value))
		{
			alert("-Incorrect new password.");
			rpwd.value='';
			rpwd.focus();
			return false;
		}
	}
	return true;
}

//By clicking on Active, Inactive, Delete button...
function anyone(frm,message)
{
	with(frm)
	{
		var count = check.length;
		var i;
		for(i=0; i < count; i++)
		{
			if(check[i].checked)
			{
				var confirmation = confirm("-Do you want to do this operation.");
				if(confirmation) { return true; } else { return false; }
			}
		}
		alert("-Please select atleast one "+message+".");
		return false;
	}
}

//Array Checkbox validation
function validateArrCheckboxes(frm)
{
    with(frm)
    {
      var i;
      var count = totCheckboxes.value;
      for(i=1; i<=count; i++)
      {
        var check = "check_"+i;
          if(document.getElementById(check).checked)
            {
                var confirmation = confirm("-Do you want to do this operation.");
                if(confirmation) { return true; } else { return false; }
            }
      }
            alert("-Please select atleast one "+message+".");
	    return false;
    }
}

//Select & Deselect array checkboxes
function selDsel(frm,ids)
{
    with(frm)
    {  
        var id=ids;
        var count = document.forms[frm].totCheckboxes.value;
        if(id==1)
          {
              for(i=1;i<=count;i++)
              {
                var check = "check_"+i;
                document.getElementById('check').checked=true;
              }						
          }
        else
          {
              for(i=0;i<=count;i++)
              {
                var check = "check_"+i;
                document.getElementById('check').checked=false;
              }
          }
    }
}

//Function to validate illness in index page...
function validteillness(frm)
{
	with(frm)
	{
		if(illness.value == "0")
		{
			alert("-Please Select a Condition.");
			illness.focus();
			return false;
		}
	}
	return true;
}

//Funtion to validte add edit news...
function validateaddeditnews(frm)
{
	with(frm)
	{
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		/*if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}*/
		if(Trim(newsdate.value) == "")
		{
			alert("-Date feild should not be empty.");
			newsdate.focus();
			return false;
		}
		else 
		{
			var sdate = newsdate.value;
			var spsyear = sdate.substr(0,4);
			var spsmon = sdate.substr(5,2);
			var spsday = sdate.substr(8,2);
			
			if(!NotFutureDate(spsyear,spsmon,spsday))
			{
				alert("-Future date not allowed.");
				return false;
			}
		}
		if(fileUpload.value != '')
		{
			if(!checkfile('addeditnews','fileUpload'))
			{
				return false;
			}
		}
	}
	return true;
}

//Funtion to validate add edit categories...
function validateaddeditcat(frm)
{
	with(frm)
	{
		if(Trim(cat_name.value) == "")
		{
			alert("-Category name should not be empty.")
			cat_name.focus();
			return false;
		}
		if(Trim(cat_desc.value) == "")
		{
			alert("-Description should not be empty.")
			cat_desc.focus();
			return false;
		}
		if(cat_image.value != '')
		{
			if(!checkimage('addeditcat','cat_image'))
			{
				return false;
			}
		}
	}
	return true;
}

//Function to Validate Add/Edit Products
function validateaddeditprod(frm)
{
	with(frm)
	{
		if(Trim(products_name.value) == "")
		{
			alert("-Please enter the name of the product.")
			products_name.focus();
			return false;
		}
		if(Trim(products_model.value) == "")
		{
			alert("-Please enter the model of the product.")
			products_model.focus();
			return false;
		}
		
		if((Trim(products_price.value) == "") || (products_price.value == '0')|| (products_price.value == '00'))
		{
			alert("-Please enter the price for the product.")
			products_price.focus();
			return false;
		}
		
		if(!IsNumeric(products_price.value))
		{
			alert("-Price should be a numeric value.");
			products_price.focus();
			return false;
		}
		
		if(category.value == "")
		{
			alert("-Please select the category to add your product.");
			category.focus();
			return false;
		}
		
		if(products_image.value == "" && prodid.value == "")
		{	
			alert("-Please upload the product image.");
			products_image.focus();
			return false;
		}
		else
		{
				if(!checkimage('addeditprod','products_image'))
				{
					return false;
				}
		}

	}
}

//Funtion to validte add edit press...
function validateaddeditpress(frm)
{
	with(frm)
	{
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		/*if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}*/
		if(Trim(newsdate.value) == "")
		{
			alert("-Date feild should not be empty.");
			newsdate.focus();
			return false;
		}
		else
		{
			var sdate = newsdate.value;
			var spsyear = sdate.substr(0,4);
			var spsmon = sdate.substr(5,2);
			var spsday = sdate.substr(8,2);
			
			if(!NotFutureDate(spsyear,spsmon,spsday))
			{
				alert("-Future date not allowed.");
				return false;
			}
		}
		if(fileUpload.value != '')
		{
			if(!checkimage('addeditpress','fileUpload'))
			{
				return false;
			}
		}
	}
	return true;
}

//Funtion to validte add edit newsletter...
function validateaddeditnewsletter(frm)
{
	with(frm)
	{
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		/*if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}*/
	}
	return true;
}

//Funtion to validte add edit video...
function validateaddeditvideo(frm)
{
	with(frm)
	{
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}
	}
	return true;
}

//Funtion to validte add edit new development...
function validateaddeditnewdevelopment(frm)
{
	with(frm)
	{ 
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}
		if(Trim(newsdate.value) == "")
		{
			alert("-Date feild should not be empty.");
			return false;
		}
		else
		{
			var sdate = newsdate.value;
			var spsyear = sdate.substr(0,4);
			var spsmon = sdate.substr(5,2);
			var spsday = sdate.substr(8,2);
			
			if(!NotFutureDate(spsyear,spsmon,spsday))
			{
				alert("-Future date not allowed.");
				return false;
			}
		}
		if(fileUpload.value != "")
		{
			if(!checkimage('frmnewdev','fileUpload'))
			{
				return false;
			}
		}
	}
	return true;
}

//function to validate the future date for user management...
function validateuserdate()
{
	var frm = document.viewusers;
	if(frm.startDate.value != "")
	{
		var sdate = frm.startDate.value;
		var spsyear = sdate.substr(0,4);
		var spsmon = sdate.substr(5,2);
		var spsday = sdate.substr(8,2);
		
		if(!NotFutureDate(spsyear,spsmon,spsday))
		{
			alert("-Future date not allowed.");
			return false;
		}
	}
	if(frm.endDate.value != "")
	{
		var sdate = frm.endDate.value;
		var spsyear = sdate.substr(0,4);
		var spsmon = sdate.substr(5,2);
		var spsday = sdate.substr(8,2);
		
		if(!NotFutureDate(spsyear,spsmon,spsday))
		{
			alert("-Future date not allowed.");
			return false;
		}
	}
}

//Funtion to validte add news release...
function validateaddeditnewsrelease(frm)
{
	with(frm)
	{
		if(Trim(title.value) == "")
		{
			alert("-Title should not be empty.");
			title.focus();
			return false;
		}
		/*if(Trim(desc.value) == "")
		{
			alert("-Description should not be empty.");
			desc.focus();
			return false;
		}*/
		if(Trim(newsdate.value) == "")
		{
			alert("-Date feild should not be empty.");
			newsdate.focus();
			return false;
		}
		else
		{
			var sdate = newsdate.value;
			var spsyear = sdate.substr(0,4);
			var spsmon = sdate.substr(5,2);
			var spsday = sdate.substr(8,2);
			
			if(!NotFutureDate(spsyear,spsmon,spsday))
			{
				alert("-Future date not allowed.");
				return false;
			}
		}
		if(fileUpload.value != '')
		{
			if(!checkimage('addeditnewrel','fileUpload'))
			{
				return false;
			}
		}
	}
	return true;
}

//Funtion to validte add edit illness...
function validateaddeditillness(frm)
{
	with(frm)
	{
		if(Trim(name.value) == "")
		{
			alert("-Name should not be empty.");
			name.focus();
			return false;
		}
		/* if(Trim(overview.value) == "")
		{
			alert("-Overview should not be empty.");
			overview.focus();
			return false;
		}
		if(Trim(treatment.value) == "")
		{
			alert("-Treatment should not be empty.");
			treatment.focus();
			return false;
		} */
	}
	return true;
}

//Funtion to validte add edit illness FAQ...
function validateaddeditillnessfaq(frm)
{
	with(frm)
	{
		/*if(Trim(question.value) == "")
		{
			alert("-Question should not be empty.");
			question.focus();
			return false;
		}
		if(Trim(answer.value) == "")
		{
			alert("-Answer should not be empty.");
			answer.focus();
			return false;
		}*/
	}
	return true;
}

//To select all colums in news management...
function SelectAllInNews(ids)
{					
	var id=ids;				
	var f1=document.viewnews.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in users management...
function SelectAllInUsers(ids)
{					
	var id=ids;				
	var f1=document.users.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in newsletter management...
function SelectAllInNewsLetter(ids)
{					
	var id=ids;				
	var f1=document.viewnewsletter.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in video management...
function SelectAllInVideo(ids)
{					
	var id=ids;				
	var f1=document.viewuploadvideos.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in press release management...
function SelectPressRelease(ids)
{					
	var id=ids;				
	var f1=document.viewpressrelease.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in news management...
function SelectAllInNewDevelopment(ids)
{					
	var id=ids;				
	var f1=document.viewnewdev.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in news management...
function SelectAllInIllness(ids)
{					
	var id=ids;				
	var f1=document.frmillness.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in illness FAQ management...
function SelectAllInIllnessFaq(ids)
{					
	var id=ids;				
	var f1=document.viewillnessfaq.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in CMS management...
function selectallforcms(ids)
{					
	var id=ids;				
	var f1=document.frmcms.check;	
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}						
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//Form Fields Validation 
function validateForm(frm)
{
	with(frm)
	{
		if(Trim(firstName.value) == "")
		{
			alert("-Please enter your first name.");
			firstName.focus();
			return false;
		}
		else if(!isAlpha(firstName.value))
		{
			alert("-Your first name should contain only alphabetics");
			firstName.focus();
			return false;
		}
		
		if(Trim(lastName.value) == "")
		{
			alert("-Please enter your last name.");
			lastName.focus();
			return false;
		}
		else if(!isAlpha(lastName.value))
		{
			alert("-Your last name should contain only alphabetics.");
			lastName.focus();
			return false;
		}
		
		if(Trim(subject.value) == "")
		{
			alert("-Please enter the subject.");
			subject.focus();
			return false;
		}
		
		if(Trim(address1.value) == "")
		{
			alert("-Please enter your contact address.");
			address1.focus();
			return false;
		}
		
		if(Trim(city.value) == "")
		{
			alert("-Please enter the city name.");
			city.focus();
			return false;
		}
		else if(!isAlpha(city.value))
		{
			alert("-City name should contain only alphabetics.");
			city.focus();
			return false;
		}
		
		if(Trim(state.value) == "")
		{
			alert("-Please enter the state/provinance name.");
			state.focus();
			return false;
		}
		else if(!isAlpha(state.value))
		{
			alert("-state name should contain only alphabetics.");
			state.focus();
			return false;
		}
		
		if(Trim(zipcode.value) == "")
		{
			alert("-Please enter zipcode.");
			zipcode.focus();
			return false;
		}
		else if(!IsNumeric(zipcode.value))
		{
			alert("-Zipcode should be only numeric.");
			zipcode.focus();
			return false;
		}
		
		if(Trim(contry.value) == "")
		{
			alert("-Please enter the state/provinance name.");
			contry.focus();
			return false;
		}
		
		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}
                
        if((Trim(phone.value) != "") && (phone.value.length < 6))
		{
			alert("-Phone number should be minimum 6 digits");
			phone.focus();
			return false;
		}
		
		if(Trim(fax.value) != "")
		{
			if(!IsNumeric(fax.value))
			{
				alert("-Fax number should be only numeric.");
				fax.focus();
				return false;
			}
		}
			
		if(email.value == "")
		{
			alert("-Please enter your email id.");
			email.focus();
			return false;
		}
		
		if(email.value != "")
		{
			return checkemail(email.value);
		}
		
		
		if(Trim(emailid.value) == "")
		{
			alert("-Please enter your email id.");
			emailid.focus();
			return false;
		}
		
		if(Trim(emailid.value) != "")
		{
			checkemail(emailid.value);
		}
		
		
		if(Trim(password.value) == "")
		{
			alert("-Please enter your password.");
			password.focus();
			return false;
		}
		
		if(Trim(message.value) == "")
		{
			alert("-Please enter your comments/questions.");
			message.focus();
			return false;
		}		
	}
}

//Function to validate admin/send mail to customers...
function validatesendmail(frm)
{
	with(frm)
	{
		if(Trim(subject.value) == '')
		{
			alert("-Please enter subject.");
			subject.focus();
			return false;
		}
		if(Trim(message.value) == '')
		{
			alert("-Please enter message.");
			message.focus();
			return false;
		}
	}
}

//function to validate send_promote.php
function frmsendpromote(frm)
{
	with(frm)
	{
		if(Trim(subject.value) == '')
		{
			alert('-Subject should not be blank.');
			subject.focus();
			return false;
		}
		if(Trim(body.value) == '')
		{
			alert('-Message should not be blank.');
			body.focus();
			return false;
		}
		if(Trim(firstname.value)=="" && Trim(secondname.value)=="" && Trim(thirdname.value)=="" && Trim(fourthname.value)=="")  
		{
		  alert("-Enter name.");
		  firstname.focus();
		  return false; 
		}
		if(Trim(firstname.value)!= "")
		{
			if(!checkEmailsent(firstemail.value))
			{
				firstemail.focus();
				return false;
			}
		}
		
		if(Trim(secondname.value) != "")
		{
			if(!checkEmailsent(secondemail.value))
			{
				secondemail.focus();
				return false;
			}
		}
		
		if(Trim(thirdname.value)!= '')
		{
			if(!checkEmailsent(thirdemail.value))
			{
				thirdemail.focus();
				return false;
			}
		}
			
		if(Trim(fourthname.value)!= '')
		{
			if(!checkEmailsent(fourthemail.value))
			{
				fourthemail.focus();
				return false;
			}
		}
		
	}
	return true;
}

//Coding to validate transaction id in admin/view_orders.php
function validatetransid()
{
	var frm = document.orders;
	if(frm.transid.value == '')
	{
		alert("-Please enter transaction id.");
		frm.transid.focus();
		return false;
	}
	return true;
}

//Coding to validate date in admin/view_orders.php
function validatedate()
{
	var frm = document.orders;
	if(frm.StartDate.value == "")
	{
		alert("-Please select start date.");
		return false;
	}
	else
	{ 
		var sdate = frm.StartDate.value;
		var spsyear = sdate.substr(0,4);
		var spsmon = sdate.substr(5,2);
		var spsday = sdate.substr(8,2);
		
		if(!NotFutureDate(spsyear,spsmon,spsday))
		{
			alert("-Future date not allowed.");
			return false;
		}
	}
	if(frm.EndDate.value == "")
	{
		alert("-Please select end date.");
		return false;
	}
	else
	{
		var sdate = frm.EndDate.value;
		var spsyear = sdate.substr(0,4);
		var spsmon = sdate.substr(5,2);
		var spsday = sdate.substr(8,2);
		
		if(!NotFutureDate(spsyear,spsmon,spsday))
		{
			alert("-Future date not allowed.");
			return false;
		}
	}
}

//Function for site general configuration...
function validateconf(frm)
{
	with(frm)
	{
		if(Trim(allemailid.value) != '')
		{
			if(!checkEmailadmin(allemailid.value))
			{
				allemailid.focus();
				return false;
			}
		}
		else { alert("-Please enter email address."); allemailid.focus();	return false; }
		if(Trim(allemailheader.value) == '')
		{
			alert("-Please enter email header.");
			allemailheader.focus();
			return false;
		}
		if(Trim(allsignature.value) == '')
		{
			alert("-Please enter signature.");
			allsignature.focus();
			return false;
		}
		if(Trim(newsemailid.value) != '')
		{
			if(!checkEmailadmin(newsemailid.value))
			{
				newsemailid.focus();
				return false;
			}
		}
		else { alert("-Please enter email address."); newsemailid.focus();	return false; }
		if(Trim(newssignature.value) == '')
		{
			alert("-Please enter signature.");
			newssignature.focus();
			return false;
		}
		if(Trim(supportemailid.value) != '')
		{
			if(!checkEmailadmin(supportemailid.value))
			{
				supportemailid.focus();
				return false;
			}
		}
		else { alert("-Please enter email address."); supportemailid.focus();	return false; }
		if(Trim(supportssignature.value) == '')
		{
			alert("-Please enter signature.");
			supportssignature.focus();
			return false;
		}
	}
	return true;
}

//Function for search engine...
function validatesearchengine(frm)
{
	with(frm)
	{
		if(Trim(page_title.value) == '')
		{
			alert("-Please enter page title.");
			page_title.focus();
			return false;
		}
		if(Trim(page_url.value) == '')
		{
			alert("-Please enter page URL.");
			page_url.focus();
			return false;
		}
		if(Trim(indexed_metawords.value) == '')
		{
			alert("-Please enter search keywords.");
			indexed_metawords.focus();
			return false;
		}
	}
	return true;
}

function sringTrim(str)
{
    if(!str || typeof str != 'string')
        return null;

    //return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' );
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}


//Email Validation 
function checkemail(emailstr)
{
	//var str=document.frm.emailid.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(emailstr))
	{
		return true;
	} else {
	alert("Please input a valid email address!");
		return false;
	}
}

//Validate Loging form
function validateLogin(frm)
{
	with(frm)
	{
		if(Trim(emailid.value) == "")
		{
			alert("-Please enter your email id.");
			emailid.focus();
			return false;
		}
		if(Trim(emailid.value) != "")
		{
			if(!checkemail(emailid.value))
			{
				emailid.focus();
				return false;
			}
		}
		
		if(Trim(password.value) == "")
		{
			alert("-Please enter your password.");
			password.focus();
			return false;
		}
	}
}


//Validate Change Password Form
//Validate Loging form
function validateChangePassword(frm)
{
	with(frm)
	{
		if(Trim(currentPassword.value) == "")
		{
			alert("-Please enter your current password.");
			currentPassword.focus();
			return false;
		}
		
		if(Trim(newPassword.value) == "")
		{
			alert("-Please enter your new password.");
			newPassword.focus();
			return false;
		}
		
		if(Trim(currentPassword.value) == Trim(newPassword.value))
		{
			alert("-Your new password should not be a current passowrd.");
			newPassword.value='';
			newPassword.focus();
			return false;
		}
		
		if(Trim(confirmPassword.value) == "")
		{
			alert("-Please enter your confirm password.");
			confirmPassword.focus();
			return false;
		}
		
		if(Trim(newPassword.value) != Trim(confirmPassword.value))
		{
			alert("-Your confirm password should match with new password.");
			confirmPassword.value='';
			confirmPassword.focus();
			return false;
		}		
	}
}

/*
* Hide & show Marchant Block 
*/
function showhide(val, id)
{
	var hideshowid = document.getElementById(id);
	if(val == "PR" || val == "CH")
	{
		hideshowid.style.display = "inline";
	}
	else
	{
		hideshowid.style.display = "none";
	}
}

function showhidedetails(showhideid)
{
	var val = document.create_account.customers_type.value;
	var showhideid = document.getElementById(showhideid);
	//var style = showhideid.style.display;
	//showhideid.style.display = "none";

	if (val=='Affiliate')
	{
		showhideid.style.display = "block";
	}
	else
	{
		showhideid.style.display = "none";
	}
}

/* Registration Form Validation */
function check_form(frm)
{ 
	with(frm)
	{
		if(customers_type.value == "Affiliate" && Trim(customers_merchant_name.value) == '')
		{
			alert("-Please enter your merchant name.");
			customers_merchant_name.focus();
			return false;
		}
		if(customers_type.value == "Affiliate" && Trim(customers_merchant_name.value) != '')
		{
			if(!isAlpha(customers_merchant_name.value))
			{
				alert("-Merchant name should contain only alphabetics.");
				customers_merchant_name.focus();
				return false;
			}
		}
		if(customers_type.value == "Affiliate" && Trim(customers_merchant_no.value) == '')
		{
			alert("-Please enter your merchant number.");
			customers_merchant_no.focus();
			return false;
		}
		if(customers_type.value == "Affiliate" && Trim(customers_merchant_no.value) != '')
		{
			if(!IsNumeric(customers_merchant_no.value))
			{
				alert("-Merchant number should be only numeric.");
				customers_merchant_no.focus();
				return false;
			}
		}
		
		if(Trim(firstname.value) == '')
		{
			alert("-Please enter your first name.");
			firstname.focus();
			return false;
		}
		
		if(!isAlpha(firstname.value))
		{
			alert("-Your first name should contain only alphabetics.");
			firstname.focus();
			return false;
		}
		
		if(Trim(lastname.value) == '')
		{
			alert("-Please enter your last name.");
			lastname.focus();
			return false;
		}
		
		if(!isAlpha(lastname.value))
		{
			alert("-Your last name should contain only alphabetics.");
			lastname.focus();
			return false;
		}
		
		if(Trim(street_address.value) == '')
		{
			alert("-Please enter your street address.");
			street_address.focus();
			return false;
		}
		
		if(Trim(city.value) == '')
		{
			alert("-Please enter the city name.");
			city.focus();
			return false;
		}
                
		if(!isAlpha(city.value))
		{
			alert("-Your city name should contain only alphabetics.");
			city.focus();
			return false;
		}
                
		if(Trim(state.value) == '')
		{
			alert("-Please enter the state name.");
			state.focus();
			return false;
		}
		
		if(Trim(postcode.value) == '')
		{
			alert("-Please enter the postcode.");
			postcode.focus();
			return false;
		}
		
		if(postcode.value.length <= 4)
		{
			alert("-Minimum length of postcode number should be minimum 5 digits.");
			postcode.focus();
			return false;
		}
		if(!IsNumeric(postcode.value))
		{
			alert("-Postcode should be only numeric.");
			postcode.focus();
			return false;
		}
		
		if(Trim(zone_country_id.value) == '')
		{
			alert("-Please select the contry.");
			zone_country_id.focus();
			return false;
		}
			
		if(Trim(telephone.value) == '')
		{
			alert("-Please enter your contact number.");
			telephone.focus();
			return false;
		}
		
		if(!IsNumeric(telephone.value))
		{
			alert("-Your contact number should be only numeric.");
			telephone.focus();
			return false;
		}
		
		if(telephone.value.length < 5)
		{
			alert("-Minimum length of telephone number should be 5 digits.");
			telephone.focus();
			return false;
		}
		if(Trim(fax.value) != '')
		{
			if(!IsNumeric(fax.value))
			{
				alert("-Fax number should be only numeric.");
				fax.focus();
				return false;
			}
		}
		if(!checkEmailadmin(email_address.value))
		{
			email_address.focus();
			return false;
		}
		
		if(Trim(password.value) == '')
		{
			alert("-Please enter password.");
			password.focus();
			return false;
		}	
		
		if(password.value.length < 5)
		{
			alert("-Password should be atleast 5 characters length.");
			password.focus();
			return false;
		}
		
		if(password.value != confirmation.value)
		{
			alert("-Please enter the correct password.");
			confirmation.value='';
			confirmation.focus();
			return false;
		}
	}
}

/* Edit Address details Form Validation */
function validateEditAddrForm(frm)
{ 
	with(frm)
	{
		if(Trim(firstname.value) == '')
		{
			alert("-Please enter your first name.");
			firstname.focus();
			return false;
		}

		if(!isAlpha(firstname.value))
		{
			alert("-Your first name should contain only alphabetics.");
			firstname.focus();
			return false;
		}
		
		if(Trim(lastname.value) == '')
		{
			alert("-Please enter your last name.");
			lastname.focus();
			return false;
		}
		
		if(!isAlpha(lastname.value))
		{
			alert("-Your last name should contain only alphabetics.");
			lastname.focus();
			return false;
		}
		
		if(Trim(street_address.value) == '')
		{
			alert("-Please enter your street address.");
			street_address.focus();
			return false;
		}
		
		if(Trim(city.value) == '')
		{
			alert("-Please enter the city name.");
			city.focus();
			return false;
		}
                
      if(alphaRegValidate(city.value))
		{
			alert("-City name should contain only alphabetics.");
			city.focus();
			return false;
		}
		
		if(Trim(state.value) == '')
		{
			alert("-Please enter the state name.");
			state.focus();
			return false;
		}
                
		if(alphaRegValidate(state.value))
		{
			alert("-State name should contain only alphabetics.");
			state.focus();
			return false;
		}
                
		if(Trim(postcode.value) == '')
		{
			alert("-Please enter the postcode.");
			postcode.focus();
			return false;
		}
		if(!IsNumeric(postcode.value))
		{
			alert("-Postcode should be only numeric");
			postcode.focus();
			return false;
		}
		
		if(postcode.value.length <= 4)
		{
			alert("-Minimum length of postcode number should be minimum 5 digits.");
			postcode.focus();
			return false;
		}
		
		if(zone_country_id.value == '')
		{
			alert("-Please select the contry.");
			zone_country_id.focus();
			return false;
		}
		
		if(Trim(telephone.value) == '')
		{
			alert("-Please enter your contact number.");
			telephone.focus();
			return false;
		}
		
		if(!IsNumeric(telephone.value))
		{
			alert("-Your contact number should be only numeric");
			telephone.focus();
			return false;
		}
		
		if(telephone.value.length < 5)
		{
			alert("-Minimum length of telephone number should be 5 digits.");
			telephone.focus();
			return false;
		}		
		
		if(!IsNumeric(fax.value))
		{
			alert("-Your fax number should be only numeric.");
			fax.focus();
			return false;
		}
	}
}

var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';


function isValid(parm,val)
{
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}

function isNum(parm) {return isValid(parm,numb);}
function isLower(parm) {return isValid(parm,lwr);}
function isUpper(parm) {return isValid(parm,upr);}
function isAlpha(parm) {return isValid(parm,lwr+upr);}
function isAlphanum(parm) {return isValid(parm,lwr+upr+numb);}

function alphaRegValidate(val) {
  //if (!name.match(/^[a-zA-Z0-9 ]+$/)) //Alpha Numeric Values
  if (!val.match(/^[a-zA-Z ]+$/))
  {
    return true;
  } else { return false; }
}
