function fnValidateNewsletterSub(){
	var sel=0;
	if(document.getElementById('subscribe1').checked== true) {
		sel = document.getElementById('subscribe1').value
	}
	if(document.getElementById('subscribe2').checked== true) {
		sel = document.getElementById('subscribe2').value
	}
	
	if(document.frmnewssub.emailid.value=="" || document.frmnewssub.emailid.value=="Enter your E Mail Address"){
		alert("Please enter email");
		document.frmnewssub.emailid.focus();
		return false
	}
	
	if(!fnEmail(document.frmnewssub.emailid)){		
		document.frmnewssub.emailid.focus();
		return false
	}
	
	var emailid=document.frmnewssub.emailid.value;
	var ccity=document.frmnewssub.ccity.value;
	fnNewslettersub(emailid,sel,ccity)
}
var xmlHttp1
function fnNewslettersub(eid,cval,ccity)
{ 
	xmlHttp1=RemoteRequestObject()
	if (xmlHttp1==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	if(eid!=""){
		var url="submitnewsletter.php"
		url=url+"?emailid="+eid+"&subid="+cval+"&ccity="+ccity+"&from=newsletter"+"&randid="+Math.random()
		//alert(url)
		xmlHttp1.onreadystatechange=stateChangedn 
		xmlHttp1.open("GET",url,true)
		xmlHttp1.send(null)
	}
}

function stateChangedn() 
{ 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{
		document.getElementById("somediv").style.display="";
		document.getElementById("somediv").innerHTML="";
		if(document.getElementById('subscribe1').checked== true) {
			document.getElementById("somediv").innerHTML="<div id='somediv_val' >"+xmlHttp1.responseText+"</div>"			
			divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'SUBSCRIBE FOR NEWSLETTER', 'width=400px,left=200px,top=100px,height=180px,scrolling=1'); 
			
			document.frmnewssub.emailid.value=""
			document.frmnewssub.emailid.value = 'Enter E-Mail Address';

		} else if(document.getElementById('subscribe2').checked== true) {
			document.getElementById("somediv").innerHTML="<div id='somediv_val' class='popupbg'>"+xmlHttp1.responseText+"</div>"			
			divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'UNSUBSCRIBE FOR NEWSLETTER', 'width=400px,left=200px,top=100px,height=180px,scrolling=1'); 
			
			document.frmnewssub.emailid.value=""
			document.frmnewssub.emailid.value = 'Enter E-Mail Address';
		}
		
	} 
}


function fnValidateSMSSub(){	

	var pobj=document.frmSMSSub.psubscribe;
	
	//alert(obj);
	flag=0
	var chkpval=0;
	for(var i=0;i<pobj.length;i++){
		if(pobj[i].checked==true){
			flag=1;
			chkpval=pobj[i].value;
			break;
		}
	}
		
	if(document.frmSMSSub.phoneno.value=="" || document.frmSMSSub.phoneno.value=="Enter Your Phone No."){
		alert("Please enter Phone Number");
		document.frmSMSSub.phoneno.focus();
		return false
	}
	
	if(!(/^\d+$/.test(document.frmSMSSub.phoneno.value))){
		alert("Phone Number Should be numbers only");
		document.frmSMSSub.phoneno.focus();
		document.frmSMSSub.phoneno.value="";
		return false;
	}
	if(document.frmSMSSub.phoneno.value.length < 10 || document.frmSMSSub.phoneno.value.length > 10){
        alert("Phone number should be 10 Digits");
		document.frmSMSSub.phoneno.focus();
		return ;
		}
	
	var phone=document.frmSMSSub.phoneno.value;
	var ccity=document.frmSMSSub.ccity.value;
	if(chkpval==0) {
	   fnValidateSMSAjax(phone,0,ccity);

	}else{
		fnValidateSMSAjax(phone,1,ccity);
    //var url="submitnewsletterunsub.php?phoneno="+phone
	//window.open(url,"","width=400,height=120,resizable=1,left=300,top=250") 
    
	}
	
}

