﻿// JScript File
$(document).ready(function(){    
    $("#addressid").change(function () {        
        getAddress($(this).val());
    });
    $('#simple-modal').click(function () {
        $('#wd').modal();
    });
    $(".wd-purchase").change(function () {
        if ($(this).val() == "ebay") {
            $("#wd_form").attr("action", "https://www.cpscentral.com/store/ebay.aspx");
            $("#wd_ebay").attr("checked", "checked");
            $(".wd-ebay").show();
            $(".wd-retail").hide();
            $('input[name$="wd-ebay"]').focus();
        } else {
            $("#wd_form").attr("action", "https://www.cpscentral.com/store/retail.aspx");
            $("#wd_retail").attr("checked", "checked");
            $(".wd-retail").show();
            $(".wd-ebay").hide();
            $('input[name$="wd_price"]').focus();
        }
        return true;
    });
    $(".wd-ebay").hide();
    $(".wd-retail").show();
    $('input[name$="wd_price"]').focus();
    $(".tooltip").cluetip({ splitTitle: '|' });
});
function getAddress(addressid) {   
    $.ajax({
        type: "POST",
	    url: "../client/_ajax_address.aspx",
	    data: "addressid="+addressid,
	    dataType: "xml",
	    success: function(data) {	         
	        $("#label").val($(data).find("label").text());
            $("#firstname").val($(data).find("firstname").text());
            $("#lastname").val($(data).find("lastname").text());
            $("#company").val($(data).find("company").text());
            $("#address1").val($(data).find("address1").text());
            $("#address2").val($(data).find("address2").text());
            $("#city").val($(data).find("city").text());
            $("#state").val($(data).find("state").text());
            $("#zip").val($(data).find("zip").text());
            $("#country").val($(data).find("country").text());
            $("#phone").val($(data).find("phone").text());
            $("#email").val($(data).find("email").text());            
	    }
    });
}


