﻿
/* Watermark textbox */
$(document).ready(function() {

    swapValues = [];

    $(".watermark_textbox").each(
        function(i) {
            swapValues[i] = $(this).val();
            $(this).focus(function() {
                if ($(this).val() == swapValues[i]) {
                    $(this).removeClass("watermarkOn").val("");
                }
            }).blur(function() {
                if ($.trim($(this).val()) == "") {
                    $(this).addClass("watermarkOn").val(swapValues[i]);
                }
            })
        }
    )

    //***************************************************************************************************************
    // Ideas Library Search control
    // disabled at request of Abbi
    //    $('img').poshytip({
    //	    className: 'tip-whitesimple',
    //	    followCursor: true,
    //	    fade: false,
    //	    slide: false
    //    });



    //***************************************************************************************************************
    // Ideas Library Search control

    $("div.showcase div.item").mouseover(function() {
        $(this).removeClass().addClass("over item");
    }).mouseout(function() {
        $(this).removeClass().addClass("item");
    });



    //***************************************************************************************************************
    // Ideas Library Search control

    $('input[type="text"].keywordbox').focus(function(srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).val("");
        }
    });

    $('input[type="text"].keywordbox').blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this)[0].title);
        }
    });

    $('input[type="text"].keywordbox').blur();



    //***************************************************************************************************************
    // Carousel
    var XMLFile = getQuerystring('carousel');

    if (XMLFile != '' && XMLFile != null) {
        XMLFile = "/Assets/Config/HomeCarousel/" + XMLFile;
    }
    else {
        var url = "" + document.location;
        if (url.indexOf('/Ideas/') > -1 || url.indexOf('/ideas/') > -1)
            XMLFile = "/Assets/Config/IdeasCarousel/_ideascarousellive.xml";
        else
            XMLFile = "/Assets/Config/HomeCarousel/_homecarousellive.xml";
    }

    $("#slidebox .slidebox_images").slidebox({ width: 648, xmlFile: XMLFile, hover: false });
    $("#slidebox2 .slidebox_images").slidebox({ width: 648, xmlFile: XMLFile, hover: false, containerName: "#slidebox2" });



    //***************************************************************************************************************
    // FancyBox modal

    $("a.modal").fancybox({
        //'titleShow'		: false,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic'
    });


});



//***************************************************************************************************************
// Disable enter key
    
function killEnter(e)
{
    e = e? e : window.event;
    var k = e.keyCode? e.keyCode : e.which? e.which : null;
    
    if (k == 13){
        if (e.preventDefault)
            e.preventDefault();
        return false;
    };
    
    return true;
};
    

var loc = new String(document.location);

if (loc.indexOf('PostalOrders.aspx') > -1)
{
}
else
{
    if(typeof document.addEventListener!='undefined')
        document.addEventListener('keydown', killEnter, false);
    else if(typeof document.attachEvent!='undefined')
        document.attachEvent('onkeydown', killEnter);
    else{
        if(document.onkeydown!=null){
        var oldOnkeydown=document.onkeydown;
        document.onkeydown=function(e){
            oldOnkeydown(e);
            killEnter(e);
        };
    }
    else
        document.onkeydown=killEnter;
    }
}

// get querystring info
function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    
    if (qs == null)
        return default_;
    else
        return qs[1];
}
