//******************************************************************************************************* // TOGGLE DISPLAY OF A DIV // Toggle the display of a div element function toggleDisplay(divId) { var div = document.getElementById(divId); div.style.display = (div.style.display=="block" ? "none" : "block"); } //******************************************************************************************************* // FADE CONTENT // Slowly make a div disapear! function opacity(id, opacStart, opacEnd, millisec) { //speed for each frame var speed = Math.round(millisec / 100); var timer = 0; //determine the direction for the blending, if start and end are the same nothing happens if(opacStart > opacEnd) { for(i = opacStart; i >= opacEnd; i--) { setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; } } else if(opacStart < opacEnd) { for(i = opacStart; i <= opacEnd; i++) { setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; } } } //change the opacity for different browsers function changeOpac(opacity, id) { var object = document.getElementById(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; if(opacity == 0) { fl = document.getElementById(id); fl.style.display = "none"; } } //******************************************************************************************************* // UPDATE ITEM // This function gets called when a user updates the quantity of an item in their cart function UpdateQty(item) { itemId = item.name; newQty = item.options[item.selectedIndex].text; document.location.href = '/koodooecommerce.co.uk/my_cart/update/'+itemId+'/'+newQty+'/'; } //******************************************************************************************************* // Validate the register form function validate_frm_register() { valid = true; if ( document.frm_register.FirstName.value == "" ) { alert ( "Please fill in the 'Your Name' box." ); document.frm_register.FirstName.focus(); return false; } else if ( document.frm_register.SecondName.value == "" ) { alert ( "Please fill in the 'Your Second Name' box." ); document.frm_register.SecondName.focus(); return false; } else if ( document.frm_register.Email.value == "" ) { alert ( "Please fill in the 'Your Email' box." ); document.frm_register.Email.focus(); return false; } else if ( echeck(document.frm_register.Email.value) == false ) { document.frm_register.Email.focus(); return false; } else if ( document.frm_register.Tel.value == "" ) { alert ( "Please fill in the 'Your Telephone Number' box." ); document.frm_register.Tel.focus(); return false; } else if ( document.frm_register.Address1.value == "" ) { alert ( "Please fill in the 'Your Address Line 1' box." ); document.frm_register.Address1.focus(); return false; } else if ( document.frm_register.Address2.value == "" ) { alert ( "Please fill in the 'Your Address Line 2' box." ); document.frm_register.Address2.focus(); return false; } else if ( document.frm_register.City.value == "" ) { alert ( "Please fill in the 'Your City' box." ); document.frm_register.City.focus(); return false; } else if ( document.frm_register.Postcode.value == "" ) { alert ( "Please fill in the 'Your Postcode' box." ); document.frm_register.Postcode.focus(); return false; } else if ( document.frm_register.Password.value != document.frm_register.Password2.value ) { alert ( "Your passwords do not match, please check you have entrered them correctly." ); document.frm_register.Password.focus(); return false; } else if ( document.frm_register.ReadTerms.checked == false ) { alert ( "Please check the tick box to confirm you have read and agree to our terms and conditions." ); document.frm_register.ReadTerms.focus(); return false; } return valid; } //******************************************************************************************************* // CHECK DELETE // Toggle the display of a div element function deleteCheck(myMessage) { result=confirm(myMessage); if (result==true) { return true; //window.location = 'section_delete.php' } else { return false; } } //******************************************************************************************************* // CHECK if real email function echeck(str) { var message = "Please make sure you enter a valid email address."; var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert(message) return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert(message) return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert(message) return false } if (str.indexOf(at,(lat+1))!=-1){ alert(message) return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert(message) return false } if (str.indexOf(dot,(lat+2))==-1){ alert(message) return false } if (str.indexOf(" ")!=-1){ alert(message) return false } return true } function alertMessage(myMessage) { alert (myMessage); return false; }