var config = {
    sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
    interval: 200, // number = milliseconds for onMouseOver polling interval    
    timeout: 500 // number = milliseconds delay before onMouseOut    
};

$(document).ready(function()
{
runJQuery();

  $('ul.menu > li').hoverIntent(function () { $(this).find('>ul').show(); }, function () { $(this).find('>ul').hide(); });

  $('.addToBasket').click(function() { 
       $.growlUI('Item has been added to your basket!', '<a class="newLinkO plr20 right grey" href="/Basket.aspx">proceed to checkout</a>'); 
   });
	
  $('.addToBasketNoButton').click(function() { 
       $.growlUI('Item has been added to your basket!', '&nbsp;');
   });
    
   $('input[type="text"]').each(function() {
        $(this).keypress(function(e) {
		    if(e.which==60 || e.which==62){
		        return false;
		    }
         });
        if($(this).val() != '')
            EvaluateBackground($( this )[0]);
    })
    
	if($.fn.qtip){
		$.fn.qtip.styles.maplinTipstyle = { // Last part is the name of the style
			width: 292,
			padding: 5,
			lineheight:1.2,
			background: '#F2F2F2',
			color: 'black',
			textAlign: 'left',
			border: {
					 width: 1,
					 radius: 5,
					 color: '#ed0c6e'
					},
			tip: 'bottomLeft',
			name: 'dark'
		}
		
		$.fn.qtip.styles.maplinTipstyle_left = { 
			width: 292,
			padding: 5,
			lineheight:1.2,
			background: '#F2F2F2',
			color: 'black',
			textAlign: 'left',
			border: {
					 width: 1,
					 radius: 5,
					 color: '#ed0c6e'
					},
			tip: 'bottomRight',
			name: 'dark'
		}
	
		$('.tooltip[title]').qtip({ 
			position: {
					corner: {
							target: 'topRight',
							tooltip: 'bottomLeft'
							}
					},
			style: 'maplinTipstyle' 
			})
		
		$('.tooltip_left[title]').qtip({ 
			position: {
					corner: {
							target: 'topLeft',
							tooltip: 'bottomRight'
							}
					},
			style: 'maplinTipstyle_left' 
			})
	}
		
	$(".more_recently_viewed").hide();
	
	$("#recently_viewed_more").click(function()
	{
	$(".more_recently_viewed").slideToggle(600);
	
	var str = $("p#recently_viewed_more").text();
	
	if(str == 'view less') {     
			 $("p#recently_viewed_more").text('view more');
	}else{
			$("p#recently_viewed_more").text('view less');
	}
	
	});
		
	$("a[rel='module']").colorbox({width:650, height:650});
	$("a[rel='storemap']").colorbox();
    $(".video").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	$(".iframe").colorbox({width:750, height:500, iframe:true});
	$(".jobs").colorbox({width:650, height:600, iframe:true});
	$(".inline").colorbox({inline:true});
});

var forms_hidden=new Array();

function GetFirstNonWhitespaceChild(parent)
{
	var firstChild = parent.firstChild;
	while(firstChild != null && firstChild.nodeType === 3){
		firstChild = firstChild.nextSibling;
	}
	return firstChild;
}
	    
function returnCustomGreeting()
{
	var d=new Date();
	theHour=d.getHours();
	if (theHour > 6 && theHour < 12)
		return "Good morning";
	else if(theHour >= 12 && theHour <= 17)
		return "Good afternoon";
	else if(theHour > 17 && theHour <= 21)
		return "Good evening";
	else
		return "Welcome";
}
		
function EvaluateBackground(control)
{
    if (control.value == '')
        control.style.backgroundImage = '';
    else 
        control.style.backgroundImage = 'none';
}
 
function GetWindowWidth()
{
	var width =
		document.documentElement && document.documentElement.clientWidth ||
		document.body && document.body.clientWidth ||
		document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
		0;
		
	return width;
}
 
