﻿
function doClear(inputField) {
    if (inputField.value == inputField.defaultValue) {
        inputField.value = "";
//        inputField.style.color = "black";
    }
}


jQuery(document).ready(function ($) {
    $('#mycarousel').jcarousel({
        wrap: 'circular', 
		scroll:1
    });
    $('#tecarousel').jcarousel({
        wrap: 'circular', 
		scroll:1
    });
	
    $('#rotating-articles').cycle({
        fx: 'fade',
        speed: 500,
        timeout: 5500,
        pager: '#rotating-articles-nav',
        pause: 1, 
		fit: 1
    });
    $('.rotating-headers').cycle({
        fx: 'fade',
        speed: 500,
        timeout: 5000
    });

    function showNewsLetter() {
        var value = $.cookie("newsletterAlreadyShown");
        if (value != "true") {
            var src = "/eNewsletter_Sign_up.aspx?auto=1";
            $.modal('<div style="width: 700px; height: 500px;"><div class="modal-close-signup"><a href="javascript:void(0);" class="simplemodal-close" style="color: #999999;font-size:23px;">CLOSE</a></div><div class="modal-iframe"><iframe src="' + src + '" height="500" width="700" style="border:0 none;" frameborder="0" /></div>', {
                closeHTML: "",
                containerCss: {
					backgroundColor: "#CDCECE",
					border: "1px solid #999999",
					height: 520,
					padding: 0,
					width: 702
                },
                overlayClose: true,
                onClose: function (dialog) {
                    $.cookie("newsletterAlreadyShown", "true", { path: '/' });
                    $.modal.close();
                }
            });
        };
    };

	if(window.isMobileSite === undefined){
		if(window.location.href.indexOf('okcadillac') == -1 && window.location.href.indexOf('cadillacstl') == -1  && window.location.href.indexOf('teamesc') == -1 && window.location.href.indexOf('cadtet') == -1  && window.location.href.indexOf('cadstl') == -1  && window.location.href.indexOf('cadokc') == -1)
			window.setTimeout(showNewsLetter, 16000);
	}
});

jQuery(function ($) {
    jQuery('.btnLocateDealer').click(function (e) {
        var src = "/Standard-Items/Dealer-Results.aspx";
        if ($('#ctl06_ctl00_txtLocateDealer').val() != "ENTER ZIP") {
            src = src + "?zip=" + $('#ctl06_ctl00_txtLocateDealer').val();
        }
        $.modal('<div style="width: 600px; height: 290px;"><div class="modal-close"><a href="#" class="simplemodal-close" style="color: #0C3F5E;font-size:12px;">Close </a></div><div class="modal-iframe"><iframe src="' + src + '" height="290" width="600" style="border:0 none;" frameborder="0" /></div>', {
            closeHTML: "",
            containerCss: {
                backgroundColor: "#CDCECE",
                border: "1px solid #999999",
                height: 310,
                padding: 0,
                width: 600
            },
            overlayClose: true
        });
        return false;
    });
});

jQuery('.txtLocateDealer').keypress(function (e) {
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
        jQuery('.btnLocateDealer').click();
        return false;
    } else {
        return true;
    }
});

function popupModalClosestDealer(linkType){
	if(linkType !="")
		linkType = "?linkType=" + linkType;
		
	var src = "/Standard-Items/Dealer-Results.aspx" + linkType;
	$.modal('<div style="width: 600px; height: 290px;"><div class="modal-close"><a href="#" class="simplemodal-close" style="color: #0C3F5E;font-size:12px;">CLOSE</a></div><div class="modal-iframe"><iframe src="' + src + '" height="290" width="600" style="border:0 none;" frameborder="0" /></div>', {
		closeHTML: "",
		containerCss: {
			backgroundColor: "#CDCECE",
			border: "1px solid #999999",
			height: 310,
			padding: 0,
			width: 600
		},
		overlayClose: true
	});
}

jQuery(function ($) {
    jQuery('.closest-dealer').click(function (e) {
        var src = "/Standard-Items/Dealer-Results.aspx";
        $.modal('<div style="width: 600px; height: 290px;"><div class="modal-close"><a href="#" class="simplemodal-close" style="color: #0C3F5E;font-size:12px;">CLOSE</a></div><div class="modal-iframe"><iframe src="' + src + '" height="290" width="600" style="border:0 none;" frameborder="0" /></div>', {
            closeHTML: "",
            containerCss: {
                backgroundColor: "#CDCECE",
                border: "1px solid #999999",
                height: 310,
                padding: 0,
                width: 600
            },
            overlayClose: true
        });
        return false;
    });
});

jQuery(function ($) {
    jQuery('.video-menu-item').click(function (e) {
        var src = $(this).attr("href");
        $.modal('<div style="width: 900px; height: 480px;border:solid 1px #999;"><div class="modal-close"><a href="#" class="simplemodal-close" style="color: #0C3F5E;font-size:12px;">CLOSE</a></div><div class="modal-iframe"><iframe src="' + src + '" height="480" width="900" style="border:0 none;" frameborder="0" /></div>', {
            closeHTML: "",
            containerCss: {
                backgroundColor: "#CDCECE",
                border: "1px solid #999999",
                height: 500,
                padding: 0,
                width: 900
            },
            overlayClose: true
        });
        return false;
    });
});

jQuery(function ($) {
    jQuery('.newsletter-menu-item').click(function (e) {
        var src = $(this).attr("href");
        $.modal('<div style="width: 700px; height: 500px;"><div class="modal-close-signup"><a href="#" class="simplemodal-close" style="color: #0C3F5E;font-size:12px;">Close</a></div><div class="modal-iframe"><iframe src="' + src + '" height="500" width="700" style="border:0 none;" frameborder="0" /></div>', {
            closeHTML: "",
            containerCss: {
                backgroundColor: "#CDCECE",
                border: "1px solid #999999",
                height: 520,
                padding: 0,
                width: 702
            },
            overlayClose: true
        });
        return false;
    });
});

