function addLoadEvent(func) 
{  
  var oldonload = window.onload;  
  if (typeof window.onload != 'function')
   {  
	    window.onload = func;  
   } 
	else
	 {  
			window.onload = function() 
			{  
			  if (oldonload)
			   {  
			oldonload();  
			   }  
			  func();  
			}  
	  }  
	} 
	

	
function logout(pwalletID)
{	
 window.location.href='signact.php?id='+pwalletID+'&x=0';	
}	

function doPrint()
{	
window.print();
}

//function slideshow
function popflash(url,name)
{
	
var	newwindow=window.open(url,name,'height=530,width=710,top=0,middle=0,scrollbars=1,resizable=1');
	newwindow.focus();
//	if (window.focus) {newwindow.focus()}
	
}

//e-brochure
function popbroc(url,name)
{
	
var	newwindow=window.open(url,name,'height=435,width=470,top=0,middle=0,scrollbars=1,resizable=0');
	newwindow.focus();
//	if (window.focus) {newwindow.focus()}
	
}

function popside(url,name,ht,wd,scrl,rez)
{


var	newwindow=window.open(url,name,'height='+ht+',width='+wd+',middle=200,middle=500,scrollbars='+scrl+',resizable='+rez);
	newwindow.focus();
//	if (window.focus) {newwindow.focus()}
	
}

function popsideTop(url,name,ht,wd,scrl,rez)
{
var screenW = 320, screenH = 240;
if (parseInt(navigator.appVersion)>3) {
 screenW =(screen.width)/4;
 screenH = (screen.height)/6;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
 screenW =screenW /4;
  screenH = screenH /6;
}


var	newwindow=window.open(url,name,'height='+ht+',width='+wd+',top='+screenH+',left='+screenW+',scrollbars='+scrl+',resizable='+rez);
	newwindow.focus();
//	if (window.focus) {newwindow.focus()}
	
}

function popreg(url,name)
{
	
var	newwindow=window.open(url,name,'height=425,width=555,top=0,middle=0,scrollbars=1,resizable=0');
	newwindow.focus();
//	if (window.focus) {newwindow.focus()}
	
}

function popmap(url,n)
{
var	popup=window.open(url,n,'height=690,width=620,middle=200,middle=200,scrollbars=0,resizable=1');
	//if (window.focus) {newwindow1.focus()}
	popup.focus();
}

function popvideo(url,n)
{
var	popup=window.open(url,n,'height=480,width=580,middle=200,middle=200,scrollbars=0,resizable=0');
	//if (window.focus) {newwindow1.focus()}
	popup.focus();
}

function popflashunder(url) {
var newWindow2 = window.open(url,'PopupName','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=640,height=520');
newWindow2.blur();
//window.focus()
}
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function validate_login(pg,x)
{
	var username=document.getElementById("username").value;
	var password=document.getElementById("pword").value;
	 if((username == "")||
	 (username == "username here"))
	 {
		 alert("Please enter a valid username");
	 }
	  if((password == "")||
	 (password== "password here"))
	 {		
		 alert("Please enter a valid password");
	 }
	 if((username != "")&&
	 (username != "username here")&&
	 (password != "")&&
	 (password!= "password here"))
	 {
 window.location.href='login.php?username='+username+'&password='+password+'&pg='+pg+'&x='+x;	
	 }
}

function validate_login2()
{
	var username=document.getElementById("username").value;
	var password=document.getElementById("pword").value;
	 if((username == "")||
	 (username == "email here"))
	 {
		 alert("Please enter a valid username\(E-mail\)");
	 }
	  if((password == "")||
	 (password== "password here"))
	 {		
		 alert("Please enter a valid pasword");
	 }
	 if((username != "")&&
	 (username != "username here")&&
	 (password != "")&&
	 (password!= "password here"))
	 {
  document.getElementById("signin").style.display="inline";
	document.getElementById("confirm").style.display="none";	
	 }
}

function makeForm(ses) {


var myform=document.createElement("form");

hidden_ses=document.createElement("HIDDEN");
hidden_ses.value=ses;
hidden_ses.name="ses";
myform.appendChild(hidden_ses);
//I need to set the IDs because I want to

// to reference then so I can delete the form later
myform.setAttribute("id","formID");


}

function post_to_url(path, params) {
var    method = method || "post"; // Set method to post by default, if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form);    // Not entirely sure if this is necessary
    form.submit();
}

