function popup(url,width,height,name){
	if (width == '' || width == null) width = 400;
	if (height == ''|| height == null) height = 425;
	if (name == '' || name == null) name = "details";
	var props ="toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,width="+width+",height="+height;w = window.open(url, name, props);
	if (w) w.focus();
}
/* fucntion validate the lenght of the Security code on Order  Summary page */
function validateSecurityCode(){
var securityfield;
var selectedcard ;
	if(document.getElementById("orderconfirmation")){
			securityfield = document.wizform.ohcccsc;
			cardtype = document.wizform.cardtype;
			securityfield.onblur=function() {
					selectedcard = document.wizform.cardtype.value;
					securityfieldval = document.wizform.ohcccsc.value;
					if((selectedcard!="mastercard") && ((securityfieldval.length)>3)){
						alert("Please enter the valid security code on the card.");
						document.wizform.ohcccsc.focus();
					}
					else if((selectedcard=="mastercard") && ((securityfieldval.length)<4)){
						alert("Please enter the valid security code on the card.");
						document.wizform.ohcccsc.focus();
					}
			}
			cardtype.onchange=function(){
					selectedcard = document.wizform.cardtype.value;
					securityfieldval = document.wizform.ohcccsc.value;
					if((selectedcard!="mastercard") && ((securityfieldval.length)>3)){
						alert("Please enter the valid security code on the card.");
						document.wizform.ohcccsc.focus();
					}
					else if((selectedcard=="mastercard") && ((securityfieldval.length)<4)){
						alert("Please enter the valid security code on the card.");
						document.wizform.ohcccsc.focus();
					}
			}

	}
}


//order confirmation and order receipt page - split the email address on the RHN if too long
function splitEmailAdd(usemail) {
	var stringlist = new Array();
	while (usemail.length > 150) {
	   stringlist.push( usemail.slice(0,50));
	   usemail=usemail.substr(50);
	}
	if (usemail.length) {
	  stringlist.push(usemail);
	}
	document.write(stringlist.join( '<br>' ));
}

function getObjectByCaptureIdandTagName(id, tagName) {
            var obj;
            if (document.getElementById(id)) {
                        if (document.getElementById(id).getElementsByTagName(tagName)) {
                                    obj = document.getElementById(id).getElementsByTagName(tagName)
                        }
            }
            return obj;
}

function displaySwapColor(id, class1, class2) {
            var trObj = getObjectByCaptureIdandTagName(id, "tr");
            if (trObj) {
                        for (i = 0; i < trObj.length; i++) {
                                    if (i % 2 == 1) {
										if (trObj[i].className == "") {
                                                trObj[i].className  = class1;
										} else {
                                                trObj[i].className  = trObj[i].className + " " + class1;										
										}
                                    } else {
										if (trObj[i].className == "") {
                                                trObj[i].className  = class2;
										} else {
                                                trObj[i].className  = trObj[i].className + " " + class2;
										}
                                    }
                        }
            }
}
function LoadingPage() {
		displaySwapColor("yourbasket", 'bk-row-one', 'bk-row-two');
}



function initMenu() {
if (document.getElementById("rpmenulist")) {
rpMenu = document.getElementById("rpmenulist")
rpMenuLabels = rpMenu.childNodes;

for ( i = 0; i < rpMenuLabels.length-1; i++ ) {
if (rpMenuLabels[i].childNodes.length > 2) {
thisLabel = rpMenuLabels[i];
thisLabel2 = thisLabel.id + "menulink";
eval("menuName" + i + "= thisLabel.id + \"menu\"");
eval("thisLabel.onmouseover = function(){showDdMenu(menuName" + i + ",'yes')}");
eval("thisLabel.onmouseout = function(){hideDdMenu(menuName" + i + ",'yes')}");
}
}
}
// document.getElementById('termtextkeywordsearch').onfocus = function(){advSearch('show')};
}

function showDdMenu(rpmenuID,hidesearch) {
menuToShow = document.getElementById(rpmenuID);
menuToShow.style.display = 'block';
if (hidesearch == 'yes') {
// document.getElementById('rpadvopts').style.display = 'none';
}
}

function hideDdMenu(rpmenuID,hidesearch) {
menuToShow = document.getElementById(rpmenuID);
menuToShow.style.display = 'none';
if (hidesearch == 'yes') {
// document.getElementById('rpadvopts').style.display = 'block';
}
}





function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



function switchpage(select) {
    var index;

  for(index=0; index < select.options.length; index++)
    if(select.options[index].selected)
      {
        if(select.options[index].value!="")
          window.location.href=select.options[index].value;
        break;
      }
} 



function showHelp(divid) {
document.getElementById(divid).style.display = 'block';
}

function hideHelp(divid) {
document.getElementById(divid).style.display = 'none';
}

//Description: Returns the value of a specified URL parameter 
//Parameters:
//1. currURL = this is the URL which you wish to get the URL parameter value from
//2. urlParam = this is the name of the URL parameter you want to get the value for
//Returns: value for parameter specified urlParam.
function grabURL(currURL,urlParam) {
//find out a value where is passed from current url
var url = unescape(currURL);
var spliter = '&';
var sField = spliter+urlParam+'=';

if (url.search(sField) == -1) { 
sField = '?'+urlParam+'='; 
}

var urlArray = url.split(sField);
if (urlArray[1]) {
//get url param value
var paramArray = urlArray[1].split(spliter);
return(paramArray[0]);
}
}

