function ValidateForm(theform)
{
		if(theform.name.value=='') {
		alert('Please enter your Name')
		theform.name.focus()
		return false
	}

		if(theform.contact.value=='') {
		alert('Please enter your Contact Number')
		theform.contact.focus()
		return false
	}

		if(theform.email.value=='') {
		alert('Please enter your Email address')
		theform.email.focus()
		return false
	}

		if(theform.email.value!='') {
			if(emailValidator(theform.email)==false) {
			alert('The Email address is not valid. Please enter a valid Email address')
			theform.email.focus()
			return false
		}
	}
	
		if(theform.enquiry.value=='') {
		alert('Please enter your enquiries')
		theform.enquiry.focus()
		return false
	}
	
	return true
}


function ValidateForm1(theform)
{
		if(theform.name.value=='' && theform.email.value=='' && theform.discount_code.value=='') {
		alert('Please enter your Name or Email Address or Discount Code')
		theform.email.focus()
		return false
	}
	return true
}

function ValidateForm2(theform)
{
		if(theform.name.value=='') {
		alert('Please enter your Name')
		theform.name.focus()
		return false
	}

		if(theform.address.value=='') {
		alert('Please enter your Address')
		theform.address.focus()
		return false
	}

		if(theform.email.value=='') {
		alert('Please enter your Email address')
		theform.email.focus()
		return false
	}

		if(theform.email.value!='') {
			if(emailValidator(theform.email)==false) {
			alert('The Email address is not valid. Please enter a valid Email address')
			theform.email.focus()
			return false
		}
			if(theform.email_chk.value=='1') {
			alert('Please use a different email address')
			theform.email.focus()
			return false
		}

	}
	
		if(theform.discount_chk.value!='') {
			if(theform.discount_chk.value=='1') {
			alert('Invalid discount code')
			theform.discount_code.focus()
			return false
		}
	}
		
		if(theform.contact_num.value=='') {
		alert('Please enter your Contact Number')
		theform.contact_num.focus()
		return false
	}

	return true
}

function ValidateForm3(theform)
{
		if(theform.attnto.value=='') {
		alert('Please enter person\'s name receiving goods.')
		theform.attnto.focus()
		return false
	}

		if(theform.ship_address.value=='') {
		alert('Please enter the shipping address')
		theform.ship_address.focus()
		return false
	}

		if(theform.contact_num.value=='') {
		alert('Please enter the Contact Number')
		theform.contact_num.focus()
		return false
	}
	return true
}


function Validateorder(theform)
{
	var form=document.forms['theform'];
	var length=form.length;
	for (var i=0; i<length; i++)
 	{
    	if (form.elements[i])
    	{
			//Check object here...
			if (form.elements[i].selectedIndex == '0')
			{
			//	form.elements[i].selectedIndex == '1'
			//	var opt = explode('::', form.elements[i].select.value);
			//	var opt_type = opt[0];
			//	var type_val = opt[1];
				alert('You must '+form.elements[i].value);
				form.elements[i].focus()
				return false
			}
    	}
 	}
	return true
}

function ValidateSpread(theform)
{
		if(theform.name.value=='') {
		alert('Please enter your Name')
		theform.name.focus()
		return false
	}

		if(theform.email.value=='') {
		alert('Please enter your Email address')
		theform.email.focus()
		return false
	}

		if(theform.email.value!='') {
			if(emailValidator(theform.email)==false) {
			alert('The Email address is not valid. Please enter a valid Email address')
			theform.email.focus()
			return false
		}
	}
	
		if(theform.email_to.value=='') {
		alert('Please enter the email address of your friends')
		theform.email_to.focus()
		return false
	}
	return true
}


function emailValidator(elem){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,10}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		return false;
	}
}

function explode( delimiter, string, limit ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}