function doEditAddress(edit_id,ses)
{
	 if(document.getElementById("edit_firstname").value == "")
	{
	    document.getElementById("edit_firstname_x").style.display="inline";
		alert("Please enter a valid firstname");
	}
	
	 	 	
	else 
	{
	var edit_add=document.getElementById("editBook").value; 
	var firstname=document.getElementById("edit_firstname").value;
	
	
 window.location.href='addbook_act.php?edit_id='+edit_id+'&firstname='+firstname+'&ses='+ses+'&tp=edit_addy';
	}
}
function doEditPoll(ses)
{
	var selectEditPoll=document.getElementById("selectEditPoll").value; 
	if(selectEditPoll == "edit_poll")
	{
		alert("Please select a poll to edit");
	}
	else
	{
	 window.location.href='a_polls.php?selectEditPoll='+selectEditPoll+'&ses='+ses+'&px=1';
	}
}
function doEditPoll1(ses)
{
	var selectEdPoll=document.getElementById("selectEdPoll").value; 
	if(selectEdPoll == "ed_poll")
	{
		alert("Please select a poll to edit");
	}
	else
	{
	 window.location.href='a_polls.php?selectEdPoll='+selectEdPoll+'&ses='+ses+'&px=2';
	}
}

function doEditAd(ses)
{
	var selectEditAd=document.getElementById("selectEditAd").value; 
	if(selectEditAd == "edit_ad")
	{
		alert("Please select a file to edit");
	}
	else
	{
	 window.location.href='a_ads.php?selectEditAd='+selectEditAd+'&ses='+ses+'&px=1';
	}
}

function doDeleteAd(ses)
{
	var selectDeleteAd=document.getElementById("selectDeleteAd").value; 
	if(selectDeleteAd == "del_ad")
	{
		alert("Please select a file to delete");
	}
	else
	{
	 window.location.href='a_ads.php?selectDeleteAd='+selectDeleteAd+'&ses='+ses+'&px=2';
	}
}

function doEditPage(ses)
{
	var selectEditPg=document.getElementById("selectEditPg").value; 
	if(selectEditPg == "edit_ap")
	{
		alert("Please select a page name to edit");
	}
	else
	{
	 window.location.href='a_pages.php?selectEditPg='+selectEditPg+'&ses='+ses+'&px=0';
	}
}
function doEditAd1(ses)
{
	var selectEdAd=document.getElementById("selectEdAd").value; 
	if(selectEdAd == "edit_ad")
	{
		alert("Please select a file to edit");
	}
	else
	{
	 window.location.href='a_ads.php?selectEdAd='+selectEdAd+'&ses='+ses+'&px=2';
	}
}
function doEditPollQuest(ses)
{
var selectPollQuest=document.getElementById("selectPollQuest").value; 
//var selectPollQuest=document.getElementById("selectPollQuest").value; 
	if(selectPollQuest == "edit_pollquest")
	{
		alert("Please select a question to edit");
	}
	else
	{
	// window.location.href='a_polls.php?selectPollQuest='+selectPollQuest+'&ses='+ses+'&quest='+quest+'&px=1';
	
	  window.location.href='a_polls.php?selectPollQuest='+selectPollQuest+'&ses='+ses+'&px=1';
	 
	}	
}
function doEditAdName(ses,selectEditAd)
{
var doEditAdName=document.getElementById("doEditAdName").value; 
//var selectPollQuest=document.getElementById("selectPollQuest").value; 
	if(doEditAdName == "edit_adname")
	{
		alert("Please select a file name to edit");
	}
	else
	{
	// window.location.href='a_polls.php?selectPollQuest='+selectPollQuest+'&ses='+ses+'&quest='+quest+'&px=1';
	
	  window.location.href='a_ads.php?selectEditAd='+selectEditAd+'&doEditAdName='+doEditAdName+'&ses='+ses+'&px=1';
	 
	}	
}

function doDelAd()
{
var doDelAdName=document.getElementById("doDelAdName").value; 
//var selectPollQuest=document.getElementById("selectPollQuest").value; 
	if(doDelAdName == "del_adname")
	{
		alert("Please select a file name to delete");
	}
	else
	{	
	 document.getElementById("btn_del_ad_confirm").style.display="none";
	  document.getElementById("btn_del_ad_submit").style.display="inline";	  
	}	
}