var xmlHttp21
function fnValidateSMSAjax(pid,cval,ccity)
{ 
	xmlHttp21=RemoteRequestObject()
	if (xmlHttp21==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	if(pid!=""){
		var url="submitnewsletter.php"
		url=url+"?phoneno="+pid+"&subid="+cval+"&ccity="+ccity+"&from=sms"+"&randid="+Math.random()
		//alert(url)
		xmlHttp21.onreadystatechange=stateChangeds 
		xmlHttp21.open("GET",url,true)
		xmlHttp21.send(null)
	}
}

function stateChangeds() 
{ 
	if (xmlHttp21.readyState==4 || xmlHttp21.readyState=="complete")
	{
		document.getElementById("somediv").style.display="";
		document.getElementById("somediv").innerHTML="";
		
		if(document.getElementById('psubscribe1').checked== true) {
			document.getElementById("somediv").innerHTML="<div id='somediv_val' >"+xmlHttp21.responseText+"</div>"			
			divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'SUBSCRIBE FOR SMS', 'width=400px,left=200px,top=100px,height=180px,scrolling=1'); 
			
			document.frmSMSSub.phoneno.value=""
			document.frmSMSSub.phoneno.value = 'Enter Your Phone No.';

		} else if(document.getElementById('psubscribe2').checked== true) {
			document.getElementById("somediv").innerHTML="<div id='somediv_val' class='popupbg'>"+xmlHttp21.responseText+"</div>"			
			divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'UNSUBSCRIBE FOR SMS', 'width=400px,left=200px,top=100px,height=180px,scrolling=1'); 
			
			document.frmSMSSub.phoneno.value=""
			document.frmSMSSub.phoneno.value = 'Enter Your Phone No.';
		}
		
	} 
}

function fnChkLoginindex() {

	if(document.frmLogin.username.value=="" || document.frmLogin.username.value=="User Name"){
		alert("Please enter user name");
		document.frmLogin.username.focus();
		return false
	}
	
	if(document.frmLogin.psw.value=="" || document.frmLogin.psw.value=="Password"){
		alert("Please enter password");
		document.frmLogin.psw.focus();
		return false
	}
	
	uname = document.frmLogin.username.value
	
	upassword = document.frmLogin.psw.value


	fnValidateLoginAjax(uname,upassword);
	//document.frmLogin.action="chklogin.php"
	//document.frmLogin.submit();
}

