<!--
function WriteMovie(fileName, largeImageFileName) {
    var so = new SWFObject('/jw/player.swf', 'mpl', '556', '345', '9', '#000000');
    so.addParam('allowscriptaccess', 'always');
    so.addParam('allowfullscreen', 'false');
    so.addParam('flashvars', '&file=/movies/' + fileName + '&autostart=false&bufferlength=5&volume=100&image=/images/movielargeimages/' + largeImageFileName + "&skin=/jw/dc.swf");
    so.write('player');
}

function blankInputField(a,b,c) {
    if (document.getElementById(a).value == b) {
        document.getElementById(a).value = "";
        document.getElementById(a).className = c;
    }
}

function populateInputField(a,b,c) {
    if (document.getElementById(a).value == "") {
	    document.getElementById(a).value = b;
	    document.getElementById(a).className = c;
    }
}

function ValidateDOBRequired(src, args) {
          
    dobDay = ddlDOBDayElm[ddlDOBDayElm.selectedIndex].value;
    dobMonth = ddlDOBMonthElm[ddlDOBMonthElm.selectedIndex].value;
    dobYear = ddlDOBYearElm[ddlDOBYearElm.selectedIndex].value;
    if ((dobDay == "0") || (dobMonth == "0") || (dobYear == "0")) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function ValidateDOBIsValid(src, args) {
    
    var dobDay = ddlDOBDayElm[ddlDOBDayElm.selectedIndex].value;
    var dobMonth = ddlDOBMonthElm[ddlDOBMonthElm.selectedIndex].value;
    var dobYear = ddlDOBYearElm[ddlDOBYearElm.selectedIndex].value;
    if ((dobDay != "0") && (dobMonth != "0") && (dobYear != "0")) {
        $.ajax({
            async: false,
            type: "POST",
            url: "/WebService.asmx/CheckDateIsValid",
            data: "strDate=" + dobYear + "-" + dobMonth + "-" + dobDay,
            dataType: "xml",
            success: function(xml) {
                if ($(xml).find('boolean').text() == "true") {
                    args.IsValid = true;
                }
                else {
                    args.IsValid = false;
                }
            }
        });
    }
}

                   

function trim(str) {
    try {
        if(typeof(str)=="string") {
            return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
        }
    }
    catch(e) {
        return "";
    }
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function isValidEmail(strEmail) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,8})+$/;
    return filter.test(strEmail);
}

function closeFaceBox() {
    jQuery(document).trigger('close.facebox')
}

function addThis_onmouseover() {
    return addthis_open(this, '', '[URL]', '[TITLE]');
}

function addThis_onmouseout() {
    addthis_close();
}

function addThis_onclick() {
    return addthis_sendto();
}

function externalLinks() {  
    try {
        if (!document.getElementsByTagName) {
            return;
        }
        var anchors = document.getElementsByTagName("a");   
        for (var i=0; i<anchors.length; i++) {   
            var anchor = anchors[i];   
            if (anchor.getAttribute("href") && anchor.getAttribute("rel")) {
                if (anchor.getAttribute("rel").indexOf("external")!=-1) {
                    anchor.target = "_blank";   
                } 
            }
        }
    }
    catch(e) {}
}   
window.onload = externalLinks;

$(document).ready(function() {
    try {
        var addThisElm = document.getElementById('addThis');
        //addThisElm.onclick = addThis_onclick;
        //addThisElm.onmouseover = addThis_onmouseover;
        addThisElm.onmouseout = addThis_onmouseout;
        addThisElm.onclick = addThis_onmouseover;
        //addThisElm.onmouseout = addThis_onmouseout;
    }
    catch(e){} 
    $('.wp2Link').hover(function() {
        try {
            $(this).children('.wpText').fadeIn("slow");
        } catch (e) { }
    }, function() {
        try {
            $(this).children('.wpText').fadeOut("slow");
        }
        catch (e) { }
    });
	$('.wp1Link').hover(function() {
        try {
            $(this).children('.wpText').fadeIn("slow");
        } catch (e) { }
    }, function() {
        try {
            $(this).children('.wpText').fadeOut("slow");
        }
        catch (e) { }
    });
	$('.wp0Link').hover(function() {
        try {
            $(this).children('.wpText').fadeIn("slow");
        } catch (e) { }
    }, function() {
        try {
            $(this).children('.wpText').fadeOut("slow");
        }
        catch (e) { }
    });
});

