// script ouverture pop-up

var popup ;
function openPopup(url,largeur,hauteur){
	gauche=(screen.width-largeur)/2;
	haut=(screen.height-hauteur)/2;
	if (popup && !popup.closed) {popup.close();}
	popup=window.open(url,"Nutriose","scrollbars=yes,status=no,width="+largeur+",height="+hauteur+",top="+haut+",left="+gauche);	
}



//Insert Flash
function insertSWF ( movieURL, strParams, width, height ) {
	var strHTML	;
	var transparency = ""	;
	if ( arguments[4] ) transparency = arguments[4]	;
	strHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
			+ ' CODEBASE="/dior/cab/swflash.cab#version=6,0,2,0" '
			+ ' WIDTH="'+width+'" HEIGHT="'+height+'">'
			+ '<PARAM name=movie VALUE="'+movieURL+'?'+strParams+'">'
			+ '<PARAM NAME=FlashVars VALUE="'+strParams+'" />'	;
	if ( transparency != "noTransparancy" ) strHTML+=    '<PARAM name=wmode VALUE=transparent />'	;
	strHTML+= '<PARAM name=quality VALUE=high />'
			+ '<embed src="'+movieURL+'?'+strParams+'" quality=high '
			+ '    wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" '
			+ '    type="application/x-shockwave-flash" width="'+width+'" height="'+height+'">'
			+ '</embed>' 
			+ '</OBJECT>'	;
	if ( arguments[4] == "getTag" ) return strHTML	;
	else document.write ( strHTML )	;
}

function subTopics(string, string2, topic1, topic2)
{
	if(topic1 == topic2)
	{
		document.write('<li class="on"><a href="'+string+'">'+string2+'</a></li>');
	}
	else
	{
		document.write('<li><a href="'+string+'">'+string2+'</a></li>');
	}

}

function subArticles(string, string2, article1, article2)
{
	if(article1 == article2)
	{
		document.write('<li class="on"><a href="'+string+'">'+string2+'</a></li>');
	}
	else
	{
		document.write('<li><a href="'+string+'">'+string2+'</a></li>');
	}

}

var popup;
function openPopupAdvert (url,largeur,hauteur,pict){
	gauche=(screen.width-largeur)/2;haut=(screen.height-hauteur)/2;
	if (popup && !popup.closed) {popup.close();};
	popup = window.open(url+"?pict=" + escape ( pict ),'geWindow','scrollbars=yes,status=no,width='+largeur+',height='+hauteur+',top='+haut+',left='+gauche);
}

var popup;
function openPopupRessource (url,largeur,hauteur,ressource_id){
	gauche=(screen.width-largeur)/2;haut=(screen.height-hauteur)/2;
	if (popup && !popup.closed) {popup.close();};
	popup = window.open(url+"ressource_id-" + escape ( ressource_id ) + "/",'geWindow','scrollbars=yes,status=no,width='+largeur+',height='+hauteur+',top='+haut+',left='+gauche);
}

function placePopup()
{
	var cont = document.getElementById('popup_contener');
	if(cont !== null)
	{
		cont.style.top = document.body.scrollTop+100+'px';
	}
}

function checkContactForm(form){
  if(form.sel3.value != "" && form.lastname.value != "" && form.email.value != "" && form.country.value != "" && form.phone.value != "" && form.secu.value != "") {
    return true;
  } else {
    alert("Please indicates required fields");
    return false;
  }
}

function checkSubscribeForm(form){
	if(form.lastname.value != "" && form.email.value != "" && form.country.value != "" && form.phone.value != ""
  	 && form.subject.value && form.company.value != "" && form.secu.value != ""
  	 ) {
  		var regEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   		if (regEmail.test(form.email.value)){
   			return true;
   		}
   		else {
   			alert("Please check the mail you enter !");
    		return false;
   		}
  	} 
  	else {
    	alert("Please indicates all required fields");
    	return false;
  	}
}

function checkSampleForm(form){
  if(form.lastname.value != "" && form.email.value != "" && form.country.value != "" && form.phone.value != "" && form.secu.value != "") {
    return true;
  } else {
    alert("Please indicates required fields");
    return false;
  }
}

function checkMailTo(value){
	switch(value ){
		case "Pharmaceutics Applications" :
		document.getElementById('nutriose_contact_to').value = "pharma.business.unit@roquette.com";
		break;
		case "Health-Nutrition" :
		document.getElementById('nutriose_contact_to').value = "foodbusiness@roquette.com";
		break;
		case "Legal" :
		document.getElementById('nutriose_contact_to').value = "foodbusiness@roquette.com";
		break;
		case "Other" :
		document.getElementById('nutriose_contact_to').value = "foodbusiness@roquette.com";
		break;
		case "Food Applications" :
		document.getElementById('nutriose_contact_to').value = "foodbusiness@roquette.com";
		break;
	}
}


function checkMailToSample(){
	mailto = "";
	if (document.getElementById('bread').checked == true || document.getElementById('snacks').checked == true || document.getElementById('beverage').checked == true || document.getElementById('snacks').checked == true || document.getElementById('confec').checked == true || document.getElementById('fruit').checked == true || document.getElementById('ice').checked == true || document.getElementById('dairy').checked == true || document.getElementById('sauces').checked == true || document.getElementById('other').checked == true ){
	mailto = "foodbusiness@roquette.com";
	}
	if (document.getElementById('nutrition').checked == true || document.getElementById('formulation').checked == true){
		if (mailto != ""){
			mailto += ";";
			mailto += "pharma.business.unit@roquette.com";
		}
	}
	document.getElementById('nutriose_sample_to').value= mailto;
}