function GetWindowHeight()
{
    var height =
		document.documentElement && document.documentElement.clientHeight ||
		document.body && document.body.clientHeight ||
  		document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  		0;
  		
  	return height;
}

function OnWindowResize(div)
{
	var top = document.body.scrollTop
    ? document.body.scrollTop
    : (window.pageYOffset
        ? window.pageYOffset
        : (document.body.parentElement
            ? document.body.parentElement.scrollTop
            : 0
        )
    );
	var left = document.body.scrollLeft
    ? document.body.scrollLeft
    : (window.pageXOffset
        ? window.pageXOffset
        : (document.body.parentElement
            ? document.body.parentElement.scrollLeft
            : 0
        )
    );
	
	div.style.left = Math.max((left + (GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (GetWindowHeight() - div.offsetHeight) / 2), 0) + 'px';
}

	function showForm(div, divWidth, divHeight)
{

	var backgroundDiv = document.getElementById(div);
	var modalDiv = GetFirstNonWhitespaceChild(backgroundDiv);
	modalDiv.style.display = backgroundDiv.style.display = 'block';
	OnWindowResize(modalDiv);
	
	document.getElementById('formoverlay').style.display = 'block';
	
	if (window.attachEvent)
		window.attachEvent('onresize', forms_hidden[div]=function () { OnWindowResize(modalDiv); });
	else if (window.addEventListener)
		window.addEventListener('resize', forms_hidden[div]=function () { OnWindowResize(modalDiv); }, false);
	else
		window.onresize = function () { OnWindowResize(modalDiv); };
}

function closeForm(div)
{
	var backgroundDiv = document.getElementById(div);
	var modalDiv = GetFirstNonWhitespaceChild(backgroundDiv);
	backgroundDiv.style.display = backgroundDiv.style.display = 'none';
	document.getElementById('formoverlay').style.display = 'none';
	
	if (window.detachEvent)
		window.detachEvent('onresize', forms_hidden[div]);
	else if (window.removeEventListener)
		window.removeEventListener('resize', forms_hidden[div], false);
	else
		window.onresize = null;
}
	
function changeBorderOrange2(div)
	{
		document.getElementById(div).style.border="2px solid #f7941d";
	}
	
function changeBorderOrange1(div)
	{
		document.getElementById(div).style.border="1px solid #f7941d";
	}

function changeBorderBlue2(div)
	{
		document.getElementById(div).style.border="2px solid #00bce4";
	}

function changeBorderBlue1(div)
	{
		document.getElementById(div).style.border="1px solid #00bce4";
	}
	
function changeBorderPurple1(div)
	{
		document.getElementById(div).style.border="1px solid #b490c8";
	}

function changeBorderGreen2(div)
	{
		document.getElementById(div).style.border="2px solid #C3CD23";
	}

function backToOrange2(div)
	{
		document.getElementById(div).style.border="2px solid #f7941d";
	}

function backToOrange1(div)
	{
		document.getElementById(div).style.border="1px solid #f7941d";
	}

function backToBlue2(div)
	{
		document.getElementById(div).style.border="2px solid #00bce4";
	}
	
function backToPurple2(div)
	{
		document.getElementById(div).style.border="2px solid #b490c8";
	}

function backToPurple1(div)
	{
		document.getElementById(div).style.border="1px solid #b490c8";
	}

function backToGreen2(div)
	{
		document.getElementById(div).style.border="2px solid #C3CD23";
	}
	
function backToGreen1(div)
	{
		document.getElementById(div).style.border="1px solid #C3CD23";
	}
	
function showDiv(div)
	{
		document.getElementById(div).style.display="";
	}

function closeBox(div)
	{
		document.getElementById(div).style.display="none";
	}

function capLock(e){
    kc = e.keyCode?e.keyCode:e.which;
    sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);
    if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))
    {
        document.getElementById('other_alert').style.display = 'none';
        document.getElementById('caps_on').style.display = '';
    }
    else
    {
        document.getElementById('other_alert').style.display = '';
        document.getElementById('caps_on').style.display = 'none';
    } 
}

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "190";

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');