//Mega Menu Code
	$(document).ready(function() {
	//On Hover Over
function megaHoverOver(){
    $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
    (function($) {
        //Function to calculate total width of all ul's
        jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            $(this).find("ul").each(function() { //for each ul...
                rowWidth += $(this).width(); //Add each ul's width together
            });
        };
    })(jQuery); 

    if ( $(this).find(".row").length > 0 ) { //If row exists...

        var biggestRow = 0;	

        $(this).find(".row").each(function() {	//for each row...
            $(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if(rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        $(this).find(".sub").css({'width' :biggestRow}); //Set width
        $(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

    } else { //If row does not exist...

        $(this).calcSubWidth();  //Call function to calculate width of all ul's
        $(this).find(".sub").css({'width' : rowWidth}); //Set Width

    }
}
//On Hover Out
function megaHoverOut(){
  $(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
  });
}
//Set custom configurations
var config = {
     sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
     interval: 100, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};

try {
    $("ul#topNav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
    $("ul#topNav li").hoverIntent(config); //Trigger Hover intent with custom configurations
}
catch(e) {
}

});

function updateTopBasket() {
    var basketItemCount = 0;
    if (document.getElementById('viewBasketItemCount')) {
        basketItemCount = parseInt(document.getElementById('viewBasketItemCount').innerHTML);
        if (basketItemCount > 0) {
            document.getElementById('topBasketItemCount').innerHTML = basketItemCount;
            document.getElementById('topBasketSubTotal').innerHTML = document.getElementById('viewBasketSubTotal').innerHTML;
        }
        if (basketItemCount == 1) {
            document.getElementById('topBasketItemSuffix').innerHTML = "item";
        }
        else { document.getElementById('topBasketItemSuffix').innerHTML = "items"; }
    }
    else {
        document.getElementById('topBasketItemCount').innerHTML = '0';
        document.getElementById('topBasketSubTotal').innerHTML = '&pound;0.00';
        document.getElementById('topBasketItemSuffix').innerHTML = "items";
    }
}

function isNumberKey(evt)
      {
          var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }


// Window opening

function winOpenCenter(url,name,statbar,scroll,locate,resize,xWidth,yWidth)	{
var adjustedleft = 8//optional
var adjustedheight = 30//adjust height because of windows taskbar
var screenwidthremainder = screen.availWidth%2//really not needed, but won't hurt
var screenheightremainder = screen.availHeight%2
var screenwidth = screen.availWidth - screenwidthremainder
var screenheight = screen.availHeight - screenheightremainder
var winheight = yWidth //set new window height properties
var winwidth = xWidth //set new window width properties
var winleft = parseInt(screenwidth/2) - (winwidth/2) - adjustedleft//optional
var wintop = parseInt(screenheight/2) - (winheight/2) - adjustedheight

var win = window.open(url,name,'width=' +winwidth+ ',height=' +winheight+',status=' +statbar+',resizable='+resize+',scrollbars='+scroll+',location='+locate+',top='+wintop+',left='+winleft);
return win;
}
//-->


jQuery.fn.ForceNumericOnly =
function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
    })
};
jQuery.fn.RequiredFieldBlur =
function()
{
    $(this).blur(function() {
        if ($(this).val()=='') {
            $('#lblQuanityError').show();
            return false;
        }
        else {
            $('#lblQuanityError').hide();
            return true;
        }
    })
};
jQuery.fn.RequiredFieldClick =
function(theElm)
{
    return this.each(function()
    {
        $(this).click(function() {
            if ($('#'+theElm).val()=='') {
                $('#lblQuanityError').show();
                return false;
            }
            else {
                $('#lblQuanityError').hide();
                return true;
            }
        })
    })
};


function validateAddToBasket(elmId, blnIsVariant) {
    //alert(elmId);
    //alert($('#'+elmId).val());
    //alert($('#hidPriceID').val());
    if ($('#'+elmId).val()=='') {
        $('#lblQuanityError').show();
        $('#lblNoColourSelectedError').hide();
        return false;
    }
    else {
        $('#lblQuanityError').hide();
        if (blnIsVariant) {
            if ($('#hidPriceID').val()=='') {
                $('#lblNoColourSelectedError').show();
                return false;
            }
            else {
                $('#lblNoColourSelectedError').hide();
                return true;
            }
        }
        else {
             $('#lblNoColourSelectedError').hide();
            return true;
        }
    }
}      
