function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { 
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { 
if (form.btnContinueOrder == true)
{
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
  }
}

function getEl(id) {
	// Helper to reduce typing
	return document.getElementById(id);
}

function checkPromotionCode(src, arg) {
	var i = getEl("txtPromotionCode").value.length;
	if (i != 0) {
		arg.IsValid = (i >= 10 && i <=15);
	} else {
		arg.IsValid = true;
	}
}

function checkSortCode1(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode1").value;	
	arg.IsValid = (sSortCode.length == 2);
}

function checkSortCode2(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode2").value;
	arg.IsValid = (sSortCode.length == 2);
}

function checkSortCode3(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode3").value;
	arg.IsValid = (sSortCode.length == 2);
}

function checkSecurityCode(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SecurityCode").value;
	arg.IsValid = (sSortCode.length > 2);
}

function checkFirstNameLength(src, arg) {
	var sName = getEl("CheckOut:PersonalDetailsTemplate_FirstName").value;
	arg.IsValid = (sName.length > 1);
}

function checkLastNameLength(src, arg) {
	var sName = getEl("CheckOut:PersonalDetailsTemplate_LastName").value;
	arg.IsValid = (sName.length > 1);
}

function checkEmails(src, arg) {
	if (getEl("txtEmail").value.length != 0 && getEl("txtEmailConfirm").value.length != 0) {
		arg.IsValid = getEl("txtEmail").value == getEl("txtEmailConfirm").value;
	} else {
		arg.IsValid = true;
	}
}

function popup(url, windowName, width, height, top, left) {
	remote = window.open(url, windowName, "resizable=yes,toolbar=0,location=0,directories=0,status=no,menubar=0,scrollbars=1,copyhistory=0,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",screeny=" + top + ",screenx=" + left);
}

function checkTandC(src, arg)
{
	arg.IsValid = getEl("chkTerms").checked;
}

function isNumeric(str) {
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len) {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function checkDOB(src, arg) {
	var day = getEl("Checkout:PersonalDetailsTemplate_DOB_Day").value;
	var month = getEl("Checkout:PersonalDetailsTemplate_DOB_Month").value;
	var year = getEl("Checkout:PersonalDetailsTemplate_DOB_Year").value;
	
	if( (day.length < 1 || day.length > 2 || ! isNumeric(day) ) ||
		(month.length < 1 || month.length > 2 || ! isNumeric(month) ) ||
		(year.length < 1 || year.length > 2 || ! isNumeric(year) ) ) {
			arg.IsValid = false;
	}
	else {
		arg.IsValid = true;
	}		
}

function checkTimeWithEmployer(src, arg) {
	var months = getEl("Checkout:PersonalDetailsTemplate_MonthsWithEmployer").value;
	var years = getEl("Checkout:PersonalDetailsTemplate_YearsWithEmployer").value;
	
	if( (months.length < 1 || months.length > 2 || ! isNumeric(months) ) ||
		(years.length < 1 || years.length > 2 || ! isNumeric(years) ) ) {
			arg.IsValid = false;
	}
	else {
		arg.IsValid = true;
	}		
}

function changeImage(layer,imgName,imgObj) {
	if (document.layers && layer!=null) {
		eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
	}
	else {
		document.images[imgName].src = eval(imgObj+".src");
	}
}

function checkInsuranceTermsAndConditions(src, arg) {
	arg.IsValid = document.forms[0].hid.value == 1;
}

function setChecked(checked) {
	if (checked) {
		document.forms[0].hid.value = 1; 
	} else {
		document.forms[0].hid.value = 0;
	}
}

function clickButton(e){
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13){
        document.getElementById('searchBar_searchButton').click();
        return false;
    }
    return true;
}

function clickButton(e, button){
    var intKey = (window.Event) ? e.which : e.keyCode;
    if (intKey == 13){
        document.getElementById(button).click();
        return false;
    }
    return true;
}

// move the navigation
function roll(pos_y, id){
    var move = document.getElementById(id).style.backgroundPosition="0px " + pos_y + "px" ;	
    return move;
}

// general jquery 
$(document).ready(function(){ 
    $(".rounded").corner("bl tr");
});

// expanding my account section + jquery integration 

// my account area show
$(document).ready(function(){
    $(".btnMyAccountShow").click(function () {
        if($("#myAccountAreaWrapper").is(":visible"))
            $("#myAccountAreaWrapper").hide("slow");
        else
            $("#myAccountAreaWrapper").show("slow");
        
    });
});

// my account area hide
$(document).ready(function(){
    $("#btnMyAccountHide").click(function () {
        $("#myAccountAreaWrapper").hide("slow");
    });
});
    
// faqs section 
jQuery().ready(function(){
    jQuery("#faqsList").Accordion({
	    event: "click",
	    active: false, 
        alwaysOpen: false, 
        animated: false, 
        autoheight: false 

    
    });
    
});
    
$(document).ready(function(){
	$("select#country").change(function () {
		var str = "";
		$("select#country option:selected").each(function () {
			str = $(this).parent().attr("value");
		});
		
		for(i=0;i<10;i++){
		div = "#cost_option_"+i;
			$(div).hide();
		}

		div = "#cost_option_"+str;
		$(div).show();
	}).change();
});

function popup(url, windowName, width, height, top, left) {
	remote = window.open(url, windowName, "resizable=yes,toolbar=0,location=0,directories=0,status=no,menubar=0,scrollbars=1,copyhistory=0,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",screeny=" + top + ",screenx=" + left);
}


/*

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}


function MM_findObj(n, d) { 
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { 
if (form.btnContinueOrder == true)
{
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
  }
}

function getEl(id) {
	// Helper to reduce typing
	return document.getElementById(id);
}

function checkPromotionCode(src, arg) {
	var i = getEl("txtPromotionCode").value.length;
	if (i != 0) {
		arg.IsValid = (i >= 10 && i <=15);
	} else {
		arg.IsValid = true;
	}
}

function checkSortCode1(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode1").value;	
	arg.IsValid = (sSortCode.length == 2);
}

function checkSortCode2(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode2").value;
	arg.IsValid = (sSortCode.length == 2);
}

function checkSortCode3(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SortCode3").value;
	arg.IsValid = (sSortCode.length == 2);
}

function checkSecurityCode(src, arg) {
	var sSortCode = getEl("CheckOut:CardPaymentDetailsTemplate_SecurityCode").value;
	arg.IsValid = (sSortCode.length > 2);
}

function checkFirstNameLength(src, arg) {
	var sName = getEl("CheckOut:PersonalDetailsTemplate_FirstName").value;
	arg.IsValid = (sName.length > 1);
}

function checkLastNameLength(src, arg) {
	var sName = getEl("CheckOut:PersonalDetailsTemplate_LastName").value;
	arg.IsValid = (sName.length > 1);
}

function checkEmails(src, arg) {
	if (getEl("txtEmail").value.length != 0 && getEl("txtEmailConfirm").value.length != 0) {
		arg.IsValid = getEl("txtEmail").value == getEl("txtEmailConfirm").value;
	} else {
		arg.IsValid = true;
	}
}



function checkTandC(src, arg)
{
	arg.IsValid = getEl("chkTerms").checked;
}

function isNumeric(str) {
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len) {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function checkDOB(src, arg) {
	var day = getEl("Checkout:PersonalDetailsTemplate_DOB_Day").value;
	var month = getEl("Checkout:PersonalDetailsTemplate_DOB_Month").value;
	var year = getEl("Checkout:PersonalDetailsTemplate_DOB_Year").value;
	
	if( (day.length < 1 || day.length > 2 || ! isNumeric(day) ) ||
		(month.length < 1 || month.length > 2 || ! isNumeric(month) ) ||
		(year.length < 1 || year.length > 2 || ! isNumeric(year) ) ) {
			arg.IsValid = false;
	}
	else {
		arg.IsValid = true;
	}		
}

function checkTimeWithEmployer(src, arg) {
	var months = getEl("Checkout:PersonalDetailsTemplate_MonthsWithEmployer").value;
	var years = getEl("Checkout:PersonalDetailsTemplate_YearsWithEmployer").value;
	
	if( (months.length < 1 || months.length > 2 || ! isNumeric(months) ) ||
		(years.length < 1 || years.length > 2 || ! isNumeric(years) ) ) {
			arg.IsValid = false;
	}
	else {
		arg.IsValid = true;
	}		
}

function changeImage(layer,imgName,imgObj) {
	if (document.layers && layer!=null) {
		eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
	}
	else {
		document.images[imgName].src = eval(imgObj+".src");
	}
}

function checkInsuranceTermsAndConditions(src, arg) {
	arg.IsValid = document.forms[0].hid.value == 1;
}

function setChecked(checked) {
	if (checked) {
		document.forms[0].hid.value = 1; 
	} else {
		document.forms[0].hid.value = 0;
	}
}


function clickButton(e)
{
    var intKey = (window.Event) ? e.which : e.keyCode;

    if (intKey == 13)
    {
        document.getElementById('searchBar_searchButton').click();
        return false;
    }

    return true;

}

// move the navigation

    function roll(pos_y, id){
        var move = document.getElementById(id).style.backgroundPosition="0px " + pos_y + "px" ;	
        return move;
    }
    
 */