// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkenquiry(){
	var ftxt = '';

	if (document.enquiry.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiry.Company.value==''){
		ftxt += '\n- Please enter your Company.';
	}
	
	if (document.enquiry.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.enquiry.email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiry.subject.value==''){
		ftxt += '\n- Please select an enquiry Subject.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function changeTextSize(size){
      var sitetext = document.getElementById('wrapper');  
      sitetext.style.fontSize = size + '%'; 
      createCookie('ipwfontsize',size,1)
}

function clearemailfield(fieldVal){
	if (isValidEmail(fieldVal)==false){
		document.newsletterform.email.value='';
	}
}

function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function mainmenu(){
	$(" #navlist ul ").css({display: "none"}); // Opera Fix
	$(" #navlist li").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(0);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
	}

 $(document).ready(function(){					
	mainmenu()
});
 
$(document).ready(function(){
	
	

});

/* Home Quick Enquiry */
function checkQuickEnquiry() {
    var ftxt = '';

    if (document.homecontact.Name.value == '' || document.homecontact.Name.value == 'Name') {
        ftxt += '\n- Please enter your Name.';
    }

    if (isValidEmail(document.homecontact.Email.value) == false) {
        ftxt += '\n- Please enter your Email Address.';
    }

    if (document.homecontact.Enquiry.value == '' || document.homecontact.Enquiry.value == 'Enquiry') {
        ftxt += '\n- Please enter your Enquiry.';
    }

    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }
}

/* Media Search */
function checkMediaSearch() {
    var ftxt = '';

    if (document.mediaform.Criteria.value == '' || document.mediaform.Criteria.value == 'Search...') {
        ftxt += '\n- Please enter your Search Criteria.';
    }

    var x = false;
    for (var i = 0; i < 2; i++) {
        if (document.mediaform.SearchBy[i].checked) {
            x = true;
        }
    }
    if (x == false) {
        ftxt += '\n- Please select a Search Option.';
    }

    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }
}
