	/**
	 *
	 * @access public
	 * @return void
	 **/
	function calculateTotal(index){
		var p 	= 'document.order_form.price_'+index+'.value';
		var price = eval(p);
		var qty 	= eval('document.order_form.qty_'+index+'.value');
		total 	= price * qty;
		document.getElementById('total').innerHTML = total.toFixed(2);
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function voidx(){

	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function SelectRow(index){
		document.getElementById('row_'+index).style.background ='#E0E0E0';
		document.getElementById('qty_'+index).style.display='inline-block';
		document.order_form.selectedRow.value = index;

		for(i=1;i<=7;i++){
			if (i != index) {
				if (document.getElementById('row_'+i)) {
					document.getElementById('row_'+i).style.background = '#FFFFFF';
					document.getElementById('qty_'+i).style.display='none';
				}

			}
		}
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function calculateTotal(index){
		var p 	= 'document.order_form.price_'+index+'.value';
		var price = eval(p);
		var x	= 'document.order_form.qty_'+index+'.value';
		var qty 	= eval(x);
		var total;
		total 		= price * qty;
		document.getElementById('total').innerHTML = total.toFixed(2);
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function calcTotal(){
		var p 	= 'document.order_form.price.value';
		var price = eval(p);
		var qty 	= eval('document.order_form.qty.value');
		total 		= price * qty;
		document.getElementById('total').innerHTML = total.toFixed(2);
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function checkDetail(){
		var er=0;
		if(document.order_form.consistency.value==''){
			document.getElementById('consistency').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.order_form.fat_content.value==''){
			document.getElementById('fat_content').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.order_form.sliced_or_whole.value==''){
			document.getElementById('sliced_or_whole').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.order_form.selectedRow.value==''){
			er=1;
		}

		if(er){
			alert('Attention! Please specify the attributes!');
			return false;
		}
		return true;

	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function checkDetail2(){
		var er=0;
		if(document.order_form.over.checked!=1){
			document.getElementById('over').style.border='1px solid #ff0000';
			er=1;
		}

		if(er){
			alert('Attention! You must be over 16!');
			return false;
		}
		return true;

	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function checkContact(){
		var er=0;
		if(document.contactForm.name.value==''){
			document.getElementById('name').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.email.value==''){
			document.getElementById('email').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.telephone.value==''){
			document.getElementById('telephone').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.enquiry_type.value==''){
			document.getElementById('enquiry_type').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.subject_title.value==''){
			document.getElementById('subject_title').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.message.value==''){
			document.getElementById('message').style.border='1px solid #ff0000';
			er=1;
		}
		if(document.contactForm.captcha.value==''){
			document.getElementById('captcha').style.border='1px solid #ff0000';
			er=1;
		}


		if(er){
			alert('Attention! All field with * are mandatory!');
			return false;
		}
		return true;

	}

	function cap(){
			document.contactForm.captcha.style.borderColor='red';
	}

	function setCheckedValue(radioObj, newValue) {

		if(!radioObj)
			return;
		var radioLength = radioObj.length;

		if(radioLength == undefined) {
			radioObj.checked = (radioObj.value == newValue.toString());
			return;
		}
		for(var i = 0; i < radioLength; i++) {
			radioObj[i].checked = false;
			if(radioObj[i].value == newValue.toString()) {
				radioObj[i].checked = true;
			}
		}
	}


	/**
	 *
	 * @access public
	 * @return void
	 **/
	function getSaving(option){
		if (option == 'delivery') {
			document.getElementById('freeDelivery').style.background='#E0E0E0';
			document.getElementById('deliveryLabel').style.color='#008B48';
			document.getElementById('optionFreeDelivery').style.display='block';
			setCheckedValue(document.shoppingCart.saving, 'delivery');

			document.getElementById('voucherCode').style.background='#FFFFFF';
			document.getElementById('voucherLabel').style.color='#8BC6AA';
			document.getElementById('optionVoucher').style.display='none';
		}else{
			document.getElementById('freeDelivery').style.background='#FFFFFF';
			document.getElementById('deliveryLabel').style.color='#8BC6AA';
			document.getElementById('optionFreeDelivery').style.display='none';
			setCheckedValue(document.shoppingCart.saving, 'voucher');

			document.getElementById('voucherCode').style.background='#E0E0E0';
			document.getElementById('voucherLabel').style.color='#008B48';
			document.getElementById('optionVoucher').style.display='block';
		}
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function CheckVoucherField(){

		if(document.shoppingCart.voucher_code.value == '')
		{
			alert('Please add your voucher!');
			return 0;
		}
		else
		return 1;

	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function validateNewsletterSubscription(){

		var er=0,email=0;

		if(document.newsletterForm.email.value == '' || document.newsletterForm.email.value == 'Email address')
		{
			document.getElementById('email').style.border='1px solid #FF0000';
			er 	  = 1;
		}else
			document.getElementById('email').style.border='1px solid #D4D4D4';

		if(er){
			alert('Attention! Please fill in all fields!');
			document.getElementById('email').style.border='1px solid #FF0000';
			return 0;
		}

		email = document.newsletterForm.email.value
		AtPos = email.indexOf("@")
		StopPos = email.lastIndexOf(".")

		if (AtPos == -1 || StopPos == -1) {
			alert("Not a valid email address!");
			document.getElementById('email').style.border='red';
			return 0;
		}



		return 1;
	}


	function updateNewsletter(){
	var returnValue = true;

	email_address = encodeURI(document.newsletterForm.email.value);

	$.ajax({
	   type: "GET",
	   url: "http://demo.thinkingjuice.co.uk/smarty-train/ajax/subscribeToNewsletter.php",
	   data: "email="+email_address,
	   async: false,
	   success: function(msg){
	     	if(msg == "successful"){
				document.getElementById('tyMsgElm').style.display='block';
				document.getElementById('newsletterForm').style.display='none';
				returnValue =  true;
				return;
			}else{
				alert('This email already in use!');
				returnValue =  false;
				return;
			}
	   },
	   error:
            function(errorThrown) {
                //alert("Error occured: " + errorThrown);
            }
	 });


	 return returnValue;
	}

function voidx(){
	return;
}

//mot's form
function doToggle() {
	$(".formMot").slideDown("slow");
	$(".enquiry").removeClass("enquiry_open");
	$(".enquiry").addClass("enquiry_close");
	$('.show_form').css('display','none');
	$('#thanks').css('display','none');
	return false;
}

$(document).ready(function() {
	$('.enquiry_open').click(function() {
		doToggle();
	});
});
/**
 *
 * @access public
 * @return void
 **/

function pad(n){
    return (n < 10) ? '0' + n : n;
}


function updateClock(){

    /*var now = new Date();
    var s = (pad(now.getUTCHours()))+ ':' +
            pad(now.getUTCMinutes())+ ':' +
            pad(now.getUTCSeconds());*/

    var currentTime = new Date ( );

  	var currentHours = currentTime.getHours ( );
  	var currentMinutes = currentTime.getMinutes ( );
  	var currentSeconds = currentTime.getSeconds ( );

  	// Pad the minutes and seconds with leading zeros, if required
  	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  	// Choose either "AM" or "PM" as appropriate
  	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  	// Convert the hours component to 12-hour format if needed
  	currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  	// Convert an hours component of "0" to "12"
  	currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  	// Compose the string for display
  	var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;




/*	if ( ((pad(now.getUTCHours())) >= 7) && (pad(now.getUTCMinutes())>=1) && ((pad(now.getUTCHours())) <= 8)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html('Smarty bird catches the worm.');
	}
	if ( ((pad(now.getUTCHours())+1) >= 9) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 9)&&(pad(now.getUTCMinutes())<=30) ) {
		jQuery('#clockMsg').html('Good morning Smarty folk.');
	}
	if ( ((pad(now.getUTCHours())+1) >= 9) && (pad(now.getUTCMinutes())>=31) && ((pad(now.getUTCHours())+1) <= 10)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html('Now, do you take milk and sugar?');
	}
	if ( ((pad(now.getUTCHours())+1) >= 11) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 11)&&(pad(now.getUTCMinutes())<=30) ) {
		jQuery('#clockMsg').html("Elevenses - we'll stick the kettle on.");
	}
	if ( ((pad(now.getUTCHours())+1) >= 11) && (pad(now.getUTCMinutes())>=31) && ((pad(now.getUTCHours())+1) <= 11)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Nearly lunch time - Saj is having bread.");
	}
	if ( ((pad(now.getUTCHours())+1) >= 12) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 14)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Ahh, stop for lunch.");
	}
	if ( ((pad(now.getUTCHours())+1) >= 14) && (pad(now.getUTCMinutes())>=1) && ((pad(now.getUTCHours())+1) <= 14)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Did you have anything nice for lunch?");
	}
	if ( ((pad(now.getUTCHours())+1) >= 15) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 16)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Still thinking about lunch?");
	}
	if ( ((pad(now.getUTCHours())+1) >= 16) && (pad(now.getUTCMinutes())>=1) && ((pad(now.getUTCHours())+1) <= 16)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Stop watching the clock, concentrate!");
	}
	if ( ((pad(now.getUTCHours())+1) >= 17) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 17)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Nearly home time.");
	}
	if ( ((pad(now.getUTCHours())+1) >= 18) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 19)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Working late? Can help with?");
	}
	if ( ((pad(now.getUTCHours())+1) >= 20) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 21)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("What's this - homework?");
	}
	if ( ((pad(now.getUTCHours())+1) >= 22) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 4)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Time for Smarty sleep, good night x");
	}
	if ( ((pad(now.getUTCHours())+1) >= 5) && (pad(now.getUTCMinutes())>=0) && ((pad(now.getUTCHours())+1) <= 6)&&(pad(now.getUTCMinutes())<=59) ) {
		jQuery('#clockMsg').html("Be sure to eat a hearty breakfast");
	}
*/

	jQuery('#clock').html(currentTimeString);



    var delay = 1000 - (currentTime % 1000);
    setTimeout(updateClock, delay);
}

function calcTime(city, offset) {

    // create Date object for current location
    d = new Date();

    // convert to msec
    // add local time zone offset
    // get UTC time in msec
    utc = d.getTime() + (d.getTimezoneOffset() * 60000);

    // create new Date object for different city
    // using supplied offset
    nd = new Date(utc + (3600000*offset));

    // return time as a string
	var list = nd.toLocaleString();
	list1	= list.split(" ");
	return '<li class="time">nearly home time <b>'+list1[4]+list1[5]+'</b></li>';
}

function validatePasswordChange(){
	var pass 		= document.changePasswordForm.passw.value;
	var conf_pass 	= document.changePasswordForm.conf_passw.value;

	if(pass != conf_pass){
		alert('Password and Confirm password fields doesn\'t match!');
		return 0;
	}
	return 1;
}