var xmlHttp22
function fnValidateLoginAjax(uid,upass)
{ 
	xmlHttp22=RemoteRequestObject()
	if (xmlHttp22==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	if(uid!=""){
		var url="chklogin.php"
		var remember='';
		if(document.frmLogin.remember.checked==true) {
			remember = document.frmLogin.remember.value
		}
		url=url+"?username="+uid+"&psw="+upass+"&remember="+remember+"&randid="+Math.random()
		//alert(url)
		xmlHttp22.onreadystatechange=stateChangedLoin
		xmlHttp22.open("GET",url,true)
		xmlHttp22.send(null)
	}
}

function stateChangedLoin() 
{ 
	if (xmlHttp22.readyState==4 || xmlHttp22.readyState=="complete")
	{
		//alert(xmlHttp22.responseText)
		document.getElementById("somediv").style.display="";
		document.getElementById("somediv").innerHTML="";
		
		var val1 = xmlHttp22.responseText;
		var arr1 = val1.split("|");

		if(arr1[0]== 'wrong') {
			//document.getElementById("somediv").innerHTML="<div id='somediv_val' >"+xmlHttp22.responseText+"</div>"			
			//divwin=dhtmlmodal.open('agebox', 'span', 'somediv', 'Login', 'width=600px,left=200px,top=60px,height=400px,scrolling=1'); 

			document.getElementById("login_p").innerHTML="";
			document.getElementById("login_p").innerHTML=arr1[1]
			
			
		} else if(arr1[0]== 'ok') {
			
			//alert(arr1[0])
			jQuery(function() {
				//alert("jquery");
				$.post("photogallery/misc.php",{authuser:$('#username').val(),password:$('#psw').val(),action:"login",sessid:Math.random()},function(data) {

					window.location.href = 'mypulse.php';
				});
			});
			
			//window.location.href = 'mypulse.php';
		}
		
	} 
}

function fnforgotpassword()
{ 
var url="forgotpassword.php"
url=url+"?rand="+Math.random()
divwin=dhtmlmodal.open('agebox', 'iframe', url, 'Retrieve Password', 'width=450px,height=200px,center=1,resize=0,scrolling=1');

}


function fnchgRegtype(rtype) {
	
	document.getElementById("regtype").value = '';
	document.getElementById("regtype").value = rtype;

}


function fnShowSite(id,urlval){

	var myUrl="showtargetsite.php?id="+id+"&url='"+urlval+"'";
	 window.open(myUrl,"urlval","_new,toolbars=yes,menubar=yes,width=700,height=500,scrollbars=yes,resizable=yes,status=yes,directories=yes");	

}


$(document).ready(function(){ 

if(document.getElementById("cur_tab")!=null) {

	var t=$("#cur_tab").val();
	var t1="#tab"+t;

		$(t1).addClass('current');
//alert(t1)
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:t,sessid:Math.random()},function(data)
		{
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});

}
});


 $(function() {
$("#tab0").click(function(){ 
     
		var t=$("#cur_tab").val();
		$("#cur_tab").val(0);
		var t1="#tab"+t;
		$(t1).removeClass('current');
	    $("#tab0").addClass('current');
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:0,sessid:Math.random()},function(data)
		{	 
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});
	});

	$("#tab1").click(function(){ 
     
		var t=$("#cur_tab").val();
		$("#cur_tab").val(1);
		var t1="#tab"+t;
		$(t1).removeClass('current');
        $("#tab1").addClass('current');
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		$.post("week_events.php",{pg:1,week:1,sessid:Math.random()},function(data)
		{	
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});

	});
		
	$("#tab2").click(function(){ 
      
		var t=$("#cur_tab").val();
		$("#cur_tab").val(2);
		var t1="#tab"+t;
		$(t1).removeClass('current');
	    $("#tab2").addClass('current');
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:2,sessid:Math.random()},function(data)
		{
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});
	});

	$("#tab3").click(function(){ 
      
		var t=$("#cur_tab").val();
		$("#cur_tab").val(3);
		var t1="#tab"+t;
		$(t1).removeClass('current');
	    $("#tab3").addClass('current');
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:3,sessid:Math.random()},function(data)
		{
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});

	});

	 $("#tab4").click(function(){ 
      
		var t=$("#cur_tab").val();
		$("#cur_tab").val(4);
		var t1="#tab"+t;
		$(t1).removeClass('current');
	    $("#tab4").addClass('current');
		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:4,sessid:Math.random()},function(data)
		{
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});

	});

		 $("#tab5").click(function(){ 
      
		var t=$("#cur_tab").val();
		$("#cur_tab").val(5);
		var t1="#tab"+t;
		$(t1).removeClass('current');
     
	    $("#tab5").addClass('current');
	document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		$.post("week_events.php",{pg:1,week:5,sessid:Math.random()},function(data)
		{
			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;
			$(function() {$('.scroll-pane').jScrollPane();});
		});
	});

	$("#tab6").click(function(){ 
      
		var t=$("#cur_tab").val();
		$("#cur_tab").val(6);
		var t1="#tab"+t;
		$(t1).removeClass('current');
        $("#tab6").addClass('current');

		document.getElementById("inline_txt_week_events").innerHTML ='<div style="float:left;"><table border="0" cellpadding="0" width="280px" cellspacing="0" style="height: 168.5px;"><tbody><tr><td align="center"><p><img alt="loading.gif" title="loading.gif" src="images/loading.gif" height="30" width="30"><br><strong><font color="#FFFFFF">Loading ...</font></strong></p></td></tr></tbody></table></div>';
		
		$.post("week_events.php",{pg:1,week:6,sessid:Math.random()},function(data)
		{
			

			document.getElementById("inline_txt_week_events").innerHTML ="";
			document.getElementById("inline_txt_week_events").innerHTML =data;

			$(function() {
			//alert("something")
			$('.scroll-pane').jScrollPane();
			});
			
		});
		
	});
		
	
 });