//-- GENERAL FUNCTIONS --//
/*change from focus to normal starts here------------bindu on08-05-2009*/ 

function changefocusfields(txt,txtvalue)
{
	if(txt.value==txtvalue)
	{
	txt.value="";
	txt.style.color ='#000000';
	}
}
/*change from focus to normal ends here*/ 

/*change to focus from normal starts here------------bindu on08-05-2009*/ 
function changeonblurfields(txt,val)
{
	if(txt.value=="")
	{
		txt.value=val;
		txt.style.color ='#999999';
	}
}
/*change to focus from normal ends here*/ 

/* value for check box clicked starts here */
function chkfield(chkname,valuefield)
{
	if(document.getElementById(chkname).checked)
		document.getElementById(valuefield).value="1";
	else
		document.getElementById(valuefield).value="0";
}
/* value for check box clicked ends here */

//-- start required function validations --//
function validRequiredField(text,msg,val)
{
	if(val!="")
	{
		if(document.getElementById(text).value==val)
		{
			alert(msg);
			if(text!="hdnselaccrediation")
				document.getElementById(text).focus();
			return false;
		} 
	}
    if(Trim(document.getElementById(text).value)=="")
    {
        alert(msg);
		if(text!="hdnselaccrediation")
			document.getElementById(text).focus();
        return false;
    } 
    else
        return true;
    
}
function validRequiredFieldpassword(text,text1,msg,val)
{
	if(val!="")
	{
		if(document.getElementById(text).value==val)
		{
			alert(msg);
			if(text!="hdnselaccrediation")
				document.getElementById(text1).focus();
			return false;
		} 
	}
    if(Trim(document.getElementById(text).value)=="")
    {
        alert(msg);
		if(text!="hdnselaccrediation")
			document.getElementById(text1).focus();
        return false;
    } 
    else
        return true;
    
}
//-- end required function validations --//
//-- start validating the date format --//
function validateDateFormat(text,msg)
{
	regexp=/^\d{2}[-]?\d{2}[-]?\d{4}$/;
	if(document.getElementById(text).value.search(regexp)==-1)
	{
	    document.getElementById(text).value="";
	    alert(msg);
	    document.getElementById(text).focus();
	    return false;
	}
return true;
}
//-- end validating the date format --//
//-- start min count function validations --//
function validMinCount(text,long,msg) 
{
  if(document.getElementById(text).value!="")
	{
		var maxlength = new Number(long); // Change number to your max length.
		if (document.getElementById(text).value.length < maxlength)
		{		
			alert(msg);		
			document.getElementById(text).focus();
			return false;
		}		
		else
			return true;
	}
	else
			return true;
    
}
//-- end mincount function validations --//

//-- start count function validations --//
function validCount(text,len)
{
    if(text.value.length>len)
    {
        alert(len+' Characters only');
        text.value=text.value.substring(0,len);
    }
}
//-- end count function validations --//
function chkforgotpwd()
{
	if
	(
		validRequiredField('txt_email','Please enter Email')&&
		validEmailAddress('txt_email')	
	)
	{
		document.frmforgotpwd.submit();
	}
	else
		return false;
}
//-- start trim  function validations --//
function LTrim(str) 
{
	for (var i=0; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i++);
	return str.substring(i,str.length);
}
function RTrim(str) 
{
	for (var i=str.length-1; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i--);
	return str.substring(0,i+1);
}
function Trim(str) 
{
	return LTrim(RTrim(str));
}

function passwordcheck(text)
{
	str=document.getElementById(text).value;
	alert(str);
	count=str.length;
	val=0;
	for(i=0;i<count;i++)
	{
		if(str.charAt(i)==" ")
		{
			val++;
		}
	}
	alert(val);
}

function ValidpasswordCharacters(text)
{
	var regexp=/^[A-Za-z0-9-_&*@]*$/;
	if(text.value.search(regexp)==-1)
	{
		text.value = text.value.substring(0,(text.value.length-1));
		alert('Alphabets,Numbers and Special Characters - _ * & @ Only');
		if(text.value.search(regexp)==-1)
		text.value="";
	}
}
//-- end trim  function validations --//

