﻿// JScript File

function showPage(page,id){	           
            getPage = "pages/" + page;                                                       
	        $('#homearea').load(getPage, function(){
		        //$('#Procimg').hide();
		        if (id == 2){document.getElementById('videoPadder').scrollIntoView();}
		        if (id == 3){document.getElementById('divJoin').scrollIntoView();}
	        });
        }
        
function showOffline(page,id){	           
            getPage = "pages/" + page;             
	        $('#divOffline').load(getPage, function(){
		       
	        });
        }
function winOpen(url)
{
    window.open(url);
}
function JoinNow(user,pwd,resid)
{
//alert(user + ","+ pwd+ ","+resid);
$.get("pages/ajax.aspx", { method: "join", p:user, z: pwd ,r:resid  },function(data)
       {            	        
    	    if(data == '100')
    	    {    	   
    	        showPage('confirmation.aspx',1);   //to load confirmation	
    	    }    	       
    	    else
    	    {    	        
    	        $('#errText').text(data);
    	        showDiv('imgAlert');
    	        $("#errdialog").dialog();
    	        $('#divLoading').html("*Please enter a correct email for activation link and FREE credits!")
    	    }
    	    //window.location.reload(true);    	    	     
  	    });

}
function showDiv(divID)
     {
        var divStruct = '#' + divID;              
        $(divStruct).show('slow');
     }
     function hideDiv(divID)
     {
        var divStruct = '#' + divID;
        $(divStruct).hide('slow');     
     }
function LoadBio(chatname)
{
getPage = "pages/bio.aspx?name=" + chatname; 
$('#homearea').load(getPage, function(){
		        //$('#Procimg').hide();		
		        document.getElementById('divModelBio').scrollIntoView();        
	        });

}
 function offlinePaging(page, id){
	        showPage(page,id);
        }
