function echeck(str) {

    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(" ") != -1) {
        alert("Invalid E-mail ID")
        return false
    }
}
function ResetPage()
	{
	document.getElementById('popupholder').innerHTML = '';
	document.getElementById('container').style.opacity = '';
	document.getElementById('container').style.filter = '';
	document.getElementById('popupholder').style.display = 'none';
	}

function showhide()
	{
	document.getElementById('login_response').innerHTML='';	
	document.getElementById('hot').style.display='block';
	document.getElementById('loginform1').style.display='none';
	document.getElementById('member_response').innerHTML='';
	}

function showforgetpassword()
	{
	document.getElementById('loginform1').style.display='none';
	document.getElementById('forgetpassword').style.display='block';
	}
function LogIn()
{ 	
    if ($("#txt12").val() == "") 
    {
		alert("Enter Password.");
		return false;
	}
    else 
    {
        var strurl = "http://" + document.domain + "/cms/hotdealvalidateuser.ashx";
        var strdata = "password=" + $("#txt12").val() + "&type=validate" + "";
        $.ajax({
            type: "POST",
            url: strurl,
            data: strdata,
            success: function(msg) {
                if(msg == "no")
                    document.getElementById('login_response').innerHTML = "Invalid password";
                else
                    location.href = "http://" + document.domain + "/" + msg + ".aspx";
            }
        });        
    }
}	
function forgetpassword()
{
    if(document.getElementById('reqemail').value == "")
		{
		alert("All fields are mendatory.");
		return false;
		}
	else if (echeck($("#reqemail").val()) == false) {
        $("#reqemail").focus();
        return false;
    }	
    else
    {
        var strurl = "http://" + document.domain + "/cms/hotdealnewuser.ashx";
        var strdata = "name=forget&type=forget&email=" + $("#reqemail").val() + "";
        
        $.ajax({
            type: "POST",
            url: strurl,
            data: strdata,
            success: function(msg) {
                if(msg == "no")
                    document.getElementById('forgetpassword_response').innerHTML = "Not valid email.";
                else
                {
                    document.getElementById('forgetpassword_response').innerHTML = "Mail send";                   
                }
            }
        }); 
    }	

}
function SendMembeshipRequest()
{ 	
	if(document.getElementById('txt1').value == "" || document.getElementById('txt3').value == "")
		{
		alert("All fields are mendatory.");
		return false;
		}
	else if (echeck($("#txt3").val()) == false) {
        $("#txt3").focus();
        return false;
    }
    else
    {
        var strurl = "http://" + document.domain + "/cms/hotdealnewuser.ashx";
        var strdata = "name=" + $("#txt1").val() + "&type=adduser&email=" + $("#txt3").val() + "";
        
        $.ajax({
            type: "POST",
            url: strurl,
            data: strdata,
            success: function(msg) {
                if(msg == "no")
                    document.getElementById('member_response').innerHTML = "You have already sent a request for this email address.";
                else
                {
                    document.getElementById('member_response').innerHTML = "Mail send";
                    document.getElementById('hotedeals_val_35058').value = document.getElementById('txt1').value ;
		            document.getElementById('hotedeals_email').value = document.getElementById('txt3').value ;

					document.getElementById('UPTml19520').submit();

		            document.getElementById('txt1').value ="";
		            document.getElementById('txt3').value ="";	
		            document.getElementById('txt3').value ="";


                }
            }
        }); 
    }	
}



function clickFunction()
{

document.getElementById('popupholder').innerHTML = '';
document.getElementById('container').style.opacity = '';
document.getElementById('container').style.filter = '';
document.getElementById('popupholder').style.display = 'none';

var urlpost = "http://"+ document.domain + "/popup.aspx";
urlpost = urlpost +"?sid="+Math.random();
urlpost = urlpost +"&hide=1"

$.post(urlpost);


}


function showPopup()
{	


	var ajaxRM;
	ajaxRM=GetXmlHttpObjectPopUp();
	if (ajaxRM==null)
				  { 
				  alert ("Your browser does not support AJAX!");
				  return;
				  } 

	var url="http://www.worldquestorlando.com/popup.aspx";
	url=url+"?sid="+Math.random();
	ajaxRM.onreadystatechange=function () 
										{
	
											if (ajaxRM.readyState==4)
												{	

													if (ajaxRM.status==200) 
														{	alert(ajaxRM.responseText);
																if(ajaxRM.responseText != "0")
																{

																document.getElementById('popupholder').innerHTML = ajaxRM.responseText;
																document.getElementById('container').style.opacity = '0.3';
																document.getElementById('container').style.filter = 'alpha(opacity: 30)';
																document.getElementById('popupholder').style.display = 'block';
																}
																else
																{
																
																    var strurl = "http://www.worldquestorlando.com/cms/hotdealvalidateuser.ashx";
                                                                    var strdata = "password=temp&type=pagelocation" + "";
                                                                    $.ajax({
                                                                        type: "POST",
                                                                        url: strurl,
                                                                        data: strdata,
                                                                        success: function(msg) {
                                                                            if(msg != "no")
                                                                                location.href = "http://www.worldquestorlando.com/" + msg + ".aspx";
                                                                        }
                                                                    });  
																}

														}
													else
														{
																//alert(ajaxRM.status);
														}
												}
										}
	ajaxRM.open("GET",url,true);
	ajaxRM.send(null);

}


function GetXmlHttpObjectPopUp()
{ var xmlHttpRM=null;
 try
  {  // Firefox, Opera 8.0+, Safari
    xmlHttpRM=new XMLHttpRequest(); }
 catch (e)
  {  // Internet Explorer
  try
	{ xmlHttpRM=new ActiveXObject("Msxml2.XMLHTTP");  }
	  catch (e)
    {    xmlHttpRM=new ActiveXObject("Microsoft.XMLHTTP");
    }
	}
	return xmlHttpRM;
}