function addOnloadEvent(fnc) {
    if ( typeof window.addEventListener != "undefined" )
        window.addEventListener( "load", fnc, false );
    else if ( typeof window.attachEvent != "undefined" ) {
        window.attachEvent( "onload", fnc );
    }
    else {
         if ( window.onload != null ) {
         var oldOnload = window.onload;
            window.onload = function ( e ) {
            oldOnload( e );
            window[fnc]();
            };
        }
        else
            window.onload = fnc;
    }
}




toDay = new Date();
rpHours = toDay.getHours();
rpMinutes = toDay.getMinutes();
rpDay = toDay.getDay();

day = new Array()
day[0] = 'Sunday'
day[1] = 'Monday'
day[2] = 'Tuesday'
day[3] = 'Wednesday'
day[4] = 'Thursday'
day[5] = 'Friday'
day[6] = 'Saturday'

rpHoursLeft = 16 - rpHours;
rpMinsLeft = 59 - rpMinutes;

function writeTimeLeft() {
if(rpHours < 17) {
document.write('<p>You\'ve got ');
if(rpHoursLeft > 0) {
document.write(rpHoursLeft+' hour');
if(rpHoursLeft > 1) {
document.write('s');
}
document.write(' and ');
}
if(rpMinsLeft > 0) {
document.write(rpMinsLeft+' minute');
}
if(rpMinsLeft > 1) {
document.write('s');
}
document.write(' left!</p>');
}

}

function calcDay() {
if ((rpDay == 4 && rpHours >= 17) || (rpDay == 5 && rpHours < 17) ) {
return 4; // Saturday
} else if  ((rpDay != 0 && rpDay != 6) && rpHours < 17) {
return 1; // Tomrrow
} else if ((rpDay != 0 && rpDay != 5 && rpDay != 6) && rpHours >= 17) {
return 2; // day after tomorrow
} else {
return 3; //tuesday
}
}

function writePromo() {

if (calcDay() == 1) {
document.write('<p><strong>Order before 5pm for delivery tomorrow*</strong></p>')
} else if (calcDay() == 2) {
document.write('<p><strong>Order now for ' + day[rpDay + 2] + ' delivery*</strong></p>')
} else if (calcDay() == 3) {
document.write('<p><strong>Order now for Tuesday delivery*</strong></p>')
} else if (calcDay() == 4) {
document.write('<p><strong>Order now for Saturday delivery at no extra charge*</strong></p>')
}

document.write('<p class="terms">*')
document.write('Most UK mainland addresses (<a href="/page/postagedelivery">full details here</a>). ')
/* document.write('FREE for orders over £100, ')
document.write('&pound;2.99 for orders over £50, and ')
document.write('&pound;4.50 for orders under £50. ')
document.write('Select \'Express\' delivery at the checkout. ')*/
document.write('</p>')
}


function showPanel(panelname) {

if (panelname == "details") {
document.getElementById("rp_atts").style.display = 'block';
document.getElementById("rp_del").style.display = 'none';
document.getElementById("rp_ret").style.display = 'none';
document.getElementById("dettab").setAttribute("class", "tabSelected"); 
document.getElementById("dettab").setAttribute("className", "tabSelected"); 
document.getElementById("deltab").setAttribute("class", "tabUnSelected"); 
document.getElementById("deltab").setAttribute("className", "tabUnSelected"); 
document.getElementById("rettab").setAttribute("class", "tabUnSelected"); 
document.getElementById("rettab").setAttribute("className", "tabUnSelected");
} else if (panelname == "delivery")  {
document.getElementById("rp_atts").style.display = 'none';
document.getElementById("rp_del").style.display = 'block';
document.getElementById("rp_ret").style.display = 'none';
document.getElementById("deltab").setAttribute("class", "tabSelected"); 
document.getElementById("deltab").setAttribute("className", "tabSelected"); 
document.getElementById("dettab").setAttribute("class", "tabUnSelected"); 
document.getElementById("dettab").setAttribute("className", "tabUnSelected"); 
document.getElementById("rettab").setAttribute("class", "tabUnSelected"); 
document.getElementById("rettab").setAttribute("className", "tabUnSelected");
} else {
document.getElementById("rp_atts").style.display = 'none';
document.getElementById("rp_del").style.display = 'none';
document.getElementById("rp_ret").style.display = 'block';
document.getElementById("deltab").setAttribute("class", "tabUnSelected"); 
document.getElementById("deltab").setAttribute("className", "tabUnSelected"); 
document.getElementById("dettab").setAttribute("class", "tabUnSelected"); 
document.getElementById("dettab").setAttribute("className", "tabUnSelected"); 
document.getElementById("rettab").setAttribute("class", "tabSelected"); 
document.getElementById("rettab").setAttribute("className", "tabSelected"); 
}

}







  

  
  function initTopFive() {
  if (document.getElementById('topfive')) {
  topFive = document.getElementById('topfive');
  topFive = topFive.getElementsByTagName('li');
  for (i=0; i < topFive.length; i++) {
  thisLabel = topFive[i];
  eval("thisLabel.onmouseover = function(){ document.getElementById('topprods').scrollTop =  '" + i*176 + "'}");
  }
  }
  }
  
  
  
  $(document).ready(function() {
 

 initMenu();
  
  
  
  
var cookieTest = readCookie('freemsg')
if (!cookieTest) {
    $("div#freebanner").show().fadeIn("slow");
   $("#closebanner").click(function() {
     $("div#freebanner").slideUp("fast");
     createCookie('freemsg','yes',30);
   });
}



 });
  
  


  addOnloadEvent(LoadingPage);
  
 








