// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function writerror(text){
    if (text!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + text + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function checknewsletterform(){
	if (isValidEmail(document.newsletterform.email.value)==false){
		alert('Please enter your Email Address.');
		return false;
	}
	else {
		return true;
	}
}

function clearemailfield(fieldVal){
	if (isValidEmail(fieldVal)==false){
		document.newsletterform.email.value='';
	}
}

function mainmenu(){
	$(" #nav_list ul ").css({display: "none"}); // Opera Fix
	$(" #nav_list li").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(100);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
	}

 $(document).ready(function(){					
	mainmenu()
});

/* Arrow for Racing Page */
function showArrow(prodPos,show){
    if (show){
        document.getElementById("ArrowPOS1_" + prodPos).innerHTML = "<img src='Images/ArrowGraphic.gif' alt='' />";
        document.getElementById("ArrowPOS2_" + prodPos).innerHTML = "<img src='Images/ArrowGraphic.gif' alt='' />";
    }
    else {
        document.getElementById("ArrowPOS1_" + prodPos).innerHTML = "&nbsp;";
        document.getElementById("ArrowPOS2_" + prodPos).innerHTML = "&nbsp;";
    }
}

/* Forms */
function checkhomeform(){
    var ftxt = '';

    if (document.homeform.Name.value==''||document.homeform.Name.value=='Name'){
        ftxt += '\n- Please enter your Name.';
    }
    
    if (document.homeform.Company.value==''||document.homeform.Company.value=='Company'){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.homeform.Telephone.value==''||document.homeform.Telephone.value=='Tel. No.'){
        ftxt += '\n- Please enter your Telephone Number.';
    }
    
    return writerror(ftxt);
}

function checkcontactform(){
    var ftxt = '';

    if (document.contactform.Name.value==''||document.contactform.Name.value=='Name'){
        ftxt += '\n- Please enter your Name.';
    }
    
    if (document.contactform.Company.value==''||document.contactform.Company.value=='Company'){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.contactform.Telephone.value==''||document.contactform.Telephone.value=='Tel. no.'){
        ftxt += '\n- Please enter your Telephone Number.';
    }
    
    if (isValidEmail(document.contactform.email.value)==false){
        ftxt += '\n- Please enter our Email Address.';
    }
    
    return writerror(ftxt);
}

/* PayPal Buy Form */
function checkpaypal(){
    if (document.paypalform.quantity.value==''){
        alert('Please enter a Quantity.');
        return false;
    }
    else {
        return true;
    }
}
