$(document).ready(function(){
    $('ul#submenu li:first').addClass('first');
    $('ul#submenu li:last').addClass('last');
    $("div#errorMessage1").hide();
    $("div#errorMessage2").hide();

});

function orderForm_submit() {
	var errorType = 0;
 	if ((document.orderForm.f_Name.value == 'Ваше имя' || !document.orderForm.f_Name.value) && (document.orderForm.f_Email.value == 'E-mail' || !document.orderForm.f_Email.value) && (document.orderForm.f_Tel.value == 'Телефон' || !document.orderForm.f_Tel.value) && (document.orderForm.f_Company.value == 'Компания' || !document.orderForm.f_Company.value)) errorType=1;
	if (document.orderForm.f_Email.value && document.orderForm.f_Email.value!='E-mail' && !(/\w+@\w+\.[a-zA-Z]{2,4}/.test(document.orderForm.f_Email.value))) errorType = 2;
	if (errorType) {
	       $("div#errorMessage"+(errorType==1 ? 2 : 1)).fadeOut(100);
		if ($("div#errorMessage"+errorType).is(":hidden")) { 
 			$("div#errorMessage"+errorType).slideDown("slow");
 		} else {
 			$("div#errorMessage"+errorType).fadeOut(100);
 			$("div#errorMessage"+errorType).fadeIn(100);
 		}
	} else {
	 	if (document.orderForm.f_Name.value == 'Ваше имя') document.orderForm.f_Name.value='';
	 	if (document.orderForm.f_Email.value == 'E-mail') document.orderForm.f_Email.value='';
	 	if (document.orderForm.f_Tel.value == 'Телефон') document.orderForm.f_Tel.value='';
	 	if (document.orderForm.f_Company.value == 'Компания') document.orderForm.f_Company.value='';
		document.orderForm.submit();
	}
}

function wopen(pageURL, pageName, width, height) {
   window.open(pageURL, pageName, 'width='+width+',height='+height+',top=0,left=0,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