//-- start alphabetsOnly  function validations --//
function validAlphabets(text)
{
	var regexp=/^[A-Za-z]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Alphabets Only');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}
//-- end alphabetsOnly function validations --//

//-- start alphabetsOnly with space  function validations --//
function validAlphabetsWithSpace(text)
{
	var regexp=/^[A-Za-z ]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Alphabets Only');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}
//-- end alphabetsOnly with space function validations --//

//-- start numbersOnly  function validations --//
function validNumbers(text)
{
	if(text.value.length==0)
		return;
if(text.value==0)
{
		alert('Invalid Number');
		text.value='';
		return false;
}    		
	var regexp=/^[0-9]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Numbers Only');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}
//-- end numbersOnly  function validations --//

//-- start numbersOnly  function validations --//
function validNumbersWithSpace(text)
{
	if(text.value.length==0)
		return;
if(text.value==0)
{
		alert('Invalid Number');
		text.value='';
		return false;
}    		
	var regexp=/^[0-9 ]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Numbers Only and Space Only');
			//if(text.value.search(regexp)==-1)
			//text.value="";
		}	
}
//-- end numbersOnly  function validations --//

//-- start alphanumericsOnly  function validations --//
function validAlphaNumerics(text)
{
	var regexp=/^[a-zA-Z0-9 ]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only letters a-z and numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	

}
//-- end alphanumericsOnly  function validations --//

//-- start email address  function validations --//
function validEmailAddress(text)
{ 
	if(Trim(document.getElementById(text).value)!="")
	{ 
		regexp=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
		if(document.getElementById(text).value.search(regexp)==-1)
		{
			document.getElementById(text).value="";
			alert('Please Enter Valid Email');
			document.getElementById(text).focus();
			return false;
		}
		else
			return true;
	}
	else 
		return true;
  
}
//-- end email address  function validations --//

//-- start check space validations --//
function checkspace(text)
{
  var str=text.value;
  var first=str.substring(0,1);
  var second=str.substring(0,1);
  var val='false';
  if(first==' ')
  {
		val='true';
		if(val=='true')
		{
		   if(second==' ')
		   {
			 val='true';
			 //alert('Please Enter Valid Information');
			 text.value = "";
		   }
		}
  }
		 
}
//-- end check space validations --//

//-- text counter validation starts --//
function textCounter3(field,maxlimit) {
	if (field.value.length > maxlimit)
	{// if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	alert("Maximum of "+maxlimit+" characters");
	}
	// otherwise, update 'characters left' counter
}

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
	document.getElementById('remLen3').innerHTML=cntfield.value+"&nbsp;characters left";
}
//-- text counter validation ends --//

//-- text counter validation starts --//
function textCounter2(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
	document.getElementById('remLen5').innerHTML=cntfield.value+"&nbsp;characters left";
}
//-- text counter validation ends --//

//-- start check price validations --//
function PriceNumbersOnly(text)
{
	if(text.value.length==0)
		return;
if(text.value==0)
{
		alert('Invalid Number');
		text.value='';
		return false;
}    		

	var regexp=/^[0-9.]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}

function weightNumbersOnly(text)
{
	var regexp=/^[0-9.]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	
}

function PriceValidation(text,msg)
{
	if(Trim(document.getElementById(text).value)!="")
	{
	  regexp=/^[0-9]{0,5}\.?[0-9]{1,2}$/;
	  if(document.getElementById(text).value.search(regexp)==-1)
	  {
	    document.getElementById(text).value="";
			alert(msg);
		document.getElementById(text).focus();
			return false;
	  }
	  else
		  return true;
	 }
	 else
		 return true;
}
//-- end check price validations --//

//-- start change price to decimal validations --//
function changepricetodecimal(text)
{
	if(text.value=="")
	{
		text.value="";
	}
	else
	{
		if(text.value.length < 5)
		{
		text.value=parseFloat(text.value).toFixed(2);
		}
	}
}
//-- end change price to decimal validations --//

//----------------start date validation checking i.e to date should be greater than from date------sreelakshmi on 07-20-2009//
function checkValidToDate(todate,from_msg,to_msg)
{
	if(document.getElementById(todate).value!="")
	{
		//the formate of the date for this fucntion is DD-MM-YYYY
		var currentTime = new Date();
		var value1=currentTime.format("dd-mm-yyyy");

		//var value1 = document.getElementById(fromdate).value; 	
		var firstIndex1 = value1.indexOf("-"); ;
		var lastIndex1 = value1.lastIndexOf("-"); ;

		date1= value1.substring (0, firstIndex1);
		month1= value1.substring (firstIndex1+1, lastIndex1);
		year1 = value1.substring (lastIndex1+1, value1.length);

		var value2 = document.getElementById(todate).value;
		var firstIndex2 = value1.indexOf("-"); ;
		var lastIndex2 = value1.lastIndexOf("-"); ;

		date2  = value2.substring (0, firstIndex2);
		month2 = value2.substring (firstIndex2+1, lastIndex2);
		year2 = value2.substring (lastIndex2+1, value2.length);
			 
		  if(year2 > year1)//given year greater than current year
		  {
			  return true;
		  }
		  else if(year2 == year1  )//given year equal to current year
		  {
			  if( month2 > month1 )//given Month greater than current Month
			  {return true;}
			  else if(month2 == month1)//given Month equal to current Month
			  {
				 if( date1 < date2 )
						{
						  return true;
						 }
						else
						 {
							alert(to_msg+' must be greater than '+from_msg);
							document.getElementById(todate).value = "";
							return false;
						   }
			  }
			  else
			  {
				  alert(to_msg+' must be greater than '+from_msg);
				  document.getElementById(todate).value = "";
				  return false;
			  }		
		  }		
		  else
		  {
			 alert(to_msg+' must be greater than '+from_msg);
			 document.getElementById(todate).value = "";
			 return false;
		   }	
	}
	else
	{return true;}	   
}

//----------------end date validation checking i.e to date should be greater than from date------------------------//

//-- url validation starts --//
function url_validate(text)
{
	var value=document.getElementById(text).value;
	var urlregex = new RegExp("^(http:\/\/|https:\/\/){1}([0-9A-Za-z]+\.)");
	if(urlregex.test(value))
	{
		return(true);
	}
	return(false);
}
//-- url validation ends --//

//-- start checking file type    bindu,06-01-2010 --//
function chkFileType(text)
{
	var fname=document.getElementById(text).value;
	extCount=0
	if(fname.search(/jpg/)>=1)
		extCount=3;
	if(fname.search(/jpeg/)>=1)
		extCount=4;
	if(fname.search(/gif/)>=1)
		extCount=3;
	if(fname.search(/png/)>=1)
		extCount=3;	
	var ext = fname.substr((fname.length-extCount),extCount);
	ext=ext.toUpperCase();
	//alert(ext);
	if((ext=="JPG") || (ext=="JPEG") || (ext=="GIF") || (ext=="PNG"))
	{
		return true;
	}
	else
	{
		document.getElementById(text).value="";
		alert('Invalid File format, valid file format are JPG or JPEG or GIF or PNG ');
		document.getElementById(text).focus();
		return false;
	}
}
//-- end checking file type --//

//-- check password and confrim password starts --//
function chkconfirmpassword(pwd,confirmpwd,msg)
{
	if(document.getElementById(pwd).value!=document.getElementById(confirmpwd).value)
	{
		alert(msg);
		document.getElementById(pwd).value="";
		document.getElementById(confirmpwd).value="";
		document.getElementById(pwd).focus();
		return false;
	}
	else
		return true;
}
//-- check password and confrim password ends --//
//-- GENERAL FUNCTIONS END --//

//-- validations for create producer starts here --//
function chkcreateproducer()
{
	if(	validRequiredField('txt_name','Please enter Your Name','Name')&&
		validMinCount('txt_name','3','Please enter Minimum 3 characters for Your Name')&&
		validRequiredField('txt_company','Please enter Your Company','Company')&&
		validMinCount('txt_company','3','Please enter Minimum 3 characters for Your Company')&&
		validRequiredField('txt_email','Please enter Your Email','Email')&&
		validEmailAddress('txt_email')&&
		validRequiredField('txt_phone','Please enter Your Phone','Phone')&&
		validMinCount('txt_phone','5','Please enter Minimum 5 characters for Your Phone')&&
		validRequiredField('txt_website','Please enter Your Website','Website')&&
		//url_validate('txt_website')&&
		validRequiredField('txt_address1','Please enter Your Address1','Address1')&&
		validMinCount('txt_address1','3','Please enter Minimum 3 characters for Your Address1')&&
		validRequiredField('txt_town','Please enter Your Town','Town')&&
		validMinCount('txt_town','3','Please enter Minimum 3 characters for Your Town')&&
		validRequiredField('txt_county','Please enter Your County','County')&&
		validMinCount('txt_county','3','Please enter Minimum 3 characters for Your County')&&
		validRequiredField('txt_postcode','Please enter Your Postcode','Postcode')&&
		validMinCount('txt_postcode','5','Please enter Minimum 5 characters for Your Postcode')&&
		validRequiredFieldpassword('txt_pwd1','txt_password','Please enter Your Password','Password')&&
		validMinCount('txt_pwd1','5','Please enter Minimum 5 characters for Your Password')&&
		validRequiredFieldpassword('txt_confirmpassword1','txt_confirmpassword','Please Retype Password','Retype Password')&&
		validMinCount('txt_confirmpassword1','5','Please enter Minimum 5 characters for Retype Password') &&
		checkTwitter() && checkFacebook()
	)
	{
		if(document.getElementById('txt_pwd1').value!=document.getElementById('txt_confirmpassword1').value)
		{
			alert("Password and Retype Password not matched");
			document.getElementById('txt_pwd1').value="";
			document.getElementById('txt_confirmpassword1').value="";
			document.getElementById('txt_confirmpassword').style.display="block";
			document.getElementById('txt_confirmpassword1').style.display="none";
			document.getElementById('txt_pwd1').focus();
			return false;
		}
		else if(document.getElementById('chk_terms').checked==false)
		{
			alert("Please check Terms & Conditions");
			document.getElementById('chk_terms').focus();
			return false;
		}
		else
		{
		if(document.getElementById("txt_email").style.borderColor!="red")
			return true;
		else
		{
			alert("Email existed already, Please try with another Email");
			return false;
		}
		}
	}
	else
	{
		return false;
	}
}
//-- validations for create producer ends here --//
function chkcontact()
{
     if(
		validRequiredField('txtsname','Please Enter Name','Name')&&
		validMinCount('txtsname',3,'Please Enter Minimum 3 Characters For Name')&&
		validRequiredField('txtsemail','Please enter Email','Email')&&
		validEmailAddress('txtsemail')&&
		//validRequiredField('txtsphone','Please enter Phone','Phone')&&
		//validMinCount('txtsphone','10','Please enter Minimum 10 characters for Phone')&&
		validRequiredField('txtsdname','Please enter Message','Message')
	  )
	{
        document.frmcreateusers.action="functions/insert.php5";
		//document.frmcreateusers.submit();
	}
		
	else
	{
		return false;
	}
}
function gotourl(url)
{
	location.href=url;
}
//-- validations for create supporter ends here --//
function validateaddress(text,mess)
{
	var regexp=/^[A-Za-z0-9,&.(/ )\'\-]*$/;
	if(text.value.search(regexp)==-1)
	{
			text.value = text.value.substring(0,(text.value.length-1));
			alert(mess);
			if(text.value.search(regexp)==-1)
			text.value="";
	}	
}
function createsupporter()
{
	if(
		validRequiredField('txtsname','Please enter Your Name','Name')&&
		validMinCount('txtsname','3','Please enter Minimum 3 characters for Your Name')&&
		validRequiredField('txtsemail','Please enter Your Email','Email')&&
		validEmailAddress('txtsemail')&&
		validRequiredField('txtsphone','Please enter Your Phone','Phone')&&
		validMinCount('txtsphone','5','Please enter Minimum 5 characters for Your Phone')&&
		validMinCount('txtsmobile','5','Please enter Minimum 5 characters for Your Mobile')&&
		validRequiredField('txtsaddr1','Please enter Your Address1','Address1')&&
		validMinCount('txtsaddr1','3','Please enter Minimum 3 characters for Your Address1')&&
		validRequiredField('txtstown','Please enter Your Town','Town')&&
		validMinCount('txtstown','3','Please enter Minimum 3 characters for Your Town')&&
		validRequiredField('txtscounty','Please enter Your County','County')&&
		validMinCount('txtscounty','3','Please enter Minimum 3 characters for Your County')&&
		validRequiredField('txtspostcode','Please enter Your Postcode','Postcode')&&
		validMinCount('txtspostcode','5','Please enter Minimum 5 characters for Your Postcode')&&
		validRequiredFieldpassword('txtspwd1','txtspwd','Please enter Your Password','Password')&&
		validMinCount('txtspwd1','5','Please enter Minimum 5 characters for Your Password')&&
		validRequiredFieldpassword('txtsrpwd1','txtsrpwd','Please Retype Password','Retype Password')&&
		validMinCount('txtsrpwd1','5','Please enter Minimum 5 characters for Retype Password') &&
		checkTwitter('s') && checkFacebook('s')
	)
	{
		if(document.getElementById('txtspwd1').value!=document.getElementById('txtsrpwd1').value)
		{
			alert("Password and Retype Password not matched");
			document.getElementById('txtspwd1').value="";
			document.getElementById('txtsrpwd1').value="";
			document.getElementById('txtsrpwd').style.display="block";
			document.getElementById('txtsrpwd1').style.display="none";
			document.getElementById('txtspwd1').focus();
			return false;
		}
		else if(document.getElementById('chkTermss').checked==false)
		{
			alert("Please check Terms & Conditions");
			document.getElementById('chkTermss').focus();
			return false;
		}
		else
		{
		if(document.getElementById('imglogo').value!="")
		{
			var fname=document.getElementById('imglogo').value;
			var ext = fname.substr((fname.length-3),3);
			ext=ext.toUpperCase();
			if((ext!="GIF") && (ext!="JPG") && (ext!="PNG") && (ext!="JPEG"))
			{
				document.getElementById('imglogo').value="";
				alert('Invalid File format, valid image files are .jpg,.gif,.png,.jpeg');
				document.getElementById('imglogo').focus();
				return false;
			}
		}
		}
		
	}
	else
	{
		return false;
	}
}
//-- validations for create supporter ends here --//

//-- to show browse file in Producer My Profiel page starts --//'
function showphotouploadfile()
{
	document.getElementById('div_showphoto').style.display="none";
	document.getElementById('div_changephoto').style.display="block";
}

function showphotofile()
{
	document.getElementById('div_showphoto').style.display="block";
	document.getElementById('div_changephoto').style.display="none";
}
//-- to show browse file in Producer My Profiel page ends --//
//-- to password during supporter create --//
function showpwd1(txt,txt1)
{
	document.getElementById(txt).style.display="none";
	document.getElementById(txt1).style.display="Block";
	document.getElementById(txt1).focus();
	document.getElementById(txt1).style.color="#000000";
   
}
function getpwd(txt,txt1,val)
{	
	if((document.getElementById(txt1).value=="")||(document.getElementById(txt1).value==val))
	{
		document.getElementById(txt1).style.display="none";
		document.getElementById(txt).style.display="Block";
	}
}
//-- to password during supporter create --//
//-- show user types --//
function createshow(rb1,rb2,div1,div2)
{
	document.getElementById(rb1).style.display="none";
	document.getElementById(rb2).style.display="Block";
	document.getElementById(div1).style.display="Block";
	document.getElementById(div2).style.display="none";
}

//-- show user types --//

//-- to check login starts --//
function chklogin()
{
	if(
	validRequiredField('txtuname','Please enter e-mail','e-mail')&&
	validEmailAddress('txtuname')&&
	validRequiredField('txtpwd','Please enter password','password')
	)
	{
		xmlhttpL=GetXmlHttpObject();
		var d=new Date();
		var timestamp=d.getMinutes()+'_'+d.getSeconds()+'_'+d.getMilliseconds();
		var url="userstatuslogin.php5?uid="+document.getElementById('txtuname').value+"&pwd="+document.getElementById('txtpwd').value+"&ts="+timestamp;
		xmlhttpL.open("GET",url,false);
		xmlhttpL.send(null);
		if(xmlhttpL.responseText!="1")
		{
			SimpleModal.open('userstatuslogin.php5?s='+xmlhttpL.responseText+'&t='+timestamp,200,400);
		}
		else
		{
			document.frm_headerlogin.action="chklogin.php5";
			document.frm_headerlogin.submit();
			return true;
		}
	}
	else
	{return false;}
}
//-- to check login ends --//
//-- validations for updateprofile ends here --//
function updateprofile()
{
	if(
		validRequiredField('txtsname','Please enter Name','Name')&&
		validMinCount('txtsname','3','Please enter Minimum 3 characters for Name')&&
		validRequiredField('txtsemail','Please enter Email','Email')&&
		validEmailAddress('txtsemail')&&
		validRequiredField('txtsphone','Please enter Phone','Phone')&&
		validMinCount('txtsphone','5','Please enter Minimum 5 characters for Phone')&&
		validMinCount('txtsmobile','5','Please enter Minimum 5 characters for Mobile')&&
		validRequiredField('txtsaddr1','Please enter Address1','Address1')&&
		validMinCount('txtsaddr1','3','Please enter Minimum 3 characters for Address1')&&
		validRequiredField('txtstown','Please enter Town','Town')&&
		validMinCount('txtstown','3','Please enter Minimum 3 characters for Town')&&
		validRequiredField('txtscounty','Please enter County','County')&&
		validMinCount('txtscounty','3','Please enter Minimum 3 characters for County')&&
		validRequiredField('txtspostcode','Please enter Postcode','Postcode')&&
		validMinCount('txtspostcode','5','Please enter Minimum 5 characters for Postcode'  &&
		checkTwitter() && checkFacebook())
	)
	{
		if(document.getElementById('imglogo').value!="")
		{
			var fname=document.getElementById('imglogo').value;
			var ext = fname.substr((fname.length-3),3);
			ext=ext.toUpperCase();
			if((ext!="GIF") && (ext!="JPG") && (ext!="PNG") && (ext!="JPEG"))
			{
				document.getElementById('imglogo').value="";
				alert('Invalid File format, valid image files are .jpg,.gif,.png,.jpeg');
				document.getElementById('imglogo').focus();
				return false;
			}
			else
			{
				document.frmupdatecust.action="functions/update.php5?cs=1";
				document.frmupdatecust.submit();
			}
		}
		else
			{
				document.frmupdatecust.action="functions/update.php5?cs=1";
				document.frmupdatecust.submit();
			}
		
	}
	else
	{
		return false;
	}
}
//-- validations for updateprofile ends here --//

function updatepassword(val)
{
	if(
		validRequiredField('txtotxt','Please enter Old Password','Password')&&
		validMinCount('txtotxt','5','Please enter Minimum 5 characters for Old Password')&&
		validRequiredField('txtnpwd','Please enter New Password','Retype Password')&&
		validMinCount('txtnpwd','5','Please enter Minimum 5 characters for New Password')&&
		validRequiredField('txtrnpwd','Please Retype New Password','Retype Password')&&
		validMinCount('txtrnpwd','5','Please enter Minimum 5 characters for Retype New Password')&&
		chkconfirmpassword('txtnpwd','txtrnpwd','New Password and Retype New Password not matched')
	)
	{
		if(val==1)
		{
			document.frmupdatecust.action="functions/update.php5?csp=1";
			document.frmupdatecust.submit();
		}
		else if(val==2)
		{
			document.frm_createproducer.action="functions/update.php5?cpp=1";
			document.frm_createproducer.submit();
		}
	}
	else
	{
		return false;
	}
}
function forgotpassword()
{
	if(
		validRequiredField('txtforgotemail','Please enter E-mail ','Email')
	)
	{
		if(document.getElementById('txtforgotemail').value!="")
		{ 
			regexp=/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
			if(document.getElementById('txtforgotemail').value.search(regexp)==-1)
			{
				document.getElementById('txtforgotemail').value="";
				alert('Please Enter Valid E-mail');
				document.getElementById('txtforgotemail').focus();
				return false;
			}
			else
			{
				document.frmforgot.action="functions/update.php5?forgot=1";
				document.frmforgot.submit();
			}
		}
		
	}
	else
	{
		return false;
	}
}
function showsummary(val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,aval1,aval2,aval3,aval4,aval5,aval6,aval7,aval8)
{
	document.getElementById(val1).style.display="block";
	document.getElementById(val2).style.display="none";
	document.getElementById(val3).style.display="none";
	document.getElementById(val4).style.display="none";
	document.getElementById(val5).style.display="none";
	document.getElementById(val6).style.display="none";
	document.getElementById(val7).style.display="none";
	document.getElementById(val8).style.display="none";
	document.getElementById(val9).style.display="none";
	document.getElementById(val10).style.display="none";
	document.getElementById(val11).style.display="none";
	document.getElementById(val12).style.display="none";

	document.getElementById(aval1).style.color="#1E85C4";
	document.getElementById(aval2).style.color="#949494";
	document.getElementById(aval3).style.color="#949494";
	document.getElementById(aval4).style.color="#949494";
	document.getElementById(aval5).style.color="#949494";
	document.getElementById(aval6).style.color="#949494";
	document.getElementById(aval7).style.color="#949494";
	document.getElementById(aval8).style.color="#949494";
	
	if(val1=="divinvolve")
	{
		if(document.getElementById('divinvolve').style.display=="block")
		{
			document.getElementById('divshowinvolve').style.display="block"
			document.getElementById('divviewprofile').style.display="none"
		}
	}
}
function showproducerprofile()
{
	document.getElementById('divshowinvolve').style.display="none";
	document.getElementById('divviewprofile').style.display="block";
}
//--11 to display show summary div starts --//
function showsteps(val)
{
	document.getElementById('step1').style.display = 'none';
	document.getElementById('step2').style.display = 'none';
	document.getElementById('step3').style.display = 'none';
	document.getElementById('step4').style.display = 'none';
	document.getElementById('cls1').className = 'none';
	document.getElementById('cls2').className = 'none';
	document.getElementById('cls3').className = 'none';
	document.getElementById('cls4').className = 'none';
	document.getElementById('cls'+val).className = 'active';
	document.getElementById('step'+val).style.display = 'block';	
}
//--to display show summary div ends --//

var xmlhttp;
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	  {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	  }
	if (window.ActiveXObject)
	  {
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return null;
}
function supportersearch()
{
	//alert(document.getElementById('selsvenue').options[document.getElementById('selsvenue').selectedIndex].text);
	var sname=document.getElementById('txtsshowname').value;
	var pname=document.getElementById('txtsproducername').value;
	var venue=document.getElementById('selsvenue').options[document.getElementById('selsvenue').selectedIndex].text;
	//document.getElementById('selsvenue').value;
	var genre=document.getElementById('selsgenre').value;
	var incentives=document.getElementById('selsincentives').value;
	//var ftarget=document.getElementById('selsftarget').value;
	var ftarget=document.getElementById('selsftarget').options[document.getElementById('selsftarget').selectedIndex].text;

	sname=sname.replace(/&/g, "txtsshowname");
	sname=sname.replace(/#/g, "txtsshowname");

	pname=pname.replace(/&/g, "txtsproducername");
	pname=pname.replace(/#/g, "txtsproducername");

	venue=venue.replace(/&/g, "selsvenue");
	venue=venue.replace(/#/g, "selsvenue");

	genre=genre.replace(/&/g, "selsgenre");
	genre=genre.replace(/#/g, "selsgenre");

	incentives=incentives.replace(/&/g, "selsincentives");
	incentives=incentives.replace(/#/g, "selsincentives");

	ftarget=ftarget.replace(/&/g, "selsftarget");
	ftarget=ftarget.replace(/#/g, "selsftarget");

	var url="search-showsajax.php5?sname="+sname+"&pname="+pname+"&venue="+venue+"&genre="+genre+
		"&incentives="+incentives+"&ftarget="+ftarget;
	//alert(url);
	xmlHttp = GetXmlHttpObject(); 
	if (xmlHttp==null)  
	{
		alert ("Browser does not support HTTP Request");return;  
	}  
	url=url; 
	url=url+"&sid="+Math.random(); 
	xmlHttp.onreadystatechange = supportersearchajaxresponse;  
	xmlHttp.open("GET",url,true) ;  
	xmlHttp.send(null);
}


function supportersearchajaxresponse()
{
	if (xmlHttp.readyState==4)  
	{   
		document.getElementById("divsupportersearchshow").innerHTML = xmlHttp.responseText;  
		document.getElementById("imgajax").style.display='none';		
	}  
	else 
	{
		document.getElementById("imgajax").style.display='block';		
	}
}

function chk()
{
	if (document.getElementById('chknews').checked == true)
	{
		document.getElementById('hdnnewsl').value = "1";
	}
	else
	{
		document.getElementById('hdnnewsl').value = "0";
	}
}

function supportnow()
{
	document.getElementById('divinvest').style.display="none";
	document.getElementById('divsummary').style.display="none";
	document.getElementById('divinvolve').style.display="none";
	document.getElementById('divphoto').style.display="none";
	document.getElementById('divvideo').style.display="none";
	document.getElementById('divupdate').style.display="none";
	document.getElementById('divincentives').style.display="none";
	document.getElementById('divvolunteeringopp').style.display="none";
	document.getElementById('divsupportnow').style.display="block";
	document.getElementById('divvolunteernow').style.display="none";
	document.getElementById('divsendmessage').style.display="none";
	document.getElementById('divchangesupport').style.display="none";
	document.getElementById('ainvest').style.color="#949494";
	document.getElementById('asummary').style.color="#949494";
	document.getElementById('ainvolve').style.color="#949494";
	document.getElementById('aphotos').style.color="#949494";
	document.getElementById('aupdates').style.color="#949494";
	document.getElementById('aincentive').style.color="#949494";
	document.getElementById('avolunteer').style.color="#949494";
	document.getElementById('avideo').style.color="#949494";
}
function changesupport()
{
	document.getElementById('divinvest').style.display="none";
	document.getElementById('divsummary').style.display="none";
	document.getElementById('divinvolve').style.display="none";
	document.getElementById('divphoto').style.display="none";
	document.getElementById('divvideo').style.display="none";
	document.getElementById('divupdate').style.display="none";
	document.getElementById('divincentives').style.display="none";
	document.getElementById('divvolunteeringopp').style.display="none";
	document.getElementById('divsupportnow').style.display="none";
	document.getElementById('divvolunteernow').style.display="none";
	document.getElementById('divsendmessage').style.display="none";
	document.getElementById('divchangesupport').style.display="block";

	document.getElementById('ainvest').style.color="#949494";
	document.getElementById('asummary').style.color="#949494";
	document.getElementById('ainvolve').style.color="#949494";
	document.getElementById('aphotos').style.color="#949494";
	document.getElementById('aupdates').style.color="#949494";
	document.getElementById('aincentive').style.color="#949494";
	document.getElementById('avolunteer').style.color="#949494";
	document.getElementById('avideo').style.color="#949494";
}
function sendmessage()
{
	document.getElementById('divinvest').style.display="none";
	document.getElementById('divsummary').style.display="none";
	document.getElementById('divinvolve').style.display="none";
	document.getElementById('divphoto').style.display="none";
	document.getElementById('divvideo').style.display="none";
	document.getElementById('divupdate').style.display="none";
	document.getElementById('divincentives').style.display="none";
	document.getElementById('divvolunteeringopp').style.display="none";
	document.getElementById('divsupportnow').style.display="none";
	document.getElementById('divvolunteernow').style.display="none";
	document.getElementById('divsendmessage').style.display="block";
	document.getElementById('divchangesupport').style.display="none";

	document.getElementById('ainvest').style.color="#949494";
	document.getElementById('asummary').style.color="#949494";
	document.getElementById('ainvolve').style.color="#949494";
	document.getElementById('aphotos').style.color="#949494";
	document.getElementById('aupdates').style.color="#949494";
	document.getElementById('aincentive').style.color="#949494";
	document.getElementById('avolunteer').style.color="#949494";
	document.getElementById('avideo').style.color="#949494";
}
function volunteernow(val)
{
	document.getElementById('divinvest').style.display="none";
	document.getElementById('divsummary').style.display="none";
	document.getElementById('divinvolve').style.display="none";
	document.getElementById('divphoto').style.display="none";
	document.getElementById('divvideo').style.display="none";
	document.getElementById('divupdate').style.display="none";
	document.getElementById('divincentives').style.display="none";
	document.getElementById('divvolunteeringopp').style.display="none";
	document.getElementById('divsupportnow').style.display="none";
	document.getElementById('divvolunteernow').style.display="block";
	document.getElementById('divsendmessage').style.display="none";
	document.getElementById('divchangesupport').style.display="none";

	document.getElementById('ainvest').style.color="#949494";
	document.getElementById('asummary').style.color="#949494";
	document.getElementById('ainvolve').style.color="#949494";
	document.getElementById('aphotos').style.color="#949494";
	document.getElementById('aupdates').style.color="#949494";
	document.getElementById('aincentive').style.color="#949494";
	if(val=="volunteeringopp")
		document.getElementById('avolunteer').style.color="#1E85C4";
	else
		document.getElementById('avolunteer').style.color="#949494";
	document.getElementById('avideo').style.color="#949494";
}
function qtyupdate(text)
{
	 if(text.value==0)
		{			
	    alert('Please enter valid Information');
		text.value="1";		
		text.focus();
		} 

	if(text.value!="")
	{		
	  regexp=/^[0-9]{1,100}$/;
	  if(text.value.search(regexp)==-1)
	  {
	    text.value="1";		
	    alert('Please enter only numbers 1-9');
		text.focus();
	  } 
	 
	}	

}
function sendvolunteermsg()
{
	if(
		validRequiredField('txtvolunteeremail','Please enter Volunteer Email','Volunteer Email')&&
		validEmailAddress('txtvolunteeremail')&&
		validRequiredField('txtvolunteermsg','Please enter Message','Message')
	)
	{
		document.frmvolunteernow.action="functions/update.php5?vn=1";
		document.frmvolunteernow.submit();
	}
	else
	{
		return false;
	}
}
function sendmsgsupporter()
{
	if(
		validRequiredField('txtsendmsgemail','Please enter From Email','From Email')&&
		validEmailAddress('txtsendmsgemail')&&
		validRequiredField('txtsendmsg','Please enter Message','Message')
	)
	{
		document.frmsendmessage.action="functions/update.php5?sm=1";
		document.frmsendmessage.submit();
	}
	else
	{
		return false;
	}
}
/////---------------for checking the supporter email starts---------------//////////
function chksupporteremail(str)
{
supp=str.value;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="chksupporteremail.php5";
url=url+"?s="+supp;
xmlhttp.onreadystatechange=chksupporteremailchanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function chksupporteremailchanged()
{
	if (xmlhttp.readyState==4)
	{
		supporteremailnoofrows=xmlhttp.responseText;
		
		if(parseInt(supporteremailnoofrows)>0)
		{
			document.getElementById("div_supporteremail").innerHTML="Email existed already, Please try with another Email";
			document.getElementById("txtsemail").style.borderColor="red";
		}
		else
		{
			document.getElementById("div_supporteremail").innerHTML="";
			document.getElementById("txtsemail").style.borderColor="";
		}
	}	
}
function updateproducerprofile()
{
	if( validRequiredField('txt_name','Please enter Name','Name')&&
		validMinCount('txt_name','3','Please enter Minimum 3 characters for Name')&&
		validRequiredField('txt_company','Please enter Company','Company')&&
		validMinCount('txt_company','3','Please enter Minimum 3 characters for Company')&&
		validRequiredField('txt_email','Please enter Email','Email')&&
		validEmailAddress('txt_email')&&
		validRequiredField('txt_phone','Please enter Phone','Phone')&&
		validMinCount('txt_phone','5','Please enter Minimum 5 characters for Phone')&&
		validRequiredField('txt_website','Please enter Website','Website')&&
		//url_validate('txt_website')&&
		validRequiredField('txt_address1','Please enter Address1','Address1')&&
		validMinCount('txt_address1','3','Please enter Minimum 3 characters for Address1')&&
		validRequiredField('txt_town','Please enter Town','Town')&&
		validMinCount('txt_town','3','Please enter Minimum 3 characters for Town')&&
		validRequiredField('txt_county','Please enter County','County')&&
		validMinCount('txt_county','3','Please enter Minimum 3 characters for County')&&
		validRequiredField('txt_postcode','Please enter Postcode','Postcode')&&
		validMinCount('txt_postcode','5','Please enter Minimum 5 characters for Postcode') &&
		checkTwitter() && checkFacebook()
		
		)
		return true;
	else
		return false;
}
/////---------------for checking the supporter email ends---------------//////////
function validAlphaNumericspassword(text)
{
	var regexp=/^[a-zA-Z0-9]*$/;
	if(text.value.search(regexp)==-1)
		{
			text.value = text.value.substring(0,(text.value.length-1));
			alert('Please enter only letters a-z and numbers 0-9');
			if(text.value.search(regexp)==-1)
			text.value="";
		}	

}

// Ramadasu Functions for Twitter and Facebook Functionalities //

function ToggleDiv(id)
{
	ctrl=document.getElementById(id);
	if(ctrl.style.display=='none')
		ctrl.style.display='block';
	else
		ctrl.style.display='none';

}

function checkTwitter(t)
{
	if(t==null)
		t="";
	if(document.getElementById('chk_sendtotwitter'+t).checked)
	{
		if(Trim(document.getElementById('txtTwitterUname'+t).value)=='')
		{
			alert('Please Enter Twitter User Name');
			document.getElementById('txtTwitterUname'+t).focus();
			return false;
		}
		if(Trim(document.getElementById('txtTwitterPWD'+t).value)=='')
		{
			alert('Please Enter Twitter Password'+t);
			document.getElementById('txtTwitterPWD'+t).focus();
			return false;
		}
		return true;
	}
	else
		return true;
}
function checkFacebook(t)
{
	if(t==null)
		t="";
	if(document.getElementById('chk_sendtoFacebook'+t).checked)
	{
		if(Trim(document.getElementById('txtFacebookUname'+t).value)=='')
		{
			alert('Please Enter Facebook User Name');
			document.getElementById('txtFacebookUname'+t).focus();
			return false;
		}
		if(Trim(document.getElementById('txtFacebookPWD'+t).value)=='')
		{
			alert('Please Enter Facebook Password');
			document.getElementById('txtFacebookPWD'+t).focus();
			return false;
		}
		return true;
	}
	else
		return true;
}
function showincentives()
{
	document.getElementById('divinvest').style.display="none";
	document.getElementById('divsummary').style.display="none";
	document.getElementById('divinvolve').style.display="none";
	document.getElementById('divphoto').style.display="none";
	document.getElementById('divvideo').style.display="none";
	document.getElementById('divupdate').style.display="none";
	document.getElementById('divincentives').style.display="block";
	document.getElementById('divvolunteeringopp').style.display="none";
	document.getElementById('divsupportnow').style.display="none";
	document.getElementById('divvolunteernow').style.display="none";
	document.getElementById('divsendmessage').style.display="none";

	document.getElementById('ainvest').style.color="#949494";
	document.getElementById('asummary').style.color="#949494";
	document.getElementById('ainvolve').style.color="#949494";
	document.getElementById('aphotos').style.color="#949494";
	document.getElementById('aupdates').style.color="#949494";
	document.getElementById('aincentive').style.color="#1E85C4";
	document.getElementById('avolunteer').style.color="#949494";
	document.getElementById('avideo').style.color="#949494";
}
function setbuttonimage(id,img)
{
	document.getElementById(id).src=img;
}
