if (top.frames.length!=0) {
    if (window.location.href.replace)
        top.location.replace(self.location.href);
    else
        top.location.href=self.document.href;
}

function ConfirmChoice(url,msg) { 
	answer = confirm(msg)
	
	if (answer !=0) { 
		location = url 
	} 
}


function checkChange() {
	if(document.getElementById('ActionButtonChange')) {

	} else {
		document.form.submit()
	}
}

function movein(which,html){
	document.getElementById(which).innerHTML=html
}
	
function moveout(which,html){
	document.getElementById(which).innerHTML=html
}

function imgin(which,value){
	document.getElementById(which).src=value
}

function cataddtoqty(theid,chkid) {

	if (isNaN(document.getElementById(theid).value)) {
		document.getElementById(theid).value = 1;
	}

	document.getElementById(theid).value++;
	
	if (document.getElementById(theid).value > 0) {
		document.getElementById(chkid).checked = true;
	}
 
	show_add_basket();
 
}

function catminusfromqty(theid,chkid) {

	if (isNaN(document.getElementById(theid).value)) {
		document.getElementById(theid).value = 2;
	}

	if (document.getElementById(theid).value > 0) {
		document.getElementById(theid).value--;
	}

	if (document.getElementById(theid).value < 1) {
		document.getElementById(chkid).checked = false;
	}
}


function addtoqtyifzero(theid,chkid) {

	if (chkid.checked == true) {
		if (document.getElementById(theid).value < 1) {
			document.getElementById(theid).value++;
		}
	}  else {
		if (document.getElementById(theid).value > 0) {
			document.getElementById(theid).value = 0;
		}
	}
show_add_basket();
	 
}


function addtoqty(theid) {

 if (isNaN(document.getElementById(theid).value)) {
 document.getElementById(theid).value = 1;
 }
    
 document.getElementById(theid).value++;
 
}

function minusfromqty(theid) {
 if (isNaN(document.getElementById(theid).value)) {
 document.getElementById(theid).value = 2;
 }

 if (document.getElementById(theid).value > 0) {
 document.getElementById(theid).value--;

 }
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
}


function doSubmit() {
 
    if ((document.getElementById('tyre_speed').value == "") || (document.getElementById('tyre_size').value == "") || (document.getElementById('tyre_profile').value == "") || (document.getElementById('tyre_width').value == "")) {
	alert('Make sure you narrow your search before you submit the form.');
    } else {
	$('#tyre_form').submit();
    }
  
}

var add_basket = false;

function show_add_basket() {
    add_basket = true
    if (add_basket == true) {
	document.getElementById('add_basket').style.display = 'block';
    }
    
    
}
