//  Inititalises jQuery in compatibility mode
var $jq = jQuery.noConflict();

//  Common items
$jq(document).ready(function() {

    $jq('.dropDownWrap').bgiframe();
    $jq('#shoppingbag_layer').bgiframe();

    $jq('.dropDownBox').show();

    //    -- IE6 Png fix
    $jq(function(){$jq(document).pngFix();});

    $jq('.dropDownBox').hide();

    $jq('.tln').hover(
	    function () {
		    $jq(this).addClass('hover');
		    $jq('#' + $jq(this).attr('id') + ' > .dropDownWrap').show();
		    $jq('#' + $jq(this).attr('id') + ' > .dropDownWrap .dropDownBox').fadeIn('normal');
		},
        function () {
            $jq(this).removeClass('hover');
            $jq('.dropDownWrap').hide();
            $jq('.dropDownBox').hide();
        }
	);
	  
    $jq('#contact_cs').hover(
        function () {
            $jq(this).addClass('over');
        },
        function () {
            $jq(this).removeClass('over');
        }
    );
      
    //    -- Shopping bag
    $jq('#utilnav_shoppingbag').mouseleave( function() {
        if ($jq('#cart_content:visible').length > 0) {
            /*
             * We only hide the shopping bag if the mouse leaves the area when the cart content is visible.
             * This ensures that we dont hide the bag when the mouse leaves the "loading..." image.
             */
            $jq('#shoppingbag_layer').hide();
            $jq('#shoppingbag_layer').removeAttr('style');
        }
    });
    
    $jq('#utilnav_shoppingbag').mouseenter( function() {
        if ($jq('#cart_content:visible').length > 0) {
            $jq('#shoppingbag_layer').show();
            $jq('#shoppingbag_layer').attr('style', "top:45px; margin-top: auto;");
        }
    });
    
    minibag_mouseleave();
    
    //    -- Footer
    $jq('#signup_email_address').focus(function () {
        if (this.value == $jq("#signup_email_address").data("default_value")){
            $jq('#signup_email_address').val('');
        }
        return false;
    });
    
    $jq('#signup_email_address').blur(function () {
        if (this.value == ''){
            $jq('#signup_email_address').val($jq("#signup_email_address").data("default_value"));
        }
        return false;
    });
    
    $jq('#country_select').change(function () {
        window.location = 'http://' + this.value;
    });
    
    //    -- Logo
    $jq('#el_logo').click( function() {
        location.href = "/index.tmpl";    
    });
    
});

function minibag_mouseleave() {
    $jq('#shoppingbag_qtyfilter').mouseleave( function(event) {
        event.stopPropagation();
    });
}
