function showForm(){
	window.document.getElementById('terugvoer').style.visibility = 'visible';
}
function hideForm(){
    window.document.getElementById('terugvoer').style.visibility = 'hidden';
}
        
function showForm2(){
    window.document.getElementById('bestellater').style.visibility = 'visible';
}

function hideForm2(){
    window.document.getElementById('bestellater').style.visibility = 'hidden';
}

function showSub(theVis){
	eval("document.getElementById('"+theVis+"')").style.display='block';
}

function hideSub(theVis){
	eval("document.getElementById('"+theVis+"').style.display='none'");
}

function doMenu(){
	var noRows = form_num.num_row1.value;
	for (x = 1; x <= noRows; x++){
		if(eval("window.document.getElementById('link_"+x+"')")){
			var theElement = eval("window.document.getElementById('link_"+x+"')")
			var browserName=navigator.appName; 
			if (browserName=="Netscape"){ 
				//alert("Hi Netscape User!");
				theElement.style.left = "116px";
			}
			else if (browserName=="Microsoft Internet Explorer"){
				theElement.style.left = "114px";
			}
		}
	}
}

function changeImageOver(theImage, theNewImage){
    window.document.getElementById(theImage).src='images/'+theNewImage+'.gif';
}
function changeImageOut(theImage, theNewImage){
    window.document.getElementById(theImage).src='images/'+theNewImage+'.gif';
}

if (document.images){
  preload_image = new Image(109, 44);
  preload_image.src='images/shopa2_1.gif';
  preload_image = new Image(109, 44);
  preload_image.src='images/shopa2_2.gif';  
}

function addProduct(element, dropon, event) {
    sendData(element.id);
}
function showContent() {
    var url    = 'cart.php';
    var rand   = Math.random(9999);
    var pars   = 'product_id=0&rand=' + rand;
    var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
}
function sendData (prod) {
  //alert('U boek is in die mandjie geplaas. Klik op "Bestel nou" om alle boeke in u mandjie te sien.');        
    var url    = 'cart.php';
    var rand   = Math.random(9999);
    var pars   = 'product_id=' + prod;
    var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
    setTimeout("sessionCart()",1000);
}       
function clearCart () {
    var url    = 'cart.php';
    var rand   = Math.random(9999);
    var pars   = 'clear=true&rand=' + rand;
    var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
    setTimeout("sessionCart()",1000);
}
function clearProduct (id) {
    var url    = 'cart.php';
    var rand   = Math.random(9999);
    var pars   = 'clearProduct=true&id=' + id + '&rand=' + rand;
    var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
    setTimeout("sessionCart()",1000);
}               
function showResponse (originalRequest) {
    $('loading').style.display = "none";
    $('clearCart').style.display = "block";
    $('cart').innerHTML = originalRequest.responseText;
}
function showLoad () {
    $('clearCart').style.display = "none";
    $('loading').style.display = "block";
}

function sessionCart(){
    window.document.getElementById('session_cart').src = 'session_cart.php';    
}

function openOrder(){
    document.location=('Mandjie.php?menu=mandjie');
}

/*
function showForm(){
	window.document.getElementById('terugvoer').style.visibility = 'visible';
}
function hideForm(){
	window.document.getElementById('terugvoer').style.visibility = 'hidden';
}

function showForm2(){
	window.document.getElementById('bestellater').style.visibility = 'visible';
}
function hideForm2(){
	window.document.getElementById('bestellater').style.visibility = 'hidden';
}	
*/	

function showReview(theNum){
	window.document.getElementById('resensie_'+theNum).style.visibility = 'visible';
}
function hideReview(theNum){
	window.document.getElementById('theTop').focus();
	window.document.getElementById('resensie_'+theNum).style.visibility = 'hidden';
}		

function textCounter(){
	if (document.form1.comment.value.length > 255){
		document.form1.comment.value = document.form1.comment.value.substring(0, 255);
	}
	else {
		document.form1.remLen_comment.value = 255 - document.form1.comment.value.length;
		document.form1.remLen_comment.value = ' '+document.form1.remLen_comment.value;
	}
}
				
function validateForm(alertName, alertSurname, alertComment, alertGrade){
	if(document.form1.firstname.value == ''){
	alert(alertName);
		document.form1.firstname.focus();
		return false;
	}
	if(document.form1.surname.value == ''){
		alert(alertSurname);
		document.form1.surname.focus();
		return false;
	}
	if(document.form1.comment.value == ''){
		alert(alertComment);
		document.form1.comment.focus();
		return false;
	}
	if(document.form1.rating[0].checked == false && document.form1.rating[1].checked == false && document.form1.rating[2].checked == false && document.form1.rating[3].checked == false && document.form1.rating[4].checked == false){
    	alert(alertGrade);
    	return false;
    }
}

function validateForm2(alertName, alertSurname, alertEmail, alertPhoneCell, alertPostal){
	if(window.document.bestel_later_vorm.Naam.value == ''){
		alert(alertName);
		document.bestel_later_vorm.Naam.focus();
		return false;
	}
	if(document.bestel_later_vorm.Van.value == ''){
		alert(alertSurname);
		document.bestel_later_vorm.Van.focus();
		return false;
	}
	if(document.bestel_later_vorm.Epos.value == ''){
		alert(alertEmail);
		document.bestel_later_vorm.Epos.focus();
		return false;
	}
	if(document.bestel_later_vorm.Tel.value == '' && document.bestel_later_vorm.Selfoon.value == ''){
		alert(alertPhoneCell);
		document.bestel_later_vorm.Tel.focus();
		return false;
	}
	if(document.bestel_later_vorm.Posadres.value == ''){
		alert(alertPostal);
		document.bestel_later_vorm.Posadres.focus(); 
		return false;
	}
	bestel_later_vorm.email.value = bestel_later_vorm.Epos.value;
}


