<!--

var BROWSER_IE4 = "IE4"
var BROWSER_NN4 = "NN4"
var BROWSER_IE = "IE"
var BROWSER_VER;

if (document.layers) { // Netscape
//    document.captureEvents(Event.MOUSEMOVE);
//    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    //document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    //document.onmousemove = captureMousePosition;
}
// Global variables
everythingLoaded=false //sets up variable used for JavaScript within the website
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page



function OpenWindow(PageName,PageFrame,PageProperties) { //v2.0
  PageProperties= PageProperties +',scrollbars=1,resizable=1'
  var MyWindow = window.open (PageName,PageFrame,PageProperties);
  
}

function hideTable(tableToHide){
//alert(tableToHide)
if (document.all){
prefix = "document.all";}
else if (document.layers){
prefix = "document.layers";}
holder = eval(prefix)
if (prefix == "document.all"){
holder[tableToHide].style.visibility = 'hidden';}
else if (prefix == "document.layers"){
holder[tableToHide].visibility = 'hidden';}
}

function showTable(tableToShow){

if (document.all){
prefix = "document.all";}
else if (document.layers){
prefix = "document.layers";}
holder = eval(prefix)
if (prefix == "document.all"){
holder[tableToShow].style.visibility = 'visible';}
else if (prefix == "document.layers"){
holder[tableToShow].visibility = 'visible';}
//alert(holder[tableToShow].visibility );
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Paraspar's Preload Image Function //
function preloadImage(imageFile)
// The idea behind this is that we can preload all the images
// into an array, we can then circulate through the array at a later
// stage in order to find the specific image we want and load it from
// the array.

{
	if (document.images) {
	// Only run if document.images is supported

		if (document.imageArray==null) document.imageArray = new Array();
		//If the array does not exist, create it.
		
		var arrayLength = document.imageArray.length;
		// Calculate the current length of the array so we can add to it.
		
		document.imageArray[arrayLength] = imageFile;
		document.imageArray[arrayLength + 1] = new Image();
		document.imageArray[arrayLength + 1].src = imageFile; 
		// The even integer part of the array adds the image name
		// The odd integer part of the array adds the image object
		// (i.e. preloads the image into memory).

	}
}



function swapImage(imageName,imageFile)
{
//alert(imageName)
	var swapImageName = eval('document.' + imageName);
	swapImageName.src = imageFile;
	// Replaces the current image with a selected image
	// The images are already preloaded, and therefore can be swapped
	// without reference to the array.
}

function getTop(item){
var top =0;
var mywhere;
mywhere = getMyHTMLElement(item);
	while (mywhere.tagName.toLowerCase() != 'body')
	{
	top += mywhere.offsetTop;
	mywhere = mywhere.offsetParent;
	}
return top;
}

function getLeft(item){
var left =0;
var mywhere;
mywhere = getMyHTMLElement(item);
	while (mywhere.tagName.toLowerCase() != 'body')
	{
	left += mywhere.offsetLeft;
	mywhere = mywhere.offsetParent;
	}
return left;
}



function showIconsTable(tableToShow,position,leftPos,topPos){

if (document.all){
prefix = "document.all";}
else if (document.layers){
prefix = "document.layers";}
holder = eval(prefix)
//alert(holder[tableToShow].style.top);

if (prefix == "document.all"){
holder[tableToShow].style.top = getTop(position) + 10;
holder[tableToShow].style.left = getLeft(position) + 15;
}
else if (prefix == "document.layers"){
holder[tableToShow].top = topPos;
holder[tableToShow].left = leftPos + 5;
}
showTable(tableToShow)
}

function printPage(){
window.print()
}



function showTableMousePosition(tableToShow,position){
	if (document.all){
		prefix = "document.all";}
	else if (document.layers){
		prefix = "document.layers";}
	holder = eval(prefix)

	if (prefix == "document.all"){
		holder[tableToShow].style.top = yMousePos;
		holder[tableToShow].style.left = xMousePos; 
	}
	else if (prefix == "document.layers"){
		holder[tableToShow].top = yMousePos;
		holder[tableToShow].left = xMousePos;
	}
	showTable(tableToShow)
}



function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    //} else if (document.all) {
        //xMousePos = window.event.x+document.body.scrollLeft;
        //yMousePos = window.event.y+document.body.scrollTop;
        //xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        //yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

function LTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}
function RTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}
function Trim(str)
{
   return RTrim(LTrim(str));
}

