﻿function clickShow(isReplaceImg) {
    if ($('#showDesignerInfo_title').css("background-image").toLowerCase().indexOf("App_Themes/Skin_1/images/DESIGNER-BIO.png".toLowerCase()) > -1) {
        window.self.location.href = 'DesignerBio.aspx';
        return;
    }    
    if (isReplaceImg == true)
        $('#showDesignerInfo_title').css("background-image", "url(App_Themes/Skin_1/images/DESIGNER-BIO.png)");
    $('#showDesignerInfo_main').stop().show().animate({ right: '+52px' }, '600');
}
function closeWindowHidden(imgurl) {
    $('#showDesignerInfo_main').stop().animate({ right: '-262px' }, '600');
    if (typeof (imgurl) != "undefined") {
        $('#showDesignerInfo_title').css("background-image", imgurl);
    }
}
var designerinfoIsAjax = false;
function ajaxLoadZipCode() {
    if (designerinfoIsAjax == true) {
        alert('Please Wait...');
        return false;
    }
    if ($.trim($("#DesignerInfo_inputZipCode").val()) == '') {
        alert('Please enter zip code.');
        return;
    }
    designerinfoIsAjax = true;
    $.ajax({
        type: "POST",
        url: "getDesignerInfo.ashx",
        data: { zipCode: $('#DesignerInfo_inputZipCode').val(), radId: new Date().getTime().toString() },
        success: function(msg) {

            if ($.trim(msg) == 'none') {
                alert('Invalid zip code.');
                $("#DesignerInfo_inputZipCode").val('');
            } else {
                var sJson;
                if (msg.indexOf("<font color=\"#FF0000;\">") > -1) {
                    msg = msg.substr(0, msg.lastIndexOf("}") + 1);
                }
                eval('sJson=' + msg + ';');
                $('#showDesignerInfo_main_mainDiv').html(sJson.MainHtml);
                $('#showDesignerInfo_title').css("background-image", sJson.ClickNavImg);
                $('#showDesignerInfo_title').removeAttr('onclick');
                $('#showDesignerInfo_title').click(function() { clickShow(true); });
                $('#showDesignerInfo_main_closeDiv').removeAttr('onclick');
                $('#showDesignerInfo_main_closeDiv').click(function() { if (replaceImgUrl == "") replaceImgUrl = sJson.NavImg; closeWindowHidden(replaceImgUrl); });

            }
            designerinfoIsAjax = false;
        }
    });
}
var replaceImgUrl = "";
var _designerinfo_imgURL = "App_Themes/Skin_1/images/";
var _designerinfo_ImgArr = new Array("DESIGNER-BIO.png", "DESIGNER-BIO-hover.png", "DesignerFloat-01.png", "DesignerFloat-01-hover.png", "DesignerFloat-02.png", "DesignerFloat-02-hover.png", "identified-bg.png", "identified-left.png", "enter-button1.gif", "your-personal1.png", "your-zip-code1.png", "gph-proinstall-expanded-rvsd.gif", "gph-proinstall-tab.png", "gph-proinstall-zipcode.png");
for (var i = 0; i < _designerinfo_ImgArr.length; i++) {
    var img = new Image();
    img.src = _designerinfo_imgURL + _designerinfo_ImgArr[i];
}

function ChangeDealer(_objSelect, thisUrlInfo) {
    _val = _objSelect.value;
    _url = thisUrlInfo;
    if (_url == "" || _val == "") return;
    window.self.location.href = "ChangeDealer.aspx?cID="+_val+"&returnURL="+encodeURIComponent(_url);
    
}



var hssAjax=false;
function HSSLoad(){
    var _zipCode = $('#txtHSSZipCode').val();
    
    if ($.trim(_zipCode) == '' || $.trim(_zipCode).toUpperCase()=="ENTER YOUR ZIP CODE") {
        $('#txtHSSZipCode').focus();
        alert('Please enter zip code.');
        return;
    }    
    if (hssAjax == true) {
        alert('Please Wait...');
        return false;
    }
  
    hssAjax=true;
    $.ajax({
        type: "POST",
        url: "getHSSPrice.ashx",
        data: { zipCode: _zipCode, radId: new Date().getTime().toString() },
        success: function(msg) {
            hssAjax=false;
            if (msg.indexOf("<font color=\"#FF0000;\">") > -1) {
                msg = msg.substr(0, msg.indexOf("}") + 2);
            }                  
            if ($.trim(msg) == 'none') {
                alert('Invalid zip code.');                              
            } else {                
                var sJson;              
                eval('sJson=' + msg + ';');   
                $('#txtHSSPrice').val(sJson[0].price);
                $('#HSSDisplayDiv').css('left', '0px').show();
                $('#HSSEnterDiv').css('left','-360px').hide();
                
                
            }            
        },
        error:function(){
            alert('error');
             hssAjax=false;
        }
    });
        
    
    
}
//hidden Hss panel
function closeHSSPanel(){    
     if($('#HSSEnterDiv').css('display')!='none' ){       
        $('#HSSEnterDiv').stop().animate({ left: '-360px' }, '600');        
     }else{
     $('#HSSDisplayDiv').stop().animate({ left: '-360px' }, '600');        
     }
}
//display HSS panel
function displayHSSPanel() {

    if ($('#HSSEnterDiv').css('display') != 'none') {
        $('#HSSDisplayDiv').css('display', 'none');
        $('#HSSEnterDiv').css('display', '');
        $('#HSSEnterDiv').stop().animate({ left: '0px' }, '600');
    } else {
        $('#HSSEnterDiv').css('display', 'none');
        $('#HSSDisplayDiv').css('display', '');
        $('#HSSDisplayDiv').stop().animate({ left: '0px' }, '600');
    }
}


$(function(){

    function setBeginHSSInput(){
        if($.trim( $('#txtHSSZipCode').val()).toUpperCase()=="" ||  $.trim( $('#txtHSSZipCode').val()).toUpperCase()=="ENTER YOUR ZIP CODE" ){
            $('#txtHSSZipCode').val('ENTER YOUR ZIP CODE');
            $('#txtHSSZipCode').css('font-size','13px');
        }else{
            $('#txtHSSZipCode').css('font-size','16px');
        }
    }    
    $('#txtHSSZipCode').focus(function(){
      if( $.trim( $(this).val()).toUpperCase()=="ENTER YOUR ZIP CODE" || $.trim( $(this).val()).toUpperCase()==""){
        $(this).val('');
        $(this).css('font-size','16px');
      }else{
        $(this).css('font-size','16px');
      }
    }).blur(function(){
    
        setBeginHSSInput();
    });

    setBeginHSSInput();
    
});




$(document).ready(function() {
    closeHSSPanel();
});



