﻿var o_frm,_ThisRDS,_ThisRDSOrderRoot,_MenuLinkURLPreface;
var o_frmU, o_frmP, o_frmL, o_frmZ;
$(function () {
    try { if (document.addEventListener) { document.addEventListener('DOMContentLoaded', init_dom, false); } }
    catch (e) { }
    

    /*
    if(window.parent.location.protocol.toLowerCase()=="http:"){
    $(".SSLWarning").show();
    }
    */
});

function asyncMenuGuide(zoneID,AzoneID){
    // zoneID is used a way of queueing menu guides that are to be emailed
    // azoneid is the ACTUAL zoneID
    if(AzoneID==null){AzoneID=zoneID;}
    // JSON callback is the only way to make a call across domains
    var urlS="/order/ServicesNoAuth/MenuPDFZoneBook.ashx?nrco=1&r="+_ThisRDS+"&z="+zoneID+'&az='+AzoneID.toString()+"&jsoncallback=?";
    $.getJSON(_MenuLinkURLPreface+urlS,function(d){
        window.resizeTo(800,600);
        location.href=_MenuLinkURLPreface+d.file;
    });
}

function menuGuideByZone(zoneID,AzoneID){
    if(AzoneID==null){AzoneID=zoneID;}
    openWin('/pGenerateMenuGuide.ashx?z=' + zoneID.toString() + '&az=' + AzoneID.toString(), 'wMenuGuide', 'height=200px,width=300px,status=no,toolbar=no,location=no,resizable=yes');
    return false;
}


function init_login(){
    //o_frmU=gObj("frmU");
    //o_frmP=gObj("frmP");
    
    o_frmU=$(".loginTextBox")[0];
    o_frmP=$(".loginTextBox")[1];
    //o_frmL=gObj("logCheck");
    o_frmZ=$(".frmZip")[0];
    o_frm=document.forms[0];
    if(getCookie("u")){
        o_frmU.value=getCookie("u");
        o_frmP.value=getCookie("p");
        //o_frmL.checked=true;
    }
}
function doZip(){
	if((o_frmZ.value.length!=4&&o_frmZ.value.length!=5&&o_frmZ.value.length!=6)||isNaN(o_frmZ.value)){
		alert("Please enter in the zip code where the order is being delivered.");
		o_frmZ.select();
		return false;
	}
	o_frmU.value="";
	o_frmP.value="";
	//o_frm.action=_ThisRDSOrderRoot + _HomePageLoginAction; // "order3.asp";
	o_frm.action=_HomePageLoginAction;
	gObj("frmDoZip").value="yes";
	doSubmit();
}
function doHotel(){
	//o_frmU.value="";
	//o_frmP.value="";
	//o_frm.action=_ThisRDSOrderRoot + "order1h.asp";
	o_frm.action=_HomePageLoginAction+"&dh=1";
	gObj("frmDoZip").value="";
	doSubmit();
}
function doLogin(){
	if(o_frmU.value.length<6||o_frmP.value.length<6){
		alert(ttt23);
		o_frmU.select();
		return false;
	}
	else{
		if(o_frmL.checked){
			var the_date = new Date("December 31, 2050"); 
			var the_cookie_date = the_date.toGMTString(); 
			document.cookie="u="+o_frmU.value+";expires="+the_cookie_date;
			document.cookie="p="+o_frmP.value+";expires="+the_cookie_date;
		}
		else{
			document.cookie="u=";
			document.cookie="p=";
		}
        o_frm.action=_ThisRDSOrderRoot + "order2.asp";
		doSubmit();
	}
}
function doSubmit(){
	o_frm.submit();
}
function orderStart(ZoneID, RestID, OrderType){
    /*
    if(!OrderType){OrderType="";}
    o_frm.action=_ThisRDSOrderRoot+"order3.asp?frmOrderType="+OrderType;
    gObj("frmZone").value=ZoneID;
	gObj("frmDoZone").value="yes";
    doSubmit();
    */
    //location.href="/order/10_initiate.aspx";
    var OrderTypeInt="1";
    switch(OrderType){
        case "DELIVERY":
            OrderTypeInt="1";
            break;
        case "CATERING":
            OrderTypeInt="3";
            break;        
    }
    location.href="/DirectRestaurantLink.aspx?t="+OrderTypeInt+"&r="+RestID.toString()+"&z="+ZoneID.toString();  
}


function viewMenu(restID, menuID, orderType, zoneID){
    //openWin("/order/ServicesNoAuth/MenuPDF.ashx?m="+menuID+"&l="+restID+"&t="+orderType+"&z="+zoneID, "MenuPrint", "width=750px,height=700px,scrollbars=yes,resizable=yes" );
    openWin(_MenuLinkURLPreface+"/order/ServicesNoAuth/MenuPDF.ashx?RDS="+_ThisRDS+"&m="+menuID+"&l="+restID+"&t="+orderType+"&z="+zoneID, "MenuPrint", "width=750px,height=700px,scrollbars=yes,resizable=yes" );
}

function showSSLWarning(){
    openWin("/order/pSecure.aspx", "SSLWarning", "width=550px,height=400px,scrollbars=no,resizable=yes");
}

function showStaticPrivacy(){
    openWin("/pPrivacy.aspx", "wPrivacy", "width=550px,height=500px,scrollbars=yes,resizable=yes");
}
function showStaticRefund(){
    openWin("/pRefund.aspx", "wRefund", "width=550px,height=300px,scrollbars=yes,resizable=yes");
}
