function mainmenu() {
	$(" #nav ul ").css({display: "none"}); // Opera Fix
	$(" #nav li").hover(function(){
			
			//$(this).find('a.niv1').css({color: "#000"});	
			$(this).find('ul:first').css({left: '-8px'});
			
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
			},function(){
			//$(this).find('a.niv1').css({color: "#6e6e70"});
			$(this).find('ul:first').css({visibility: "hidden"});
	});
}

$(document).ready(function(){					
	mainmenu();
	$('input.q').focus(function() {
		$(this).val('');
	});
});

function swf(file, w, h) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'">'+
            '<param name="movie" value="swf/'+file+'.swf" />'+
            '<param name="quality" value="high" />'+
			'<param name="wmode" value="transparent" />'+
            '<embed wmode="transparent" src="swf/'+file+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'"'+ 'height="'+h+'"></embed>'+
	      '</object>');
}

function openPopUp(url, w, h) {
	var iLeft = (screen.width  - w) / 2 ;
	var iTop  = (screen.height - h) / 2 ;
	var sOptions = "toolbar=no,status=no,resizable=no,scrollbars=yes" ;
		sOptions += ",width=" + w ; 
		sOptions += ",height=" + h ;
		sOptions += ",left=" + iLeft ;
		sOptions += ",top=" + iTop ;
		window.open( url, "POPup", sOptions ) ;
}

function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   return IsNumber;
}
function claculer(myForm) {
//	$('#poids_taxable').val("");
	$('#poids_taxable').html("");
	pays = myForm.pays.value;
	longueur = $.trim(myForm.longueur.value);
	largeur = $.trim(myForm.largeur.value);
	hauteur = $.trim(myForm.hauteur.value);
	poids_reel = $.trim(myForm.poids_reel.value);
	coeficient=$.trim(myForm.coeficient.value);
	prestation=$.trim(myForm.prestation.value);
	
	err = '';
	if (pays<0) {
		err += '- Pays obligatoire\n';	
	}
	if (prestation<0) {
		err += '- Prestation obligatoire\n';	
	}
	if (!longueur) {
		err += '- Longueur obligatoire\n';	
	} else if(!IsNumeric(longueur)) {
		err += '- Longueur doit être numérique\n';
	}
	if (!largeur) {
		err += '- Largeur obligatoire\n';	
	} else if(!IsNumeric(largeur)) {
		err += '- Largeur doit être numérique\n';
	}
	if (!hauteur) {
		err += '- Hauteur obligatoire\n';	
	} else if(!IsNumeric(hauteur)) {
		err += 'Hauteur doit être numérique\n';
	}
	if (!poids_reel) {
		err += '- Poids réel obligatoire\n';	
	} else if(!IsNumeric(poids_reel)) {
		err += '- Poids réel doit être numérique\n';
	}
	if (!err) { 
		$.get("scripts/ajax.php", { act: 'calculer', pays: pays, longueur: longueur, largeur: largeur, hauteur: hauteur, poids_reel: poids_reel,coeficient:coeficient },
			function(data){
				//$('#poids_taxable').val(data);
				$('#poids_taxable').html(data);
			}
		);
		
		
	} else {
		alert ('Vérifiez les erreurs ci-dessous:\n' + err);
	}
}

function verifFormContact() {
	T = new Array('textnom', 'textprenom', 'textmail', 'textmailconfirm', 'textmessage');
	v = '';
	for (i=0; i<T.length; i++) {
		if ($.trim(document.form1[T[i]].value) == '') {
			v = T[i];
			break;
		}
	}
	if 	(v == '' ) {
		if (document.form1['textmailconfirm'].value != document.form1['textmail'].value) {
			alert('Veuillez confirmer l\'email!!!');
			document.form1['textmailconfirm'].focus();
			return false;
		}
		return true;
	} else {
		alert("Veuillez remplir les champs nécessaires !!!");
		document.form1[v].focus();
		return false;
	}
	return false;
}
function infosPays(idPays) {
	if (idPays != '') {
		document.form1.idPays.value = idPays;
		document.form1.submit();    			
	} else {
		alert('Choisissez un pays');	
	}
}