function ContactUs()
{
btnDisplay("btnContact","disabled",true);
uname = document.getElementById("txtEmail").value;
comments = document.getElementById("TxtComments").value;
            if (uname==""){
				//alert("Please enter e-mail");
				loadDsError("Please enter e-mail");				
				document.getElementById("txtEmail").focus();
				btnDisplay("btnContact","disabled",false);
			return false;}                     
			else if (!emailcheck(uname)){
			    loadDsError("E-mail seems to be incorrect. Please try again");				
				document.getElementById("txtEmail").focus();
				btnDisplay("btnContact","disabled",false);
				return false;}
			if (comments==""){
			    loadDsError("Please enter your comments");				
				document.getElementById("txtEmail").focus();
				btnDisplay("btnContact","disabled",false);
			return false;}
			$.get("pages/ajax.aspx", { method: "contact", p:uname, z: comments },function(data)
           {            	       
    	        loadDsError(data);      
    	        btnDisplay("btnContact","disabled",true);	
    	        window.location.reload(true);   
        	    	     
  	        });

}
function loadDsError(data)
{
    $('#errText').text(data);
    showDiv('imgAlert');
    $("#errdialog").dialog();
}
function btnDisplay(id,objevent,value)
{
id = '#' + id;
$(id).attr("disabled", value);
}
function ValidateJoinNow(page)
{
btnDisplay("btnJoin","disabled",true);
if(page == "online")
{
    uname = document.getElementById("email").value;
    password = document.getElementById("pwd").value;
        if (uname==""){
            loadDsError('Please enter e-mail');		    
		    document.getElementById("email").focus();
		    btnDisplay("btnJoin","disabled",false);
	    return false;}                     
	    else if (!emailcheck(uname)){
	        loadDsError('E-mail seems to be incorrect. Please try again');		    
		    document.getElementById("email").focus();
		    btnDisplay("btnJoin","disabled",false);
		    return false;}
        else if (document.getElementById("pwd").value.length <=2){
		    loadDsError('The password should be at least 3 characters. Please try again');		    
		    document.getElementById("pwd").focus();
		    btnDisplay("btnJoin","disabled",false);
		    return false;}
		else if (password==""){
		    loadDsError('Please specify a password');		   
		    document.getElementById("pwd").focus();
		    btnDisplay("btnJoin","disabled",false);
		    return false;}	
	    else
	    {			
	    showDiv('divLoading');
	    JoinNow(uname,password,"");
	    //JoinNow(uname,password,resid);
	    btnDisplay("btnJoin","disabled",false);
	    return true;			
	    }

    }
else
    {
    uname = document.getElementById("email").value;
    conuname = document.getElementById("conemail").value;
    password = document.getElementById("pwd").value;
    conpassword = document.getElementById("conpwd").value;
                if (uname==""){
                    loadDsError('Please enter e-mail');				    
				    document.getElementById("email").focus();
				    btnDisplay("btnJoin","disabled",false);
			    return false;}                     
			    else if (!emailcheck(uname)){
			        loadDsError('E-mail seems to be incorrect. Please try again');				    
				    document.getElementById("email").focus();
				    btnDisplay("btnJoin","disabled",false);
				    return false;}
			    else if (uname != conuname){
			        loadDsError('Confirmed e-mail not matches');				    
				    document.getElementById("conemail").focus();
				    btnDisplay("btnJoin","disabled",false);
			    return false;} 
			    else if (password==""){
			        loadDsError('Please specify a password');				    
				    document.getElementById("pwd").focus();
				    btnDisplay("btnJoin","disabled",false);
				    return false;}		
			    else if (password != conpassword){
			        loadDsError('Confirmed password not matches');				    
				    document.getElementById("conpwd").focus();
				    btnDisplay("btnJoin","disabled",false);
			    return false;}	
			    else if (document.getElementById("pwd").value.length <=2){
				    document.getElementById("pwd").value=document.getElementById("conpassword").value="";
				    loadDsError('The password should be at least 3 characters. Please try again');				    
				    document.getElementById("pwd").focus();
				    btnDisplay("btnJoin","disabled",false);
				    return false;}
				    
			    else
			    {			
			     showDiv('divLoading');
			     JoinNow(uname,password,"");
			    //JoinNow(uname,password,resid);
			    btnDisplay("btnJoin","disabled",false);
			    return true;			
			    }
			    
			    
    	
    }			

}
function emailcheck(src) {
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(src);
	}
	
function emptyUserPass()
	{
		if (document.frmMain.login.value=='username')
			{
			document.frmMain.login.value='';
			document.frmMain.passwd.value='';
			}
	}	
	
function trim(str){
return str.replace(/^\s*|\s*$/g,'');}
	
function checkLogin(){
var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
var Emailid;
var password;
Emailid=document.getElementById("login").value;
password=document.getElementById("passwd").value;	
if (!(regex.test(trim(Emailid)))){
loadDsError('Please enter the valid email ID.');
document.getElementById("login").focus();		
return false;
}
else if (password.value == "")
{
loadDsError('Please enter password.');
document.getElementById("passwd").focus();			
return false;
}
else
{
//alert(document.frmMain.login.value);
document.frmMain.target = "_top";
document.frmMain.action = "http://www.directsex.com/members/authx.aspx"	
//document.frmMain.action = "member/authx.aspx"	
document.frmMain.submit();
}
} 
function openTerms() {
    window.open("../pages/dsusageterms.aspx","dsu","alwaysRaised=yes,scrollbars=yes,width=600,height=523,,");
}
function openPrivacy() {
    window.open("../pages/privacy.aspx", "privacy", "alwaysRaised=yes,scrollbars=yes,width=600,height=523,,");
}
function openCompliance()    {
    window.open("../pages/18.aspx","18","alwaysRaised=yes,scrollbars=yes,width=600,height=523,,");   
}  
function loadHtml(page,title)
{
getPage = "pages/" + page;
ajaxwin=dhtmlwindow.open(title,"ajax",getPage,title,"width=600,height=800,left=500,scrollbars=yes,status=no");
document.getElementById('dhtmlwindowholder').scrollIntoView();
}