function doEditPollQuest1(ses)
{
var selectPollQt=document.getElementById("selectPollQt").value; 
//var selectPollQuest=document.getElementById("selectPollQuest").value; 
	if(selectPollQt == "ed_pollquest")
	{
		alert("Please select a question to edit");
	}
	else
	{
	// window.location.href='a_polls.php?selectPollQuest='+selectPollQuest+'&ses='+ses+'&quest='+quest+'&px=1';
	
	  window.location.href='a_polls.php?selectPollQt='+selectPollQt+'&ses='+ses+'&px=2';
	 
	}	
}

function doUpdatePollQuest(ses,t,edit_pollq,num)
{
var v="";
var quest=document.getElementById("ed_pollq").value;
/*var ses=document.getElementById("selectPollQuest").value; 
var t=document.getElementById("selectPollQuest").value; 
var v=document.getElementById("selectPollQuest").value; 
var edit_pollq=document.getElementById("selectPollQuest").value; */
for(var p=1;p<=num;p++)
{
var n='edit_pollo1_'+p;
var v=v+document.getElementById(n).value+"-";	//alert(v);
}
//alert(quest);
	window.location.href='updatepoll_act.php?edit_pollq='+edit_pollq+'&ses='+ses+'&t='+t+'&v='+v+'&quest='+quest;
}

function doUpdatePollPriority(ses,pollno)
{
//var selectEdPoll=document.getElementById("selectEdPoll").value;
var quest=document.getElementById("selectPollQt").value;

//alert("Question ID : "+quest);
//alert("Poll no : "+pollno);
	window.location.href='updatepoll_act.php?quest='+quest+'&ses='+ses+'&pollno='+pollno+'&p=1';
}

function doUpdateAdPriority(ses)
{
//var selectEdPoll=document.getElementById("selectEdPoll").value;
var ad=document.getElementById("selectAdQt").value;

//alert("ad ID : "+ad);
//alert("Poll no : "+pollno);
	window.location.href='updateads_act.php?ad='+ad+'&ses='+ses+'&p=1';
}
function doEditBook(ses) 
{
	var edit_addy=document.getElementById("editBook").value; 
	if(edit_addy == "edit_book")
	{
		alert("Please select a category");
	}
	else
	{
	 window.location.href='addbook_act.php?edit_id='+edit_addy+'&ses='+ses+'&px=2&tp=get_edit_addy';
	}
}

function doDisableReply(ses) 
{
	var edit_addy=document.getElementById("editBook").value; 
	if(edit_addy == "edit_book")
	{
		alert("Please select a category");
	}
	else
	{
	 window.location.href='delreply_act.php?edit_id='+edit_addy+'&ses='+ses+'&px=2&tp=get_edit_addy';
	}
}

function doDisableTopic(ses) 
{
	var edit_addy=document.getElementById("editBook").value; 
	if(edit_addy == "edit_book")
	{
		alert("Please select a category");
	}
	else
	{
	 window.location.href='deltopic_act.php?edit_id='+edit_addy+'&ses='+ses+'&px=2&tp=get_edit_addy';
	}
}

function doEnableReply(ses) 
{
	var edit_addy=document.getElementById("editBook").value; 
	if(edit_addy == "edit_book")
	{
		alert("Please select a category");
	}
	else
	{
	 window.location.href='enablereply_act.php?edit_id='+edit_addy+'&ses='+ses+'&px=2&tp=get_edit_addy';
	}
}
function doEnableTopic(ses) 
{
	var edit_addy=document.getElementById("editBook").value; 
	if(edit_addy == "edit_book")
	{
		alert("Please select a category");
	}
	else
	{
	 window.location.href='enabletopic_act.php?edit_id='+edit_addy+'&ses='+ses+'&px=2&tp=get_edit_addy';
	}
}


function doDeleteAddress(ses)
{
	var del_addy=document.getElementById("deleteBook").value;
	if(del_addy == "del_book")
	{
		alert("Please select an address");
	}
	else
	{
	 window.location.href='addbook_act.php?del_id='+del_addy+'&ses='+ses+'&tp=del_addy';
	}
}

/* Time in 24 hr format

function showClock()
{
var clock=new Date();
var hours=clock.getHours();
var minutes=clock.getMinutes();
var seconds=clock.getSeconds();
var don="AM";
// for a nice disply we'll add a zero before the numbers between 0 and 9
if (hours>=12){ don="PM"; }
if (hours<10){
hours="0" + hours;
}
if (minutes<10){
minutes="0" + minutes;
}
if (seconds<10){
seconds="0" + seconds;
}
document.getElementById('showClock').innerHTML=hours+":"+minutes+":"+seconds;
t=setTimeout('showClock()',1000);

}*/

