function printDevis() {

	var espace = document.getElementById("espace").value;
	var token = document.getElementById("token").value;
	var com = "";

	for (var i = 0; i <  document.getElementsByName("datas.primeEtTaux").length; i++) {
		if (document.getElementsByName("datas.primeEtTaux")[i].checked ){
				com = document.getElementsByName("datas.primeEtTaux")[i].value;
		}
	}

	var taux = "";

	if (document.getElementById("datas.taux") != null && document.getElementById("datas.taux").type == 'hidden'){
		taux = document.getElementById("datas.taux").value;
		if (espace == 'BtoC'){
			window.open("visuDevisB2C.do?token="+token+"&com="+com+"&taux="+taux);
		} else{
			window.open("visuDevis.do?token="+token+"&com="+com+"&taux="+taux);
		}
	}
	else if (document.getElementsByName("datas.taux").length > 1){
		var radio = document.getElementsByName("datas.taux");
		for (var i = 0; i < radio.length; i++) {
	        if (radio[i].checked) {
	        	idTaux = radio[i].id
	        }
	     }
		if (espace == 'BtoC'){
			window.open("visuDevisB2C.do?token="+token+"&idTaux="+idTaux);
		} else{
			window.open("visuDevis.do?token="+token+"&idTaux="+idTaux);
		}
	}
	else{
		if (espace == 'BtoC'){
			window.open("visuDevisB2C.do?token="+token+"&com="+com);
		} else{
			window.open("visuDevis.do?token="+token+"&com="+com);
		}
	}
}

function printDevisExpatries() {

	var token = document.getElementById("token").value;
	window.open("visuDevisB2C.do?token="+token);
}

function viewGaranties(codeProduit, code){

	var url = "/produits/viewGarantiesProduit.do?codeProduit="+codeProduit+"&code="+code;
	var modUrl=location.search.substring(1,location.search.length);
	if(modUrl.length != 0){
		var sousChaine = modUrl.indexOf("partner");
		if (sousChaine >= 0){
			var partner = modUrl.substring(sousChaine,modUrl.length);
			url = url+"&"+partner;
		}
	}
	parent.location=url;
}

function viewInformations(codeProduit, code){

	var url = "/produits/viewInformationsProduit.do?codeProduit="+codeProduit;
	var modUrl=location.search.substring(1,location.search.length);
	if(modUrl.length != 0){
		var sousChaine = modUrl.indexOf("partner");
		if (sousChaine >= 0){
			var partner = modUrl.substring(sousChaine,modUrl.length);
			url = url+"&"+partner;
		}
	}
	parent.location=url;
}

function popupSchengenPro(page){
	window.open(page,'popup','width=390,height=300,top=100,left=100,resizable=yes,scrollbars=false');
}
function relancer(element,ancre){
	element.form.action="recharger.do#"+ancre;
	element.form.submit();
}

function relancerDevis(element,ancre){
	element.form.action="rechargerDevis.do#"+ancre;
	element.form.submit();
}
function popupFaq(page) {
	window.open(page,'popup','width=1000,height=614,top=0,left=0,toolbar=false,scrollbars=yes');
}

function openFiles(filesString,winname) {
	var files = filesString.split('@');
	for (i=0; i<files.length; i++){
		newwin = window.open(files[i],winname+i,'width=800,height=600,scrollbars=yes,resizable=yes,top=100,left=100');
	}
}

function popupPaysExclus(page) {
	window.open(page,'popup2','width=300,height=250,toolbar=false,scrollbars=false');
}

//Benefits
$(document).ready(function(){

	  if ($.browser.msie && (parseInt($.browser.version) == 6)) {
          //$(".helpwindow").bgiframe({ width: 202 });
          $(".benefits").bgiframe({ width: 522 });
	  }

  $("#tableProduit tbody th a").hover(function() {
      $(this).siblings(".benefits").css("left", "auto");
    },function() {
      $(this).siblings(".benefits").css("left", "-9999px");
  });

  if ($("body").attr("class") != "purchase") {
	  $(".package_1, .package_2").addClass("hide");
	  $("#packageselector div").click(function(){
	  $("#packageselector span.selectorhr").remove();
	  $("#packageselector td").removeClass("selected");
	  $(this).parent().addClass("selected");
	  $(this).children("a").append("<span class=\"selectorhr\"></span>");
	  $("#tableProduit table[id!=packageselector]").addClass("hide");
	  // $("#packagecompare li").addClass("hide");
	  href = $(this).children("a").attr("href").split("_")[1];
	  $("#tableProduit table[id!=packageselector]").each(function(i){
		  var test = "package_" + href;
		  if (!$(this).attr("class").search(test)) {
			  $(".package_" + i).removeClass("hide");
		  };
	  });
	  return false;
    });
  };
});

function changeAutresProduits() {
	if(document.getElementById('autresProduits').style.display == 'none') {
		document.getElementById('autresProduits').style.display = 'block';
		document.getElementById('lienAutresProduits').className='autresProduitsOpen';
	}
	else {
		document.getElementById('autresProduits').style.display = 'none';
		document.getElementById('lienAutresProduits').className='autresProduitsClose';
	}
}

function download_documents() {
	document.forms.confirmation.action='/produits/documentsPdf.do';
	document.forms.confirmation.target='_blank';
	document.forms.confirmation.submit();
}

//function clignotement(){
//	if(document.getElementById("blink") != null){
//		if (document.getElementById("blink").style.color == "black")
//			document.getElementById("blink").style.color="red";
//	else
//			document.getElementById("blink").style.color="black";
//		}
//}
//
//setInterval('clignotement()', 500);