function checkBrowser() {
var BROWSER_VER;
  if (document.all && !document.getElementById) 
	BROWSER_VER = BROWSER_IE4
  else if (document.layers) 
	BROWSER_VER = BROWSER_NN4
  else if (document.getElementById) 
	BROWSER_VER = BROWSER_IE
  else 
	BROWSER_VER = BROWSER_IE
   return(BROWSER_VER)
}

function getMyHTMLElement(sid)
{
	var oelement;
	BROWSER_VER = checkBrowser()	
	if(BROWSER_VER==BROWSER_IE4)
		oelement = document.all[sid]
	else if(BROWSER_VER==BROWSER_NN4)
		oelement = document.layers[sid]
	else if(BROWSER_VER==BROWSER_IE)
		oelement = document.getElementById(sid)
	else
		oelement = document.getElementById(sid)
	return(oelement)
}


function limittext(field, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
}

function replaceString(aSearch, aFind, aReplace)
    {
    result = aSearch;
    if (result != null && result.length > 0)
        {
        a = 0;
        b = 0;
        while (true)
            {
            a = result.indexOf(aFind, b);
            if (a != -1)
                {
                result = result.substring(0, a) + aReplace + result.substring(a + aFind.length);
                b = a + aReplace.length;
            }
            else
            break;
        }
    }
    return result;
}


function showDisplayTable(tableToShow){
	getMyHTMLElement(tableToShow).style.display=''
}

function hideDisplayTable(tableToHide){
	getMyHTMLElement(tableToHide).style.display='none'
}


var value = 0;
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function printPage(){window.print()}

var lastThis;
var lastThisInnerHTML;


function imAddingByID(idname)
{
  var objName = document.getElementById(idname)  
  imAdding(objName)
      
}

function imAdding(thisObject){
lastThis = thisObject;
lastThisInnerHTML = thisObject.innerHTML;
thisObject.innerHTML = '<img border="0" src="/images/core/ajaxloader.gif">'

//alert(lastThisInnerHTML)

}

function ajaxAddToBasket(pageName,divID){
    ajaxGET(pageName,divID)
    //scroll to top
  //  scroll(0,0);
}

function ajaxGET(pageName,divID){
    currentHeight = 0
    var xmlhttp=false;
    try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) {xmlhttp = false;}  }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp=false;}}
    if (!xmlhttp && window.createRequest) {try {xmlhttp = window.createRequest();} catch (e) {xmlhttp=false;}}
    
    xmlhttp.open("GET", pageName, true); xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2005 00:00:00 GMT");
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
                getMyHTMLElement(divID).innerHTML = xmlhttp.responseText;
                if (divID=="ajaxBasket"){
                getMyHTMLElement('ajaxProductAdded').style.display=''
                fadeTimer = setTimeout("hideDisplayTable('ajaxProductAdded')",4000)
                lastThis.innerHTML = lastThisInnerHTML;
                
                if (getMyHTMLElement("basketOnLeftNav") != null) { 
                    getMyHTMLElement("basketOnLeftNav").innerHTML = getMyHTMLElement('ajaxBasketOnLeftNav').innerHTML;
                    }
                
                
                }
                  scroll(0,0);
            }
        }
    xmlhttp.send(null)
}