function showClock()
{
var now=new Date()
var hrs=now.getHours()
var minutes=now.getMinutes()
var sec=now.getSeconds()
var don="AM"
if (hrs>=12){ don="PM" }
if (hrs>12) { hrs-=12 }
if (hrs==0) { hrs=12 }
if (hrs<10) { hrs="0"+hrs }
if (minutes<10) { minutes="0"+minutes }
if (sec<10) { sec="0"+sec }
document.getElementById('showClock').innerHTML=hrs+":"+minutes+":"+sec+" "+don;
setTimeout("showClock()",1000)
}

//Validations------------------------------------------------------------


function confirmRegData()
{
	var cnt=0;
	document.getElementById("selectMembershipType").style.backgroundColor='#fff';
	document.getElementById("xname").style.backgroundColor='#fff';
	document.getElementById("selectCat").style.backgroundColor='#fff';
	document.getElementById("email").style.backgroundColor='#fff';
	document.getElementById("logpass").style.backgroundColor='#fff';
	
	document.getElementById("selectMembershipType_x").style.display='none';
	document.getElementById("xname_x").style.display='none';
	document.getElementById("selectCat_x").style.display='none';	
	 document.getElementById("email_x").style.display='none';
	 document.getElementById("logpass_x").style.display='none';
	 
	 if(document.getElementById("selectSubCategory") != null)
	 {
	document.getElementById("selectSubCategory").style.backgroundColor='#fff';
	document.getElementById("selectSubCategory_x").style.display='none';
	 }
	 
	  if(document.getElementById("code") != null)
	 {
	document.getElementById("code").style.backgroundColor='#fff';
	document.getElementById("code_x").style.display='none';
	 }
	 
	  if(document.getElementById("PinNumber") != null)
	 {
	document.getElementById("PinNumber").style.backgroundColor='#fff';
	document.getElementById("PinNumber_x").style.display='none';
	//cnt=cnt+1;
	 }
	 if(document.getElementById("xname").value == "")
	 {
	document.getElementById("xname").style.backgroundColor='#4C787E';
	document.getElementById("xname_x").style.display='inline';
	cnt=cnt+1;
	 }	
	
	 if(document.getElementById("selectMembershipType").value == "0")
	 {
		 document.getElementById("selectMembershipType").style.backgroundColor='#4C787E';
		 document.getElementById("selectMembershipType_x").style.display='inline';
		cnt=cnt+1;
	 }
	  if(document.getElementById("selectCat").value == "0")
	 {
		 document.getElementById("selectCat").style.backgroundColor='#4C787E';		
		 document.getElementById("selectCat_x").style.display='inline';
		cnt=cnt+1;
	 }
	 if(document.getElementById("selectSubCategory") != null)
	 { 
		  if(document.getElementById("selectSubCategory").value == "0")
		 {
			document.getElementById("selectSubCategory").style.backgroundColor='#4C787E';			
			document.getElementById("selectSubCategory_x").style.display='inline';
			cnt=cnt+1;
		 }
	 }
	 
	 if(document.getElementById("code") != null)
	 { 
		  if(document.getElementById("code").value == "")
		 {
			document.getElementById("code").style.backgroundColor='#4C787E';			
			document.getElementById("code_x").style.display='inline';
			cnt=cnt+1;
		 }
	 }
	
		 
	  if((document.getElementById("email").value == "")||
	 (validate_email (document.getElementById("email").value) == false))
	 {
		  document.getElementById("email").style.backgroundColor='#4C787E';	
		  document.getElementById("email_x").style.display='inline';
		cnt=cnt+1;
	 }
	 
	  if(document.getElementById("logpass").value == "") 
	 {
	 document.getElementById("logpass").style.backgroundColor='#4C787E';	
	 document.getElementById("logpass_x").style.display='inline';
		cnt=cnt+1;
	 }
	 if ( (document.getElementById("selectPremType").value !="0")&&(document.getElementById("PinNumber").value ==""))
		 { 
				document.getElementById("PinNumber").style.backgroundColor='#4C787E';				
				document.getElementById("PinNumber_x").style.display='inline';
			cnt=cnt+1;
	 }
	 if(cnt!=0)
	 {
	 alert("Please fill in the marked fileds");
	 }
	 else  if(
	 (document.getElementById("selectMembershipType").value != "0")&&
	
	  (document.getElementById("selectCat").value != "0")&&
	 (document.getElementById("selectSubCategory").value != "0")&&
	
	 (document.getElementById("logpass").value != "")&&
	  (document.getElementById("xname").value != "")&&
	
	  (document.getElementById("email").value != "")&&
	 ( validate_email (document.getElementById("email").value) != false )
	/* &&	
	  (document.getElementById("PinNumber").value != "")*/
	  )	
	 { 
	 document.getElementById("selectMembershipType").style.backgroundColor='#fff';
	 document.getElementById("xname").style.backgroundColor='#fff';
	document.getElementById("selectCat").style.backgroundColor='#fff';
	document.getElementById("selectSubCategory").style.backgroundColor='#fff';
    document.getElementById("email").style.backgroundColor='#fff';
	document.getElementById("logpass").style.backgroundColor='#fff';
	 if(document.getElementById("PinNumber") != null)
	 {
	document.getElementById("PinNumber").style.backgroundColor='#fff'; 
	 }
	  if(document.getElementById("code") != null)
	 {
	document.getElementById("code").style.backgroundColor='#fff';
	 }
	
	document.getElementById("selectMembershipType_x").style.display='none';
	document.getElementById("xname_x").style.display='none';
	document.getElementById("selectCat_x").style.display='none';
	document.getElementById("selectSubCategory_x").style.display='none';
	 document.getElementById("email_x").style.display='none';
	 document.getElementById("logpass_x").style.display='none';
	  if(document.getElementById("PinNumber_x") != null)
	 {
	document.getElementById("PinNumber_x").style.display='none';
	 }
	  if(document.getElementById("code_x") != null)
	 {
	document.getElementById("code_x").style.display='none';
	 }
	
	document.getElementById("selectMembershipType_g").style.display='inline';
	document.getElementById("xname_g").style.display='inline';
	document.getElementById("selectCat_g").style.display='inline';
	 if(document.getElementById("selectSubCategory_g") != null)
	 {
	document.getElementById("selectSubCategory_g").style.display='inline';
	}
	 document.getElementById("email_g").style.display='inline';
	 document.getElementById("logpass_g").style.display='inline';
	  if(document.getElementById("PinNumber_g") != null)
	 {
	document.getElementById("PinNumber_g").style.display='inline';
	 }
	  if(document.getElementById("code_g") != null)
	 {
	document.getElementById("code_g").style.display='inline';
	 }
	document.getElementById("regConfirm").style.display="none";
	document.getElementById("regSContinue").style.display="inline";
	 }
}