function showImage(theId, type, category){
	if (type == 'Voorblad' && category == 8){
		var newWindow = window.open('BoekPrente.php?the_id='+theId+'&type=Voorblad&newWidth=400','newWindow','top=0px,left=0px,height=500px,width=400px,scrollbars,resizable');
	}
	if (type == 'Voorblad' && category != 8){
		var newWindow = window.open('BoekPrente.php?the_id='+theId+'&type=Voorblad&newWidth=300','newWindow','top=0px,left=0px,height=500px,width=400px,scrollbars,resizable');
	} 
	else if (type == 'Binne'){
		var newWindow = window.open('BoekPrente.php?the_id='+theId+'&type=Binne','newWindow','top=0px,left=0px,height=500px,width=650px,scrollbars,resizable');
	}
}

function validateFormOrder(alertName, alertEmail, alertPhone, alertPostal, alertPostalCode){
	if(document.bestel_vorm.Naam.value == ''){
		alert(alertName);
		document.bestel_vorm.Naam.focus();
		return false;
	}
	if(document.bestel_vorm.Epos.value == ''){
		alert(alertEmail);
		document.bestel_vorm.Epos.focus();
		return false;
	}
	if(document.bestel_vorm.Selfoon.value == '' && document.bestel_vorm.Landlyn.value == ''){
		alert(alertPhone);
		document.bestel_vorm.Landlyn.focus();
		return false;
	}
	if(document.bestel_vorm.Posadres.value == ''){
		alert(alertPostal);
		document.bestel_vorm.Posadres.focus();
		return false;
	}
	if(document.bestel_vorm.Poskode.value == ''){
		alert(alertPostalCode);
		document.bestel_vorm.Poskode.focus();
		return false;
	}		
	else {		
		document.bestel_vorm.email.value = document.bestel_vorm.Epos.value;
	}
}

function validateFormOrderE(alertName, alertEmail, alertPhone, alertPostal, alertPostalCode, vReference){
	if(bestel_vorm.txtRecipient.value == ''){
		alert(alertName);
		bestel_vorm.txtRecipient.focus();
		return false;
	}
	if(bestel_vorm.txtShippingAddress2.value == ''){
		alert(alertEmail);
		bestel_vorm.txtShippingAddress2.focus();
		return false;
	}
	if(bestel_vorm.txtShippingAddress4.value == '' && bestel_vorm.txtShippingAddress3.value == ''){
		alert(alertPhone);
		bestel_vorm.txtShippingAddress3.focus();
		return false;
	}
	if(bestel_vorm.txtShippingAddress1.value == ''){
		alert(alertPostal);
		bestel_vorm.txtShippingAddress1.focus();
		return false;
	}
	if(bestel_vorm.txtShippingAddress5.value == ''){
		alert(alertPostalCode);
		bestel_vorm.txtShippingAddress5.focus();
		return false;
	}	

	//alert('http://graffitiboeke.co.za/KoopBoekeBevestigE.php?reference='+vReference+'&name='+document.bestel_vorm.txtRecipient.value+'&boeke='+document.bestel_vorm.Boeke.value+'&email='+document.bestel_vorm.txtShippingAddress2.value+'&postal='+document.bestel_vorm.txtShippingCost.value+'&total_price='+document.bestel_vorm.txtPrice.value+'&message='+document.bestel_vorm.txtItemDescr.value+'&postal_address='+document.bestel_vorm.txtShippingAddress1.value+', '+document.bestel_vorm.txtShippingAddress5.value);
	document.bestel_vorm.txtRedirectSuccessfulURL.value = 'http://www.graffitibooks.co.za/KoopBoekeBevestigE.php?reference='+vReference+'&name='+document.bestel_vorm.txtRecipient.value+'&boeke='+document.bestel_vorm.Boeke.value+'&email='+document.bestel_vorm.txtShippingAddress2.value+'&postal='+document.bestel_vorm.txtShippingCost.value+'&total_price='+document.bestel_vorm.txtPrice.value+'&message='+document.bestel_vorm.txtItemDescr.value+'&postal_address='+document.bestel_vorm.txtShippingAddress1.value+', '+document.bestel_vorm.txtShippingAddress5.value;

	if(bestel_vorm.txtShippingAddress1.value != ''){
		bestel_vorm.txtShippingAddress1.value = 'Postal address: '+bestel_vorm.txtShippingAddress1.value;
	}
	if(bestel_vorm.txtShippingAddress5.value != ''){
		bestel_vorm.txtShippingAddress5.value = 'Postal code: '+bestel_vorm.txtShippingAddress5.value;
	}	
	if(bestel_vorm.txtShippingAddress2.value != ''){
	//"bestel_vorm.txtConfirmationEmail1.value = bestel_vorm.txtShippingAddress2.value;"	
		bestel_vorm.txtShippingAddress2.value = 'Email: '+bestel_vorm.txtShippingAddress2.value;
	}
	if(bestel_vorm.txtShippingAddress3.value != ''){
		bestel_vorm.txtShippingAddress3.value = 'Phone no: '+bestel_vorm.txtShippingAddress3.value;
	}
	if(bestel_vorm.txtShippingAddress4.value != ''){
		bestel_vorm.txtShippingAddress4.value = 'Cellphone no: '+bestel_vorm.txtShippingAddress4.value;
	}
	if(bestel_vorm.txtItemDescr.value != ''){
		bestel_vorm.txtItemDescr.value = 'Message: '+bestel_vorm.txtItemDescr.value;
	}	
}