function showPopup(link){
    getMyHTMLElement('overlayContent').innerHTML = ''
    getMyHTMLElement('overlayBox').style.display='';
    getMyHTMLElement('overlayBox').style.width=document.body.clientWidth+ "px";
    getMyHTMLElement('overlayBox').style.height=document.body.clientHeight+ "px";

    ajaxGET('/fadein.asp?article_id=' + link,'overlayContent')
    //getMyHTMLElement('overlayContent').innerHTML = getMyHTMLElement(link).innerHTML;
    
    if (window.sidebar){fadeTimer = setTimeout("MOZ()",1)}
    else{
    if (document.all){fadeTimer = setTimeout("IE()",1)}
        else{fadeTimer = setTimeout("MOZ()",1)}
    }

}

function hidePopup(link){
    getMyHTMLElement('overlayContent').style.display='none';
    getMyHTMLElement('overlayBox').style.display='none';

     if ( getMyHTMLElement('storePopup')!=null)
     {
        getMyHTMLElement('storePopup').style.display='none';
      
     }

    if (window.sidebar){document.getElementById("overlayBox").style.MozOpacity=0;}
    if (document.all){document.getElementById("overlayBox").filters[0].opacity=0;}
    value = 0;
    //fadeTimer = "";
    }
function IE(){
    if (value < 70){
        value = value + 10
        document.getElementById("overlayBox").filters[0].opacity=value 
        fadeTimer = setTimeout("IE()",1)
    }
    else{
    getMyHTMLElement('overlayContent').style.top = ((parent.document.body.offsetHeight - 800) /2) + document.documentElement.scrollTop;
	getMyHTMLElement('overlayContent').style.left = (parent.document.body.offsetWidth - 400) /2
    getMyHTMLElement('overlayContent').style.display='';
    
    //end timeout
    }
}
function MOZ(){
    if (value < 70){
        value = value + 10
        getMyHTMLElement("overlayBox").style.MozOpacity=value/100
	getMyHTMLElement("overlayBox").style.opacity  = value/100  ;
	getMyHTMLElement("overlayBox").style.KhtmlOpacity = value/100 ;

        fadeTimer = setTimeout("MOZ()",1)
    }
    else{
    getMyHTMLElement('overlayContent').style.top = '40%'
	getMyHTMLElement('overlayContent').style.left = '40%'
    getMyHTMLElement('overlayContent').style.display='';
    //end timeout
    }
}
function changeQty(objName,mathematics){
	place = eval( objName + '.qty')
	place.value = parseInt(place.value) + parseInt(mathematics);
	
	if (place.value < 1)
	{
		place.value = 1;
	}
	if (isNaN(place.value))
	{
		place.value = 1;
	}
}
function replaceString(aSearch, aFind, aReplace)
{
	result = aSearch;
	if (result != null && result.length > 0)
		{
		a = 0;
		b = 0;
		while (true)
			{
			a = result.indexOf(aFind, b);
			if (a != -1)
				{
				result = result.substring(0, a) + aReplace + result.substring(a + aFind.length);
				b = a + aReplace.length;
			}
			else
			break;
		}
	}
	return result;
}

//07-11-2007 change country div tian
tranp=null;
function show_country()
{
    clearTimeout(tranp);
    getMyHTMLElement("change_country").style.display= "block";
    getMyHTMLElement("change_country").style.left=  getMyHTMLElement("div_country").offsetLeft+398+"px";
    getMyHTMLElement("change_country").style.top=  getMyHTMLElement("div_country").offsetTop+ 40+"px";
}

function change_position()
{    
    getMyHTMLElement("change_country").style.left=  getMyHTMLElement("div_country").offsetLeft+398+"px";
    getMyHTMLElement("change_country").style.top=  getMyHTMLElement("div_country").offsetTop+ 40+"px";
}
function pre_hide()
{
    tranp=setTimeout("hide_country()",2000);
}

function hide_country()
{
   
    getMyHTMLElement("change_country").style.display= "none";
}

function cancel_tran()
{
   
    clearTimeout(tranp);
}

