
function validEmailAddress(email)
{
		invalidChars = " /:,;~"
		if (email == "") 
		{
			return (false);
		}
		for (i=0; i<invalidChars.length; i++) 
		{
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) != -1) 
			{
				return (false);
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) 
		{
			return (false);
		}
		if (email.indexOf("@",atPos+1) != -1) 
		{
			return (false);
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) 
		{
			return (false);
		}
		if (periodPos+3 > email.length)	
		{
			return (false);
		}
			
		return (true);
}

function checkproductEmpty(){
	var val = TrimSTR(document.getElementById('ProductName').value) == '';
	if(val){
	alert('Please enter your search keyword.');
	document.getElementById('ProductName').focus();
	return false;
	}
}
function categorycheckEmpty(){
	var val = TrimSTR(document.getElementById('search').value) == '';
	if(val){
	alert('Please enter your search keyword.');
	document.getElementById('search').focus();
	return false;
	}
}
function partnercheckEmpty(){
	var val = TrimSTR(document.getElementById('ProductSearchname').value) == '';
	if(val){
	alert('Please enter your search keyword.');
	document.getElementById('ProductSearchname').focus();
	return false;
	}
}
function productcheckEmpty(){
	var val = TrimSTR(document.getElementById('ProductSearchname').value) == '';
	if(val){
	alert('Please enter your search keyword.');
	document.getElementById('ProductSearchname').focus();
	return false;
	}
}

function checkEmpty(){
	var val = TrimSTR(document.getElementById('ProductEmail').value) == '';
	if(val)
	{
		alert('Please Enter Email Address.');
		document.getElementById('ProductEmail').focus();return false;
	 }

	 else if (!validEmailAddress(document.getElementById('ProductEmail').value)) 
		{
			alert('Please Enter Valid Email Address.');return false;
			document.getElementById('ProductEmail').focus();return false;
		}

	return true;
}

function TrimSTR(strValue) {
	// REMOVE leading spaces.
	while (true) {
		if (strValue.indexOf(" ") == 0) {								// a leading space has been found so...
			strValue = strValue.substring(1, strValue.length)			// slice it off.
		} else {														// the first character in the string is no longer a space so...
			break														// exit the loop.
		}
	}

	// REMOVE trailing spaces.
	if (strValue.length > 0) {	// the string is not null.
		while (true) {
			if (strValue.lastIndexOf(" ") == strValue.length - 1) {			// a trailing space has been found so...
				strValue = strValue.substring(0, strValue.length - 1)	// slice it off.
			} else {													// the last character in the string is no longer a space so...
				break													// exit the loop.
			}
		}
	}

	// ASSIGN return value
	return strValue
}

//------------Function For CheckAll UnCheck All In Subscribe For News Letter

      function do_check()
         {
	   var total = document.getElementById('total').value;
		if(document.getElementById('status').value == '')
		{
			for(i=1;i <= total; i++)
			{
				document.getElementById('check_box_' + i).checked = true;
			}
		document.getElementById('status').value ='checked';
		}
			else if(document.getElementById('status').value=='checked')
		{
			for(i=1;i <= total; i++)
			{
				document.getElementById('check_box_' + i).checked = false;
			}
			document.getElementById('status').value ='';
		}
	}
//------------End Function

//------------Function For Empty CheckBox

	function chkcheckbox(objfrm)
	{
	 len = objfrm.elements.length;
	 var i=0;
	 var flag=false;
	 for( i=0 ; i<len ; i++){
	  if (objfrm.elements[i].type=='checkbox') 
	  { 
	   if(objfrm.elements[i].checked==true)
	   {
	    flag=objfrm.elements[i].checked;
	   }
	  }
	 }
	 return flag;
	}
	function validateForm(objfrm)
	{
		if(!chkcheckbox(objfrm))
		{
			alert('Please select atleast one user');
			return false;
		}
		
	}

function isValidStartEndDates(startDate,endDate)
{ 
	startDate = startDate.split("-");
	endDate   = endDate.split("-");
	var diff = -1;
	if(startDate.length==3 && endDate.length==3)
	{
		 sD = new Date(startDate[0],startDate[1],startDate[2]);  // creates a new Date for the 1st June 2005
		 eD = new Date(endDate[0],endDate[1],endDate[2]); // creates a new Date representing today
		 milli_sD = sD.getTime();
		 milli_eD = eD.getTime();
		 diff = milli_sD - milli_eD;
	}	
	if(diff>0)
		return false;
	else
		return true;
}

 function showusers()
{
    
    document.getElementById("showusers").style.display='block';
}

function hidenotes()
{ 
    document.getElementById("notedetail").style.display='none';
}

function hideusers()
{ 
    document.getElementById("showusers").style.display='none';
}

 function showerrors()
{ 
    
    document.getElementById("showusers").style.display='block';
}

function hideerrors()
{
    document.getElementById("showusers").style.display='none';
}