function confirmProfileCategoryData()
{
	var cnt=0;
	
	document.getElementById("selectCat").style.backgroundColor='#fff';
	document.getElementById("selectCat_x").style.display='none';
	 
	 if(document.getElementById("selectSubCategory") != null)
	 {
	document.getElementById("selectSubCategory").style.backgroundColor='#fff';
	document.getElementById("selectSubCategory_x").style.display='none';
	 }
	 
	  if(document.getElementById("code") != null)
	 {
	document.getElementById("code").style.backgroundColor='#fff';
	document.getElementById("code_x").style.display='none';
	 }
	  if(document.getElementById("selectCat").value == "0")
	 {
		 document.getElementById("selectCat").style.backgroundColor='#4C787E';		
		 document.getElementById("selectCat_x").style.display='inline';
		cnt=cnt+1;
	 }
	 if(document.getElementById("selectSubCategory") != null)
	 { 
		  if(document.getElementById("selectSubCategory").value == "0")
		 {
			document.getElementById("selectSubCategory").style.backgroundColor='#4C787E';			
			document.getElementById("selectSubCategory_x").style.display='inline';
			cnt=cnt+1;
		 }
	 }
	 
	 if(document.getElementById("code") != null)
	 { 
		  if(document.getElementById("code").value == "")
		 {
			document.getElementById("code").style.backgroundColor='#4C787E';			
			document.getElementById("code_x").style.display='inline';
			cnt=cnt+1;
		 }
	 }		 
	
	 if(cnt!=0)
	 {
	 alert("Please fill in the marked fileds");
	 }
	 else  if(
	 (document.getElementById("selectCat").value != "0")&&
	 (document.getElementById("selectSubCategory").value != "0"))	
	 { 
	document.getElementById("selectCat").style.backgroundColor='#fff';
	document.getElementById("selectSubCategory").style.backgroundColor='#fff';
	document.getElementById("code").style.backgroundColor='#fff';
	
	document.getElementById("selectCat_x").style.display='none';
	document.getElementById("selectSubCategory_x").style.display='none';
	document.getElementById("code_x").style.display='none';	
	
	document.getElementById("selectCat_g").style.display='inline';
	document.getElementById("selectSubCategory_g").style.display='inline';
	document.getElementById("code_g").style.display='inline';
	document.getElementById("regConfirm").style.display="none";
	document.getElementById("regSContinue").style.display="inline";
	 }
}