function swap_flags(a,b) //a=img  b=type
{
    imgsrc="/images/UK_flag";
    if(a==2) {imgsrc="/images/US_flag"}
     getMyHTMLElement("flag"+a).src=imgsrc+ b+ ".jpg";
    
}

//REM -- Additional Saturday Delivery Changes (#151490) - Murali Kanduri - 17/11/2009 - START
function repopulate_saturday_dates(ship_index, min_sat_date)

{
    var i;
    var validDates = new Array();
    var max_days = 31;
    var date_ctrl = document.getElementById('shipmentdate_2_' + ship_index + '_DD');
    var month_ctrl = document.getElementById('shipmentdate_2_' + ship_index + '_MM');
    var year_ctrl = document.getElementById('shipmentdate_2_' + ship_index + '_YY');
    var selected_date = new Date();
    var today = new Date();
    var str_sat_date = min_sat_date;
    var new_sat_date = new Date();
    var sat_date_array = str_sat_date.split("/")      

    var check_for_min_date = false;

    new_sat_date.setUTCDate(parseInt(sat_date_array[0]));
    new_sat_date.setUTCMonth(parseInt(sat_date_array[1]-1));
    new_sat_date.setUTCFullYear(parseInt(sat_date_array[2]));
    
    
    month_sel = parseInt(month_ctrl.selectedIndex);
    // form selected date from user input
    selected_date.setUTCDate(parseInt(date_ctrl.options[date_ctrl.selectedIndex].value));
    selected_date.setUTCMonth(month_sel);
    selected_date.setUTCFullYear(parseInt(year_ctrl.options[year_ctrl.selectedIndex].value));

    if( (selected_date.getMonth() < new_sat_date.getMonth() && selected_date.getYear() == new_sat_date.getYear()) || (selected_date.getDate() < new_sat_date.getDate() && selected_date.getMonth() == new_sat_date.getMonth() && selected_date.getYear() == new_sat_date.getYear()) )
    {
        setSelectedIndex(month_ctrl,new_sat_date.getMonth()+1);
        setSelectedIndex(date_ctrl,new_sat_date.getDate());
        selected_date = new_sat_date;    
        check_for_min_date = true;
    }
    var sel_month = selected_date.getMonth();

    if (sel_month == 0 || sel_month == 2 || sel_month == 4 || sel_month == 6 || sel_month == 7 || sel_month == 9 || sel_month == 11)
        {max_days = 31}
    else if(sel_month == 1)
    {
        max_days = 28;
        if (selected_date.getFullYear() % 4 == 0) {max_days = 29}
    }
    else {max_days = 30}

    
    // change the date drop down values to the date selected by customer. 

    vdIndex = 0;
    var start_index = 1;
    // make sure dropdown will not show any dates previous to minimum saturday date possible
    if (check_for_min_date == true){start_index = new_sat_date.getDate();}
    date_ctrl.options.length = 0;   
    for (i=start_index;i<=max_days;i++)
    {
        selected_date.setUTCDate(i);
        if (selected_date.getDay() == 6)
        {
            var add_date = true;
            
            if (selected_date.getMonth() == new_sat_date.getMonth() && selected_date.getYear() == new_sat_date.getYear())
            {
                if (i < new_sat_date.getDate()){add_date = false;}                
            }
            var value_to_add;
            if (i<10){value_to_add = '0'+i;}
            else{value_to_add = i;}
            
            if (add_date == true) {date_ctrl.options[date_ctrl.options.length] = new Option(value_to_add,value_to_add)}
        }
    }        
}

function setSelectedIndex(ddcontrol, value) 
{
    for ( var i = 0; i < ddcontrol.options.length; i++ ) 
    {
        if ( ddcontrol.options[i].value == value ) 
        {
            ddcontrol.options[i].selected = true;
            return;
        }
    }
}  

//REM -- Additional Saturday Delivery Changes (#151490) - Murali Kanduri - 17/11/2009 - END

//-->

