
$(document).ready(function() {
    
    /*
     * Browser version check for oldschool people
     */
    if (($.browser.mozilla) && (parseInt($.browser.version, 10) <= 4) ){
        alert("Sorry, Your web browser version "+ $.browser.version +" is not compatible with our web site, please upgrade it to Firefox 5.0 or higher");
    }
    if (($.browser.msie) && (parseInt($.browser.version, 10) <= 6) ){
        alert("Sorry, Your web browser version "+ $.browser.version +" is not compatible with our web site, please upgrade it to IE 8.0 or higher");
    }
    if (($.browser.opera) && (parseInt($.browser.version, 10) <= 7) ){
        alert("Sorry, Your web browser version "+ $.browser.version +" is not compatible with our web site, please upgrade it to Opera 8.0 or higher");
    }
    if (($.browser.safari) && (parseInt($.browser.version, 10) <= 400) ){
        alert("Sorry, Your web browser version "+ $.browser.version +" is not compatible with our web site, please upgrade it to 500.0 or higher");
    }
            
    /*
     * For the Signup Process
     */
    $("#ctl00_PageContent_BillingEqualsAccount").parent().hide().after("<div><b>Enter your billing information</b></div>");
    $("#ctl00_PageContent_BillingEqualsAccount").hide();
    $("#ctl00_PageContent_btnShppingEqBilling").after("<div><b>Enter your shipping information</b></div>"); 
    $("#ctl00_PageContent_btnShppingEqBilling").hide();
	
    var ttxtx = "<input id='jet-auth-code' type='text' style='width:20%;' /><span id='jet-auth-code-msg' style='margin: 0 0 0 5px;'>(Enter your Authorization code received from Account Manager)</span>";
    $("#ctl00_PageContent_ctrlAccount_chkOver13").parent().parent().after("<tr><td align='right' width='35%' valign='middle'>Authorization Code</td><td align='left' width='65%' valign='middle'>"+ttxtx+"</td></tr>");
    $("#ctl00_PageContent_btnContinueCheckout").after("<input id='jet-new-submit-button' type='button' value='Create Account' />");
    $("#ctl00_PageContent_btnContinueCheckout").css({
        display:"none"
    });
    
    /*
	 * Set the sequence of the boxes in the signup page
	 */
    $('#ctl00_PageContent_pnlAccountInfo').before($('#ctl00_PageContent_pnlShippingInfo'));
    $('#ctl00_PageContent_pnlAccountInfo').before($('#ctl00_PageContent_pnlBillingInfo'));

	
    /*  //this is a big F'ing compatibility error in IE 
	$("#ctl00_PageContent_pnlAccountInfo table tbody tr td table tbody tr td table tbody tr td span").css({
        valign: "top",
    });
 */   
    $("#jet-new-submit-button").css({
        display:"block"
    });
    $("#jet-new-submit-button").click(function() {
        jetValidate();
    });
    
    /*
     * For Logged Home Page
     */
    var strVarSc="";
    strVarSc += "<div class='domtab' id='other'>";
    strVarSc += "    <ul class='domtabs'>";
    strVarSc += "        <li class='active'><a href='#tt1'>DesignVision<\/a><\/li>";
    strVarSc += "        <li><a href='#tt2'>Catalogs<\/a><\/li>";
    strVarSc += "        <li><a href='#tt3'>Pricing<\/a><\/li>";
    strVarSc += "    <\/ul>";
    strVarSc += "    <img width='100%' src='tab_play\/images\/bar.png' alt=''\/>";
    strVarSc += "    <br\/>";
    strVarSc += "    <div style='display: block;'>";
    strVarSc += "        <h2><a id='tt1' name='tt1'><\/a><\/h2>";
    strVarSc += "        <p>";
    strVarSc += "        <ul>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/designvision\/designvision.exe'\">Download Application<\/button><\/a><\/li>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/designvision\/designvisionmanual.pdf'\">Quickstart Guide<\/button><\/a> <\/li>";
    strVarSc += "        <\/ul>";
    strVarSc += "        <\/p>";
    strVarSc += "    <\/div>";
    strVarSc += "    <div style='display: none;'>";
    strVarSc += "        <h2><a id='tt2' name='tt2'><\/a><\/h2>";
    strVarSc += "        <p>";
    strVarSc += "        <ul>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/catalogs\/rhc_16pageProductCatalog.pdf'\">RapcoHorizon Catalog<\/button><\/a><\/li>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/catalogs\/oculusCatalog.pdf'\">Oculus Catalog<\/button><\/a><\/li>";
    strVarSc += "        <\/ul>";
    strVarSc += "        <\/p>";
    strVarSc += "    <\/div>";
    strVarSc += "    <div style='display: none;'>";
    strVarSc += "        <h2><a id='tt3' name='tt3'><\/a><\/h2>";
    strVarSc += "        <p>";
    strVarSc += "        <ul>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/pricing\/RHC_Priceguide_Retail_12.pdf'\">RapcoHorizon 2012 Retail Price Guide<\/button><\/a><\/li>";
    strVarSc += "            <li><a href='#'><button type=\"button\" onclick=\"window.location='images\/document\/pricing\/RHC_Priceguide_12.pdf'\">RapcoHorizon 2012 Dealer Price Guide<\/button><\/a><\/li>";
    strVarSc += "        <\/ul>";
    strVarSc += "        <\/p>";
    strVarSc += "    <\/div>";
    strVarSc += "<\/div>";

    var weCallItBox = "<br><div style='margin:10px'>"+strVarSc+"<br></div><br><br>";
    if(($.trim($("#loginText a").text().toLowerCase())==="logout")) {
        $("#pict").parents().filter("#ctl00_PageContent_pnlContent").css({
            height:"300px"
        });

        // when we hav pic in home 
        // $("#pict").parents().filter("#ctl00_PageContent_pnlContent").html(weCallItBox);

        // when we hav flash banner in home
        $("#pict").parents().filter("#ctl00_PageContent_pnlContent").html(weCallItBox);
     
        $("#jet-homepage-ul").css({
            cursor: "pointer"
        });
		
        //the msg jsut after reg in
        $("#ctl00_PageContent_ShowWishButtons").parent().parent().append("<br><br><div style='text-align:center'>Please proceed to Home for the Dealer Information</div>")

    }else {
        $("#quickLeft #Span1").text("My Account | ");
        $("#quickLeft #loginText a").text("Dealer Login");
    }
    
    //just
    $("#quickLeft #loginText a").css({
        //color:"#DDEEFF"
        });

});


function jetValidate() {
    var CODEX = "4320X@1789RHC";				
        
    if($("#jet-auth-code").val() != CODEX) {
        $("#jet-auth-code-msg").css({
            color: "red"
        });
        return false;
    }else {
        Page_ValidationActive=true;
        if (typeof(Page_ClientValidate) == 'function') { 
            if (Page_ClientValidate() == false) { 
                return false; 
            }
        }
        this.disabled = true;
        document.getElementById("ctl00_PageContent_btnContinueCheckout").disabled = true;
        __doPostBack('ctl00$PageContent$btnContinueCheckout','');
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PageContent$btnContinueCheckout", "", true, "registration", "", false, false))
        $("#jet-auth-code-msg").css({
            color: "inherit"
        });
        return true;	
    }
}