function confirmRetrieveEmail()
{
	var cnt=0;	
	document.getElementById("email").style.backgroundColor='#fff';
	
	  if((document.getElementById("email").value == "")||
	 (validate_email (document.getElementById("email").value) == false))
	 {
		  document.getElementById("email").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }	 
	 
	 if(cnt!=0)
	 {
	 alert("Please confirm the format of the E-mail address");
	 }
	 else  if((document.getElementById("email").value != "")&&
	 ( validate_email (document.getElementById("email").value) != false ) )	
	 { 	
	document.getElementById("retConfirm").style.display="none";
	document.getElementById("retSubmit").style.display="inline";
	 }
}

function checkNewPassword()
{
 var email=document.getElementById("email").value;
 var pass=document.getElementById("pass").value;
  var code=document.getElementById("code").value;
 var cnt=0;	
	document.getElementById("email").style.backgroundColor='#fff';
	document.getElementById("code").style.backgroundColor='#fff';
	  if((email == "")||
	 (validate_email (email) == false))
	 {
		document.getElementById("email").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }	
	 if(document.getElementById("code").value == "")
	 {
		document.getElementById("code").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }	 
	 
	  /*if(document.getElementById("pass").value == "")
	 {
		document.getElementById("pass").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }	*/
	 if(cnt!=0)
	 {
	 alert("Please confirm the format of your E-mail address");
	 }
	 else  if((email != "")&&
	 (validate_email (email) != false )&&
	 (code != "")  )	
	 { 	
	window.location.href='signact.php?email='+email+'&pass='+pass+'&code='+code;
	 }  

}

function checkNewPasswordTop()
{
 var email=document.getElementById("tp_username").value;
 var pass=document.getElementById("tp_pword").value; 
 var cnt=0;	
	//document.getElementById("email").style.backgroundColor='#fff';
	//document.getElementById("code").style.backgroundColor='#fff';
	  if((email == "")||
	  (email == "Enter E-mail")||
	 (validate_email (email) == false) )
	 {
		document.getElementById("tp_username").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }
	  /*if(document.getElementById("pass").value == "")
	 {
		document.getElementById("pass").style.backgroundColor='#4C787E';	
		cnt=cnt+1;
	 }	*/
	 if(cnt!=0)
	 {
	 alert("Please confirm the format of your E-mail address");
	 }
	 else  if((email != "")&&
	  (email != "Enter E-mail")&&
	 ( validate_email (email) != false))	
	 { 	
	window.location.href='signacttop.php?email='+email+'&pass='+pass;
	 }
}

function clearColor(col){
    /*if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;*/
	document.getElementById(col).style.backgroundColor='#fff'; 
	
	document.getElementById("regConfirm").style.display="inline";
	document.getElementById("regSContinue").style.display="none";
	
	document.getElementById("selectMembershipType_g").style.display='none';
	document.getElementById("xname_g").style.display='none';
	document.getElementById("selectCat_g").style.display='none';
	if(document.getElementById("selectSubCategory_g") != null)
	 {
	document.getElementById("selectSubCategory_g").style.display='none';
	 }
	 document.getElementById("email_g").style.display='none';
	 document.getElementById("logpass_g").style.display='none';
	 if(document.getElementById("PinNumber_g") != null)
	 {
	document.getElementById("PinNumber_g").style.display='none';
	 }
	 if(document.getElementById("code_g") != null)
	 {
	 document.getElementById("code_g").style.display='none';
	 }
}

function clearProfileCategoryColor(col){
	document.getElementById(col).style.backgroundColor='#fff'; 
	
	document.getElementById("regConfirm").style.display="inline";
	document.getElementById("regSContinue").style.display="none";
	
	document.getElementById("selectCat_g").style.display='none';
	if(document.getElementById("selectSubCategory_g") != null)
	 {
	document.getElementById("selectSubCategory_g").style.display='none';
	 }	 
	 if(document.getElementById("code_g") != null)
	 {
	 document.getElementById("code_g").style.display='none';
	 }
}

function CheckTerms()
{
if  (document.getElementById("selectRegCheck").checked)
{ //alert("Me");
document.getElementById("regConfirm").disabled=false;
document.getElementById("regSContinue").disabled=false;	

document.getElementById("ln1").style.display='inline';
}
else
{
	//alert("You");
document.getElementById("regConfirm").disabled=true;
document.getElementById("regSContinue").disabled=true;	

document.getElementById("ln1").style.display='none';
}
}

function conf()
{
document.getElementById("regConfirm").disabled=true;
document.getElementById("regSContinue").disabled=true;	
}
function deconf()
{
document.getElementById("regConfirm").disabled=false;
document.getElementById("regSContinue").disabled=false;	
}

function changeCat(tp)
{
if(tp=="LGA")
{
document.getElementById("cat_select").style.display='none';
document.getElementById("lga_select").style.display='inline';	
}
else
if(tp=="Category")
{
document.getElementById("cat_select").style.display='inline';
document.getElementById("lga_select").style.display='none';	
}
else
if(tp=="ALL")
{
document.getElementById("cat_select").style.display='none';
document.getElementById("lga_select").style.display='none';	
}
}

function checkDoSearch()
{
var criteria="";
var searchtype="";

var rad=document.forms["fm"].elements["rgSelectOption"];
for (var i = 0; i < rad.length; i++) {
if (rad[i].checked==true) {
searchtype = rad[i].value;
}
}
var kword=document.getElementById("kword_tf").value;
if(searchtype=="Category")
{
var criteria=document.getElementById("cat_select").value;
}
else if(searchtype=="LGA")
{
var criteria=document.getElementById("lga_select").value;
}
//alert("Cat : "+cat);
//alert("Radio : "+searchtype);
//alert("kword : "+kword);
//alert("criteria : "+criteria);
window.location.href='search.php?kword='+kword+'&criteria='+criteria+'&searchtype='+searchtype;
}

function goToPrev(){ 
   window.location.href='profilesindex.php';
   } 
   
 function xmen(to,p) {
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = to ;
  for (var k in p) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}


function validate_fields()
{
	var cnt=0;
	 if((document.getElementById("fname").value == ""))
	 {
		// document.getElementById("firstname_x").style.display="inline";
		cnt=cnt +1;
		// alert("Please enter a valid firstname");
	 }
	  if((document.getElementById("lname").value == ""))
	 {
		// document.getElementById("lastname_x").style.display="inline";
		cnt=cnt +1;
		// alert("Please enter a valid lastname");
	 }
	  if((document.getElementById("pword").value == ""))
	 {
		// document.getElementById("pword_x").style.display="inline";
		cnt=cnt +1;
		// alert("Please enter a valid password");
	 }
	  if((document.getElementById("email").value == "")||
	 (validate_email (document.getElementById("email").value) == false))
	 {
		 // document.getElementById("email_x").style.display="inline";
		 cnt=cnt +1;
		// alert("Please enter a valid email address, e.g. info@quicktori.com");
	 }
	  if((document.getElementById("pnumber").value == "")||
	 (validate_mobile(document.getElementById("pnumber").value)==false))
	 {
		// document.getElementById("pnumber_x").style.display="inline";
		cnt=cnt +1;
		// alert("Please enter a valid phone number, e.g. 08090000000");
	 }
	 
	 if(cnt!=0)
	 {
		 alert("Please make sure all the fields have been completed below"); 
	 }
	 
	 else  if((cnt==0)&& (document.getElementById("selectRegCheck").checked)) 
	
	 {
	document.getElementById("register").style.display="inline";
	document.getElementById("confirm").style.display="none";
	 }
}
   
   
function validate_mobile(inp)
{
var pattern = /^\d{11}$/;	
if (inp.search(pattern) > -1) {
return true;
} else {
return false;
}
}

function validate_email (inputstr) {

var pattern =
/^[a-zA-Z0-9_\-.]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,3}$/;
if (inputstr.search(pattern) > -1) {
return true;
} else {
return false;
}
}
