// acceptContract.xsl _________________________________________________________________________
function visitContract() {
	var anUrl= getAScenarioMarkOutUrl('ContractAcceptPage','ContractAcceptPage.view');
	window.open(anUrl);
}

function getMainForm(form) {
	if (document.layers)
		zeForm = eval("document.containerPrint.document." + form);
	else if (document.all)
		zeForm = document.all(form);
	else {
		zeForm = eval("document." + form);
	}
	return zeForm;
}


// changePassword.xsl _________________________________________________________________________
function changePasswordValidation(passForm) {
	if (passForm.elements[5].value== "" ) {
		alert(mes1);
	} else {
	    if (passForm.elements[6].value== "")
			alert(mes2);
	   else
		 comparePwd(passForm);
	}
}

function comparePwd(passForm) {
	if (passForm.elements[5].value != passForm.elements[6].value)
		alert(mes3);
	else
	   	document.changePasswordForm.submit();
}

function isPwdKey(evt) {
	if (navigator.appName.indexOf("Netscape") != -1)
		keyCode = evt.which;
	else
		keyCode = evt.keyCode;
	return ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122));
}

function processPasswordInput(fld, evt) {
	if (isPwdKey(evt)) return true;
	return false;
}


// contractSelect.xsl _________________________________________________________________________
function contractSelectValidation(form) {
    var blnCheck = false;
	for (var i=0;  i<form.elements.length; i++) {
		if (form.elements[i].checked) { blnCheck = true; break }
	}
	if (!blnCheck)
		alert(mes1);
	else
		form.submit();
}


// Commun a initialAgreement.xsl & insuredModif.xsl _________________________________________________________________________
NomJours = new Array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
maintenant = new Date();

function printDate() {
	document.form1.effect_date.value = maintenant.getDate() + "/" + NomJours[maintenant.getMonth()]+ "/" + maintenant.getFullYear();
}

function writeDate() {
	if (lang == "us")
		document.write("" + NomJours[maintenant.getMonth()] + " / " +  calcDay(maintenant.getDate()) + " / " + maintenant.getFullYear());
	else
		document.write("" + calcDay(maintenant.getDate()) + " / " + NomJours[maintenant.getMonth()]+ " / " + maintenant.getFullYear());
}

function getMaxDays() {
	for (var i=0; i<paimentConditionsList.length; i++)
		if (paimentConditionsList[i].serviceValue == '02')  return paimentConditionsList[i].maxValue;
}

function creditLengthValidation(days) {
	var today = new Date();
	var maxDays = 0;
	maxDays = getMaxDays();
	if (parseInt(days) > parseInt(maxDays)) {
	  alert(err_credit_length + ' ' + maxDays + ' ' + label_days + '.');
	}
}

function dateValidation(dateEntered) {
	var today = new Date();
	var requestDate = new Date();
	var limitBefore = new Date();
	var limitBefore2 = new Date();
	var limitAfter = new Date();
	var slash1 = dateEntered.indexOf("/");
	var slash2 = dateEntered.lastIndexOf("/");
  
	if (!isDate(dateEntered)) {
		alert(dateEntered + " " + mes1);
		document.form1.effect_date.value = "";
		if (requestAgreement == "kzu") calendarReturnedDate(false);
	} else {
		requestDate.setDate(dateEntered.substring(0,slash1));
		requestDate.setMonth(parseInt(dateEntered.substring(slash1+1,slash2)-1));
		requestDate.setYear(dateEntered.substring(slash2+1,dateEntered.length));
		if (isNaN(requestDate)) {
		  alert(dateEntered + " " + mes1);
		  document.form1.effect_date.value = "";
		}

		if (requestAgreement == "init") {
			limitBefore.setMonth(today.getMonth()-1);
			limitBefore.setDate("1");
		} else if (requestAgreement == "modif") {
			limitBefore.setDate(startAgreementDate.substring(0,2));
			limitBefore.setMonth(startAgreementDate.substring(3,5));
			limitBefore.setMonth(limitBefore.getMonth()-1);
			var startAgreementYear = parseInt(startAgreementDate.substring(6,8));
			if (startAgreementYear < 70) startAgreementYear += 2000;
			else startAgreementYear += 1900;
			limitBefore.setYear(startAgreementYear);
			
			limitBefore2.setMonth(today.getMonth()-1);
			limitBefore2.setDate("1");
			if (limitBefore2.getTime() > limitBefore.getTime() || isNaN(limitBefore)) {
				limitBefore = limitBefore2;
			}
		} else if (requestAgreement == "kzu") {
			calendarReturnedDate(true);
			return;
		}
		limitAfter = today.getTime() + (1000 * 60 * 60 * 24 * 90);
		if (requestDate.getTime() < limitBefore.getTime() || requestDate.getTime() > limitAfter) {
	      limitAfter = new Date(limitAfter);
		  alert(mes2 + " " + calcDay(limitBefore.getDate()) + "/" +  calcMonth(limitBefore.getMonth()) + "/" +  limitBefore.getYear() + mes3 + " " + calcDay(limitAfter.getDate()) + "/" + calcMonth(limitAfter.getMonth()) + "/" + limitAfter.getYear() + ".");
		  document.form1.effect_date.value = "";
		}
	}
}

function calcMonth(m) {
	m = parseInt(m) + 1;
	if (m < 10) m = "0" + m;
	return m;
}

function calcDay(d) {
	d = parseInt(d);
	if (d < 10) d = "0" + d;
	return d;
}

function isDate(dateEntered) {
	var err=0;
	if (dateEntered.length > 10) err = 1;
  	slash1 = dateEntered.indexOf("/");
  	slash2 = dateEntered.lastIndexOf("/");
	dayEntered = parseInt(dateEntered.substring(0,slash1));
	monthEntered = parseInt(dateEntered.substring(slash1+1,slash2));
	yearEntered = parseInt(dateEntered.substring(slash2+1,dateEntered.length));
	if (isNaN(dayEntered) || isNaN(monthEntered) || isNaN(yearEntered)) err = 8
	if (dayEntered < 1 || dayEntered > 31) err = 1;
	if (monthEntered < 1 || monthEntered > 12) err = 2;
	if (yearEntered < 1900) err = 3;
	if (monthEntered == 4 || monthEntered == 6 || monthEntered == 9 || monthEntered == 11){
		if (dayEntered == 31) err = 4;
	}
	if (monthEntered==2) {
		var g=parseInt(yearEntered/4);
		if (isNaN(g)) err = 5;
		if (dayEntered > 29) err = 6;
		if (dayEntered == 29 && ((yearEntered/4)!=parseInt(yearEntered/4))) err = 7;
	}
	if (err != 0)
	  return false;
	else 
	  return true;
}

function popUp(url) {
	t = screen.availHeight - 300;
	l = screen.availWidth - 300;
  	popWin = window.open(url, 'popupWindow', 'top=' + t + ',left=' + l +',width=210,height=190,menubar=no,scrollbars=no,toolbar=no,location=no,status=no');
	popWin.focus();
}


function PrintManager() {
	this.buffer = "";
}

function PaiementCondition(aLabel, aMaxValue, aServiceValue) {
	this.label= aLabel;
	this.maxValue = aMaxValue;
	this.serviceValue= aServiceValue;
}

function display(output) {								
	if (document.layers) {
		document.layers["containerPrint"].document.open();
		document.layers["containerPrint"].document.write("<p>" + output + "</p>");					
		document.layers["containerPrint"].document.close();   					
	} else if (document.all) {
		document.all("containerPrint").innerHTML = output;
	} else {
		document.getElementById("containerPrint").innerHTML = output;
	}
}  

function buildScreen(code){
	var bd = '';
	bd += '<form name="form2" class="navForm">\n';
	bd += '<table border="0" cellspacing="0" cellpadding="0">\n';
	bd += '<tr>\n';
	bd += '<td class="itemList">';
	if ( code == '02' )
		bd += ' <input type="text" name="creditLength" size="3" maxlength="3" onKeyPress="return processInput(this,event)" onChange="creditLengthValidation(this.value)"> ' + label_days + '\n';
  	else 
		bd += ' <input type="hidden" name="creditLength" size="2">\n';
	if ( code == '09' )
		bd += ' <input type="text" name="paiementValue" size="10" maxlength="10" onChange="upperMe(this)">\n';
  	else 
		bd += ' <input type="hidden" name="paiementValue" size="10">\n';
	bd += '</td></tr></table>\n';
	bd += '</form>';
	
	display(bd);
}   		

function loadPayementTerm() {
	if (!document.layers) {
		var code = document.form1.payment_term_code.options[document.form1.payment_term_code.selectedIndex].value;
		document.form1.paiementValue.style.display = "none";
		document.form1.creditLength.style.display = "none";
		if (document.all)
			document.all('divDays').style.display = "none";
		else
			document.getElementById('divDays').style.display = "none";
		
		if (code == '02') {
			document.form1.creditLength.style.display = "inline";
			if (document.all)
				document.all('divDays').style.display = "inline";
			else
				document.getElementById('divDays').style.display = "inline";
		}
		if (code == '09') {
			document.form1.paiementValue.style.display = "inline";
		}
	} else {
		document.layers["containerPrint"].x = document.links[document.links.length-3].x;
		document.layers["containerPrint"].y = document.links[document.links.length-3].y;
		buildScreen(document.form1.payment_term_code.options[document.form1.payment_term_code.selectedIndex].value);
	}
}

function getEndDate(strEndDate) {
	var endAgreementDate;
	endAgreementDate.setDate(strEndDate.substring(0,2));
	endAgreementDate.setMonth(strEndDate.substring(3,5));
	endAgreementDate.setMonth(endAgreementDate.getMonth()-1);
	var endAgreementYear = parseInt(strEndDate.substring(6,8))
	if (endAgreementYear < 70) endAgreementYear += 2000
	else endAgreementYear += 1900
	endAgreementDate.setYear(endAgreementYear);
	
	return endAgreementDate.getTime();
}

function formatEffectDate(dateEntered) {
  	var slash1 = dateEntered.indexOf("/");
  	var slash2 = dateEntered.lastIndexOf("/");
	var dayEntered = dateEntered.substring(0,slash1);
	var monthEntered = dateEntered.substring(slash1+1,slash2);
	var yearEntered = dateEntered.substring(slash2+1,dateEntered.length);
	if (dayEntered.length == 1) dayEntered = "0" + dayEntered;
	if (monthEntered.length == 1) monthEntered = "0" + monthEntered;
	dateEntered = "" + yearEntered + "" + monthEntered + "" + dayEntered;
	return dateEntered;
}

// used for KZU
function formatKZUDate(dateEntered) {
  	var slash1 = dateEntered.indexOf("/");
  	var slash2 = dateEntered.lastIndexOf("/");
	var dayEntered = dateEntered.substring(0,slash1);
	var monthEntered = dateEntered.substring(slash1+1,slash2);
	var yearEntered = dateEntered.substring(slash2+1,dateEntered.length);
	if (dayEntered.length == 1) dayEntered = "0" + dayEntered;
	if (monthEntered.length == 1) monthEntered = "0" + monthEntered;
	dateEntered = "" + dayEntered + "" + monthEntered + "" + yearEntered;
	return dateEntered;
}

function prepareURLAndPost(){
	var anUrl= getAScenarioMarkOutUrl("DeletionConfirmationPage", "DeletionConfirmationPage.submit");
	aDate= formatEffectDate(document.form1.effect_date.value);
	anUrl+= "&AgreementInput.effect_date=" + aDate;
	goToUrl(anUrl);
}

function submitForm(){
	var div2;
	if (document.layers)
		div2= document.layers["containerPrint"].document.form2;
	else
		div2= document.form1;
	var code = document.form1.payment_term_code.options[document.form1.payment_term_code.selectedIndex].value;
	if (document.form1.request_amount.value == "" || document.form1.request_amount.value < 1)
  		alert(mes4);
	else if (document.form1.payment_term_code.options[document.form1.payment_term_code.selectedIndex].value == -1)
  		alert(mes5);
	else if (document.form1.minimum_request_amount.value != "" && parseInt(document.form1.request_amount.value) < parseInt(document.form1.minimum_request_amount.value))
  		alert(mes6);
	else if (minAmount != 0 && parseInt(document.form1.request_amount.value) < minAmount && statusAgreement == 0) {
  		if ( endDateAgreement.length <= 2 || ( endDateAgreement.length > 2 && getEndDate(endDateAgreement) < today.getTime() ) )
  			alert(mes7 + minAmount + mes8);
	}
	else if (document.form1.guarantor_number.value.length > 0 && document.form1.guarantor_number.value.length < 10)
  		alert(mes9);
	else if (document.form1.agreement_comment.value.length > 304)
		alert(mes20);
	else if (document.form1.agreement_comment.value.indexOf('\u20AC') != -1 || document.form1.agreement_comment.value.indexOf('\u00A3') != -1 || document.form1.agreement_comment.value.indexOf('\u00A5') != -1 || document.form1.agreement_comment.value.indexOf('\u0024') != -1)
		alert(mes21);
	else if (code == '02' && div2.creditLength.value.length < 1)
		alert(err_enter_credit_length);
	else {
		if (!validateCoveAmount(document.form1.request_amount.value, coef, curr, document.form1.request_amount)) return;
		var code = document.form1.payment_term_code.options[document.form1.payment_term_code.selectedIndex].value;
		var effectDate = formatEffectDate(document.form1.effect_date.value);
		anUrl+= "&AgreementInput.effect_date=" + escape(effectDate) +
		"&AgreementInput.request_amount=" + escape(document.form1.request_amount.value) +
		"&AgreementInput.minimum_request_amount=" + escape(document.form1.minimum_request_amount.value) +
		"&AgreementInput.payment_term_code=" + escape(code) +
		"&AgreementInput.guarantor_number=" + escape(document.form1.guarantor_number.value) +
		"&AgreementInput.request_reference=" + escape(document.form1.request_reference.value) +
		"&AgreementInput.agreement_comment=" + escape(document.form1.agreement_comment.value);
		if (document.form1.expressTransformRating) anUrl+= "&AgreementInput.expressTransformRating=" + document.form1.expressTransformRating.value;
		if (code == '02') anUrl+= "&AgreementInput.payment_term_value=" + escape(div2.creditLength.value);
		if (code == '09') anUrl+= "&AgreementInput.payment_term_value=" + escape(div2.paiementValue.value);
		//alert(anUrl);
		goToUrl(anUrl);
	}
}


// login.xsl _________________________________________________________________________
function submitLogin() {
	if (isValidForm(this.form,document.formulaire.elements[5].value,document.formulaire.elements[6].value))
		if (submitNum == 0 && detectCookies()) {
			submitNum++;
			document.formulaire.submit();
		}
}

function getCodeProfil(image) {
	var codeProfil = profilCode + "/";;
	if (image)
		codeProfil = getImagePath(codeProfil);
	else
		if (codeProfil != 'Pr10/' && codeProfil != 'Pr11/') codeProfil = "";
		else codeProfil = 'A01_Pr10/';
	return codeProfil;
}

function getImagePath(codeProfil) {
	switch (codeProfil) {
		case "Pl01/":
			codeProfil = "okv01/";
			break;
		case "Ak03/":
			codeProfil = "ak01/";
			break;
		case "Pr02/":
		case "Pr07/":
		case "default/":
		case "":
			codeProfil = "";
			break;
		default:
			codeProfil = codeProfil.toLowerCase();
	}
	return codeProfil;
}

function displayHeader() {
	document.write( '<img src="/allnetWeb/xml-internal3/images/' + getCodeProfil(true) + 'image1b.gif" width="711" height="50">' );
}

function tempTimer1() {
	indCol = 0;
	if (allTimer) window.clearTimeout(allTimer);
	setTimeout('tempTimer2()', 1500);
}

function tempTimer2() {
	document.getElementById('animatedLink').style.color = '#ffffff';
	document.getElementById('animatedLink').innerHTML = ".";
	setTimeout('tempTimer3()', 500);
}

function tempTimer3() {
	document.getElementById('animatedLink').innerHTML = label_news;
	allColours();
}

function initAllColours() {
	R = ['ff', 'cc', 'aa', '99', '66', '33', '00'];
	G = ['ff', 'cc', 'aa', '99', '66', '33', '00'];
	B = ['ff', 'ee', 'dd', 'cc', 'bb', 'aa', '99'];
	indCol = 0;
	if (allTimer) window.clearTimeout(allTimer);
	allColours();
}

function allColours() {
	displayRainbow();
	indCol++;
	allTimer = setTimeout('allColours()', 100);
	if (indCol >= 7) tempTimer1();
}

function displayRainbow() {
	document.getElementById('animatedLink').style.color = '#' + R[indCol] + G[indCol] + B[indCol];
	document.getElementById('animatedLink').style.fontSize = '1' + indCol + 'px';
}

function displayDisclaimer() {
	var curLang = getLang();
	detectCookies();
	//if (document.getElementById && (curLang == 'en' || curLang == 'fr' || curLang == 'de')) initAllColours();
	if (profilCode == "Pr04") popUpRapport("/allnetWeb/xml-internal3/A01/A01_Pr04/source/disclaimer.html");
}

function detectCookies() {
	var date = new Date();
	date.setTime(date.getTime() - (1*24*60*60*1000));
    document.cookie = "test=cookiesEnabled;expires=" + date.toGMTString();
    document.cookie = "test=cookiesEnabled";
    if (document.cookie.indexOf("test=") == -1) {
        alert("Please enable cookies and then press Reload to try again.");
		return false;
    }
	return true;
}

function addbookmark() {
	if (ie4) window.external.AddFavorite(window.location.href,"Cofanet")
}


// passwordRequest.xsl _________________________________________________________________________
function passwordRequestValidation(passForm) {
	if ((passForm.elements[5].value== "") || (passForm.elements[5].value.length != 8)) {
		alert(mes);
	} else {
		if (!isEmail(passForm.elements[6]))
			passForm.submit();
		else
		  alert(mes1);
	}
}


// person.xsl _________________________________________________________________________
function personValidation1(form) {
	if ((form.elements[9].value == "") || (form.elements[9].length < 2)) {
		alert(mes3);
	} else if ((form.elements[10].value == "") || (form.elements[10].length < 2)) {
		alert(mes4);
	} else if ((form.elements[11].value == "") || (form.elements[11].length < 2)) {
		alert(mes7);
	} else if ((form.elements[12].value == "") || (form.elements[12].length < 2)) {
		alert(mes6);
	} else if ((form.elements[13].value == "") || (form.elements[13].length < 2)) {
		alert(mes8);
    } else {
		var anUrl = getAScenarioMarkOutUrl("PersonnalizationPage", "PersonnalizationPage.submit1");
		anUrl += "&UserInput.companyName=" + escape(form.elements[5].value);
		anUrl += "&UserInput.mail=" + escape(form.elements[6].value);
		anUrl += "&UserInput.tel=" + escape(form.elements[7].value);
		anUrl += "&UserInput.fax=" + escape(form.elements[8].value);
		anUrl += "&UserInput.name=" + escape(form.elements[9].value);
		anUrl += "&UserInput.firstName=" + escape(form.elements[10].value);
		anUrl += "&UserInput.adresse=" + escape(form.elements[11].value);
		anUrl += "&UserInput.town=" + escape(form.elements[12].value);
		anUrl += "&UserInput.country=" + escape(form.elements[13].value);
		goToUrl(anUrl);
	}
}

function personValidation2(form) {
	if ((form.elements[5].value == "") || (form.elements[5].length < 2)) {
		alert(mes11);
	} else if ((form.elements[6].value == "") || (form.elements[6].length < 2)) {
		alert(mes12);
	} else if ((form.elements[7].value == "") || (form.elements[7].length < 2)) {
		alert(mes13);
	} else if ((form.elements[6].value != form.elements[7].value)) {
		alert(mes14);
    } else {
		form.submit();
	}
}

function selectCompanyPerPage() {
	var opt = document.formulaire3.elements[0];
	for (var i = 0; i < opt.length; i++) {
		if (opt.options[i].value == resPerPage) opt.selectedIndex = i;
	}
}

function selectDefaultCountry() {
	var opt = document.formulaire3.elements[1];
	for (var i = 0; i < opt.length; i++) {
		if (opt.options[i].value == defCountry) opt.selectedIndex = i;
	}
}

function selectDefaultLanguage() {
	var opt = document.formulaire3.elements[2];
	for (var i = 0; i < opt.length; i++) {
		if (opt.options[i].value == defLang) opt.selectedIndex = i;
	}
}

function selectDefaultContract() {
	var opt = document.formulaire3.elements[3];
	for (var i = 0; i < opt.length; i++) {
		if (opt.options[i].value == defContract) opt.selectedIndex = i;
	}
}

function selectDefaultWelcomePage() {
	var opt = document.formulaire3.elements[4];
	for (var i = 0; i < opt.length; i++) {
		if (opt.options[i].value == defPage) opt.selectedIndex = i;
	}
}

function submitForm3() {
	var anUrl= getAScenarioMarkOutUrl("PersonnalizationPage","PersonnalizationPage.submit3");
	var mainForm= document.formulaire3;
	var selectedCountry;
	if (mainForm.selectedCountry.length > 0)
		selectedCountry = mainForm.selectedCountry.options[mainForm.selectedCountry.selectedIndex].value;
	else 
		selectedCountry = "";
	anUrl+= "&UserInput.companyPerPage=" + mainForm.companyPerPage.options[mainForm.companyPerPage.selectedIndex].value +
  			"&UserInput.selectedCountry=" + selectedCountry +
  			"&UserInput.lang=" + mainForm.lang.options[mainForm.lang.selectedIndex].value +
  			"&UserInput.selectedContract=" + escape(mainForm.selectedContract.options[mainForm.selectedContract.selectedIndex].value) +
  			"&UserInput.welcomePage=" + mainForm.welcomePage.options[mainForm.welcomePage.selectedIndex].value +
  			"&lang=" + mainForm.lang.options[mainForm.lang.selectedIndex].value
	goToUrl(anUrl);
}


// portfolioEvent.xsl _________________________________________________________________________
function portfolioEventValidation(form) {
	var blnCheck = false
	for (var i = 0;  i < form.elements.length; i++) {
		if (form.elements[i].checked) { blnCheck = true; break }
	}
	if (!blnCheck)
		alert(mes1);
    else
		document.form1.submit();
}


// reportHistory.xsl _________________________________________________________________________
function visitReport(anReportId) {
	var anUrl = getAScenarioMarkOutUrl('ReportHistoryPage','ReportHistoryPage.visit');
	anUrl += "&ReportInput.report_id=" + anReportId;
	popUpRapport(anUrl);
}


// localReportHistory.xsl _________________________________________________________________________
function visitLocalReport(anReportId, anReportUserId) {
	var anUrl= getAScenarioMarkOutUrl('ReportHistoryPage','ReportHistoryPage.visit');
	anUrl += "&ReportInput.report_id=" + anReportId;
	anUrl += "&ReportInput.report_userId=" + anReportUserId;
	popUpRapport(anUrl);
}


// Email validation script _________________________________________________________________________
var rEmail1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var rEmail2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");	 	
function regExpSupported() {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) 
	  		supported = 1;
	}
	return supported;
}	

function isEmail(str) {
	if (!regExpSupported()) {
		if ((str.indexOf(".") > 2) && (str.indexOf("@") > 0))
			return true;
	} else if (rEmail1.test(str) || rEmail2.test(str))
		return true;
	return false;
}


//search.xsl, search2.xsl, subscriptionForm.xsl _________________________________________________________________________
var CountryList=new Array;
var i=0; 

function Country(countryCode,name,legalId1,legalId2,legalId3) {
	this.countryCode=countryCode;
	this.name=name;
	this.legalId1=legalId1;
	this.legalId2=legalId2;
	this.legalId3=legalId3;
}

function isValidForm(form, a, b) {
	if (a == "" && b == "") {
		alert(mes);
		return false;
	}
	return true;
}

function isValidForm2(form, a, b, c) {
	if (a == "" && b == "" && c == "") {
		alert(mes);
		return false;
	}
	return true;
}

function getCountry(aCode){
	for (j=0; j< CountryList.length; j++) {
		if (CountryList[j].countryCode.indexOf(aCode) != -1)
			return CountryList[j];
	}
	return;
}


// search.xsl _________________________________________________________________________
function displayStateInput(output) {
	if (document.layers) {
		document.layers['mediaDetail'].document.open();
		document.layers['mediaDetail'].document.write('<p>' + output + '</p>');
		document.layers['mediaDetail'].document.close();
		} else if (document.all) {
		document.all('mediaDetail').innerHTML = output;
	} else if (document.getElementById) {
		document.getElementById('mediaDetail').innerHTML = output;
	}
}

function displayStateList(cCodeValue) {
	var buffer = '';
	if (cCodeValue == '0285' || cCodeValue == '0195') {
		if (document.layers) buffer += '<form name="form2">\n';
		buffer += '<table height="32" cellpadding="0" cellspacing="0" border="0" align="right"><tr>\n';
		buffer += '<td>' + state + '</td>\n';
		buffer += '<td><img src="/allnetWeb/xml-internal3/images/spacer.gif" width="4" height="10" border="0"></td>\n';
		buffer += '<td><select name="stateList" class="countryList" tabIndex="4" onChange="updateCurSate(\'' + cCodeValue + '\')">\n';
		if (cCodeValue == '0285')
			for (var i=0; i<usStateArr.length; i+=2) {
				buffer += '<option value="' + usStateArr[i] +  '">' + usStateArr[i+1] + '</option>\n';	
			}
		else
			for (var i=0; i<caStateArr.length; i+=2) {
				buffer += '<option value="' + caStateArr[i] +  '">' + caStateArr[i+1] + '</option>\n';	
			}
		buffer += '</select></td></tr></table>\n';
		if (document.layers) buffer += '</form>\n';
	} else {
		if (cCodeValue == '0942') document.searchForm.region.value = 'PR';
		if (cCodeValue == '0992') document.searchForm.region.value = 'VI';
	}
	displayStateInput(buffer);
	if (cCodeValue == '0285' || cCodeValue == '0195') updateCurSate(cCodeValue);
}

function updateCurSate(cCodeValue) {
	var stateLst;
	if (document.layers) stateLst = document.layers['mediaDetail'].document.form2.stateList;
	else stateLst = document.searchForm.stateList;
	document.searchForm.region.value = stateLst.options[stateLst.selectedIndex].value;
}

function changeAGivenCountryCode(aCountryCode) {								
	var cCodeValue = aCountryCode;
	if (document.searchForm.elements[1].value.length < 1)
		for ( i=0; i<document.searchForm.country.length; i++ ) {						
			if ( ( cCodeValue.lastIndexOf(document.searchForm.country.options[i].value) == 0 ) || ( document.searchForm.country.options[i].value.lastIndexOf("0" + cCodeValue) == 0 ) ) {
				document.searchForm.country.selectedIndex= i;
				break;
			}
		}
	else cCodeValue = document.searchForm.country.options[document.searchForm.country.selectedIndex].value;
	if (!ibSearch) displayStateList(cCodeValue);
}

function submitSearchForm() {	
	var anUrl = getAScenarioMarkOutUrl("SearchCompanyPage","SearchCompanyPage.submit");
	anUrl += "&CompanySearchInput.country=" + document.searchForm.country.options[document.searchForm.country.selectedIndex].value + "&CompanySearchInput.name=" + escape(document.searchForm.name.value) + "&CompanySearchInput.town=" + escape(document.searchForm.town.value) + "&CompanySearchInput.region=" + escape(document.searchForm.region.value);
	if (isValidForm(document.searchForm, document.searchForm.name.value, ""))
		goToUrl(anUrl);
}

function submitOtherCriteriaSearch() {
	var anUrl= getAScenarioMarkOutUrl('SearchCompanyPage','SearchCompanyPage.goOtherCriteriaSearch');
	anUrl= anUrl + "&CompanySearchInput.country=" + document.searchForm.country.options[document.searchForm.country.selectedIndex].value + "&CompanySearchInput.name=" +  escape(document.searchForm.name.value) + "&CompanySearchInput.town=" +  escape(document.searchForm.town.value);
	goToUrl(anUrl);
}

function submitInfobaseSearchForm(extended) {	
	var anUrl= getAScenarioMarkOutUrl("SearchCompanyPage","SearchCompanyPage.infobaseSubmit");
	anUrl += "&CompanySearchInput.country=" + document.searchForm.country.options[document.searchForm.country.selectedIndex].value ;
	if (!extended) {
		anUrl += "&CompanySearchInput.name=" + escape(document.searchForm.name.value) ;
		anUrl += "&CompanySearchInput.address=" + escape(document.searchForm.address.value);
		anUrl += "&CompanySearchInput.postalCode=" + escape(document.searchForm.postalCode.value);
		anUrl += "&CompanySearchInput.town=" + escape(document.searchForm.town.value);
		if ( isValidFormInfobase(document.searchForm.name.value) )
			goToUrl(anUrl);
	} else {
		anUrl += "&CompanySearchInput.buyerId=" + escape(document.searchForm.buyerId.value);
		anUrl += "&CompanySearchInput.idValue=" + escape(document.searchForm.legalId.value);
		if ( isValidFormInfobase2(document.searchForm.buyerId.value, document.searchForm.legalId.value) )
			goToUrl(anUrl);
	}
}

function submitInfobaseOtherCriteriaSearch(extended) {
	var anUrl= getAScenarioMarkOutUrl('SearchCompanyPage','SearchCompanyPage.goInfoBaseOtherCriteriaSearch');
	anUrl += "&Navigation.currentPage=SearchCompanyPage&Navigation.extended=" + extended;
	goToUrl(anUrl);
}

function upperAndSubmitInfobaseSearch(t) {
	upperMe(t);
	submitInfobaseSearchForm(false);
}

function upperAndSubmitInfobaseSearch2(t) {
	upperMe(t);
	submitInfobaseSearchForm(true);
}

function isValidFormInfobase(a) {
	if ( a == "") {
		alert(mes1)
		return false;
	}
  return true;
}
	
function isValidFormInfobase2(a, b) {
	if ( (a == "") && (b == "") || (a != "") && (b != "") ) {
		alert(mes1)
		return false;
	}
  return true;
}

// search2.xsl _________________________________________________________________________
function displayStateList2(cCodeValue) {
	var buffer = '';
	if (document.layers) buffer += '<form name="form2"><table cellpadding="0" cellspacing="0" border="0"><tr><td>\n';
	if (cCodeValue == '0285' || cCodeValue == '0195') {
		buffer += '<select name="stateList" onChange="updateCurSate2(true)">\n';
		if (cCodeValue == '0285')
			for (var i=0; i<usStateArr.length; i+=2)
				buffer += '<option value="' + usStateArr[i] +  '">' + usStateArr[i+1] + '</option>\n';
		else
			for (var i=0; i<caStateArr.length; i+=2)
				buffer += '<option value="' + caStateArr[i] +  '">' + caStateArr[i+1] + '</option>\n';	
		buffer += '</select>\n';
	} else {
		if (cCodeValue == '0942')
			buffer += '<input type="text" name="stateList" size="10" value="PR" onFocus="this.blur();">\n';
		else if (cCodeValue == '0992')
			buffer += '<input type="text" name="stateList" size="10" value="VI" onFocus="this.blur();">\n';
		else
			buffer += '<input type="text" name="stateList" size="10" value="" onChange="upperMe(this);updateCurSate2(false);">\n';
	}
	if (document.layers) buffer += '</td></tr></table></form>\n';
	displayStateInput(buffer);
	if (cCodeValue == '0285' || cCodeValue == '0195') updateCurSate2(true);
	else updateCurSate2(false);

}

function updateCurSate2(list) {
	var stateLst;
	if (document.layers) stateLst = document.layers['mediaDetail'].document.form2.stateList;
	else stateLst = document.form1.stateList;
	document.form1.region.value = (list) ? stateLst.options[stateLst.selectedIndex].value : stateLst.value;
}

function submitSearch2() {
	var anUrl= getAScenarioMarkOutUrl("OtherCriteriaSearchPage","OtherCriteriaSearchPage.submit");
	var aForm = document.form1;
  		
	if ( isValidForm2(aForm, aForm.nameC.value, aForm.idValue.value, aForm.cofaceNumber.value) ) {
		country= escape(aForm.country.options[aForm.country.selectedIndex].value);
		nameC= escape(aForm.nameC.value);
		region= escape(aForm.region.value);
  		address= escape(aForm.address.value);
  		postalCode= escape(aForm.postalCode.value);
  		town= escape(aForm.town.value);
  		idInput= escape(aForm.idInput.options[aForm.idInput.selectedIndex].value);
  		idInputL= escape(aForm.idInput.options[aForm.idInput.selectedIndex].text);
  		idValue= escape(aForm.idValue.value);
  		portfolioOnly= "";
  		cofaceNumber=aForm.cofaceNumber.value;
  		
		anUrl+="&CompanySearchInput.country=" + country + "&CompanySearchInput.name=" + nameC + "&CompanySearchInput.region=" + region + "&CompanySearchInput.address=" + address + "&CompanySearchInput.postalCode=" + postalCode + "&CompanySearchInput.town=" + town + "&CompanySearchInput.idInput=" + idInput + "&CompanySearchInput.idValue=" + idValue + "&CompanySearchInput.portfolioOnly=" + portfolioOnly + "&CompanySearchInput.idInputL=" + idInputL + "&CompanySearchInput.cofaceId=" + cofaceNumber
  		goToUrl(anUrl);
  	}
}

function processCofaceRef(refValue) {
	if (isNaN(refValue))
		upperMe(document.form1.cofaceNumber)
	else {
		if (refValue.length > 0) {
			var zerosNum = "";
			for (var i=6; i>refValue.length; i--)
				zerosNum += "0";
			if (refValue.length < 6)
				document.form1.cofaceNumber.value = zerosNum + refValue;
		}
	}
}

function changeCtrySearch2() {
	var aForm = document.form1;
	var selectedCountryCode = aForm.country.options[aForm.country.selectedIndex].value;
	loadLegalId2(selectedCountryCode, aForm.idInput);
	aForm.countryNumber.value = selectedCountryCode;
}

function loadLegalId2(country, idInput){
	var siz = idInput.options.length;
	for (var k=0; k<siz; k++)
		idInput.options[0] = null;

	var countryObject = getCountry(country);
	var newoption;

	if (countryObject.legalId1 != "null" && countryObject.legalId1 != "") {
		newoption = new Option(countryObject.legalId1, "legalIdentiferCode1", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	if (countryObject.legalId2 != "null" && countryObject.legalId2 != "") {
		newoption = new Option(countryObject.legalId2, "legalIdentiferCode2", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	if (countryObject.legalId3 != "null" && countryObject.legalId3 != "") {
		newoption = new Option(countryObject.legalId3, "legalIdentiferCode3", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	if (countryObject.legalId1 == "" && countryObject.legalId1 == "" && countryObject.legalId1 == "" ) {
		newoption = new Option("", "", false, false);
		idInput.options[idInput.options.length] = newoption;
		document.form1.idValue.value = "";
	}
	idInput.selectedIndex = 0;
	if (document.getElementById)
		if (idInput.options[0].value != "")
			document.form1.idValue.style.visibility = "visible";
		else		
			document.form1.idValue.style.visibility = "hidden";
	
	displayStateList2(country);
}

// subscriptionForm.xsl _________________________________________________________________________
function loadCountry() {
	var countryList = document.form1.country;
	switch (prof) {
		case "Ak01":
		case "Ak03": selectCountry('121');break;
		case "Ak02": selectCountry('520');break;
		case "Ar01": selectCountry('135');break;
		case "Be01": selectCountry('155');break;
		case "Br01": selectCountry('175');break;
		case "Ch01": selectCountry('570');break;
		case "Hk01": selectCountry('345');break;
		case "Ir01": selectCountry('375');break;
		case "It01": selectCountry('390');break;
		case "Jp01": selectCountry('395');break;
		case "Okv01":selectCountry('145');break;
		case "Pr03": selectCountry('280');break;
		case "Pr04":
		case "Pr06": selectCountry('285');break;
		case "Pr09": selectCountry('210');break;
		case "Sap01":selectCountry('140');break;
		case "Sap02":selectCountry('355');break;
		case "Sap03":selectCountry('450');break;
		case "Sap04":selectCountry('530');break;
		case "Sap05":selectCountry('558');break;
		case "Sap06":selectCountry('590');break;
		case "Tr01": selectCountry('610');break;
		case "Uk01": selectCountry('555');break;
		case "Pr02":
		case "Pr05":
		case "Pr07":
		case "Pr08":
		default:	 selectCountry('100');break;
	}
	loadLegalId(countryList.options[countryList.selectedIndex].value,document.form1.idInput);
	if (prof == "Uk01") popUpRapport("/allnetWeb/xml-internal3/A01/A01_Uk01/source/terms.html");
}

function selectCountry(countInd) {
	var countryList = document.form1.country;
	for (var i=0; i<countryList.length; i++) {
		if (countryList.options[i].value == countInd) {
			countryList.selectedIndex = i;
			break;
		}
	}
}

function loadLegalId(country, idInput) {
	var siz= idInput.options.length		
	for (k=0; k< siz; k++)
		idInput.options[0]= null;	

	var countryObject = getCountry(country);
	var newoption

	if (countryObject.legalId1 != "null" && countryObject.legalId1 != "") {
		newoption = new Option(countryObject.legalId1, "legalIdentiferCode1", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	if (countryObject.legalId2 != "null" && countryObject.legalId2 != "") {
		newoption = new Option(countryObject.legalId2, "legalIdentiferCode2", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	if (countryObject.legalId3 != "null" && countryObject.legalId3 != "") {
		newoption = new Option(countryObject.legalId3, "legalIdentiferCode3", false, false);
		idInput.options[idInput.options.length] = newoption;
	}
	newoption = new Option(cofaceNumber, "cofaceNumber", false, false);		
	idInput.options[idInput.options.length] = newoption;
	idInput.options.selectedIndex = 0;
}

function subscriptionFormValidation(passForm) {
	if (document.all) passForm = passForm.all;
	if ((passForm.companyName.value== "") || (passForm.town.value== "") || (passForm.country.value== "") || (passForm.name.value== "") || (passForm.mail.value== "") || (passForm.comment.value== "") ) {
		alert(mes1);
	} else {
		if (!isEmail(passForm.mail.value))
			alert(mes3);
		else
			submitRequest();
	}
}

function submitRequest() {
  	var anUrl= getAScenarioMarkOutUrl("SubscriptionFormPage","SubscriptionForm.submitSubscription");
  	var aForm= document.form1;
	idInputL= aForm.idInput.options[aForm.idInput.selectedIndex].text;
	anUrl+="&SubscriptionInput.country=" + aForm.country.options[aForm.country.selectedIndex].value;
	anUrl+="&SubscriptionInput.name=" + escape(aForm.name.value);
	anUrl+="&SubscriptionInput.firstName=" + escape(aForm.firstName.value);
	anUrl+="&SubscriptionInput.adress1=" + escape(aForm.adress1.value);
	anUrl+="&SubscriptionInput.adress2=" + escape(aForm.adress2.value);
	anUrl+="&SubscriptionInput.adress3=" + escape(aForm.adress3.value);
	anUrl+="&SubscriptionInput.postCode=" + escape(aForm.postCode.value);
	anUrl+="&SubscriptionInput.county=" + aForm.county.value;
	anUrl+="&SubscriptionInput.town=" + escape(aForm.town.value);
	anUrl+="&SubscriptionInput.idInput=" + aForm.idInput.value;
	anUrl+="&SubscriptionInput.idValue=" + aForm.idValue.value;
	anUrl+="&SubscriptionInput.idInputL=" + escape(idInputL);
	anUrl+="&SubscriptionInput.companyName=" + escape(aForm.companyName.value);
	anUrl+="&SubscriptionInput.job=" + escape(aForm.job.value);
	anUrl+="&SubscriptionInput.mail=" + aForm.mail.value;
	anUrl+="&SubscriptionInput.tel=" + escape(aForm.tel.value);
	anUrl+="&SubscriptionInput.fax=" + escape(aForm.fax.value);
	anUrl+="&SubscriptionInput.contractNumber=" + escape(aForm.contractNumber.value);
	anUrl+="&SubscriptionInput.comment=" + escape(aForm.comment.value);
	goToUrl(anUrl);
}

// insuredModif.xsl, initialAgreement.xsl _________________________________________________________________________
function isNumKey(evt) {
	if (navigator.appName.indexOf("Netscape") != -1)
		keyCode = evt.which;
	else
		keyCode = evt.keyCode;
	return (keyCode == 0 || (keyCode >= 48 && keyCode <= 58));
}

function processInput(fld, evt) {
	if (isNumKey(evt)) return true;
	return false;
}


// login.xsl, loginError.xsl, search.xsl, search2.xsl, portfolio.xsl _________________________________________________________________________
function processOnEnter(fld, evt) {
	evt = (evt) ? evt : (window.event) ? window.event : "";
	if (evt.keyCode == 13) return true;
	return false;
}

function upperAndSubmitSearch(t) {
	upperMe(t);
	submitSearchForm();
}

function upperAndSubmitSearch2(t) {
	upperMe(t);
	submitSearch2();
}


// sponsorshipForm.xsl _________________________________________________________________________
function sponsorshipFormValidation(passForm) {
	if ((passForm.elements[5].value== "") || (passForm.elements[6].value== "") || (passForm.elements[8].value== "") ) {
			alert(mes1);
	} else {
		if (!isEmail(passForm.elements[8].value))
			alert(mes2);
		else
			passForm.submit();
	}
}


// companyInfo.xsl _________________________________________________________________________
var coefArr = ["", "k", "M", "G", "T"]

function companyInfoFormValidation(passForm) {
	if ( (passForm.elements[5].value == "" || passForm.elements[5].value == " ") && passForm.elements[6].value == "" )
		alert(msgCompanyReferenceMissing);
	else if (passForm.elements[6].value != "" && passForm.elements[6].value == 0)
			alert(msgAmount + ' ' + msgSuperiorTo + ' 0.');
	else
		document.formRef.submit();
}

function requestCoverageAmount() {
	if (managementGranted == 'false') {
		alert(msgViewMode);
		return;
	}
	var label_enter_amount2 = label_enter_amount + ' ' + coefArr[(coef.length)/3] + ' ' + curr + '.';
	var amount = prompt(label_enter_amount2, document.formRef.elements[6].value);
	if (amount == null || amount == '') return false;
	if (amount.length > 6 || isNaN(parseInt(amount))) {
		alert(label_error_amount);
		document.formRef.elements[6].value = '';
		return false;
	}
	if (!validateCoveAmount(amount, coef, curr, document.formRef.elements[6])) return false;
	if (amount == 0) amount = '';
	document.formRef.elements[6].value = amount;
	document.formRef.submit();
}

function validateCoveAmount(amount, coef, curr, elemt) {
	if (parseInt(amount) > 5000)
		if (!confirm(mes30 + " " + amount + coef + " " + curr + ".\n" + mes31)) {
			elemt.value = '';
			return false;
		}
	return true;
}

// portfolio.xsl, search.xsl _________________________________________________________________________
function printContract(contractIs,contractNbr,contractType,contractShortName) {
  if (contractShortName != "null" && !document.layers)
    document.write(' <a title="' + contractShortName + '">')
  
  document.write(contractIs + ' ' + contractNbr + '-' + contractType );
  
  if (contractShortName != "null" && !document.layers)
	document.write('</a>' );
}


// companyDetail.xsl _________________________________________________________________________
function whichDiv() {
	if (document.getElementById) {
		var nbrOnglet = 0;
		if (onglet3 != "0" && uBuyer != 'W') {
			hideDiv('insurance');
			hideDiv('notation');
			showDiv('report');
			ongletSelected = 3;
			nbrOnglet++;
		}
		if ( (onglet2 != "0" || (acp1 != "0" && acp2 == 'true')) && uBuyer == 'N' ) {
			hideDiv('insurance');
			hideDiv('report');
			showDiv('notation');
			ongletSelected = 2;
			nbrOnglet++;
		}
		if ( ((onglet1 != "0" && onglet1 != "10" ) || (onglet1 == "10" && insur == "true")) && uBuyer != 'I' ) {
			hideDiv('notation');
			hideDiv('report');
			showDiv('insurance');
			ongletSelected = 1;
			nbrOnglet++;
		}
		if (nbrOnglet <= 1) {
			onglet1 = "0";
			onglet2 = "0";
			onglet3 = "0";
		}
		if (!document.all) showOnglets();
		if (nbrOnglet > 0) document.getElementById('link' + ongletSelected).click();
	}
}
   
function showOnglets() {
	var buffer = "";
	buffer += '<table border="0" cellspacing="0" cellpadding="0" align="left">';
	buffer += '<tr>';
	if ( ((onglet1 != "0" && onglet1 != "10" ) || (onglet1 == "10" && insur == "true")) && uBuyer != 'I' ) {
		if (ongletSelected == 1)
			buffer += '<td class="ongletActif"> <a href="javascript:ongletSelected=1;void(0);showDiv(\'insurance\');hideDiv(\'notation\');hideDiv(\'report\');" id="link1">' + label1 + '</a> </td> ';
		else
			buffer += '<td class="ongletInactif"> <a href="javascript:ongletSelected=1;void(0);showDiv(\'insurance\');hideDiv(\'notation\');hideDiv(\'report\');" id="link1">' + label1 + '</a> </td> ';
	}
	if ( (onglet2 != "0" || (acp1 != "0" && acp2 == 'true')) && uBuyer == 'N' ) {
		if (ongletSelected == 2)
			buffer += '<td class="ongletActif"> <a href="javascript:ongletSelected=2;void(0);showDiv(\'notation\');hideDiv(\'insurance\');hideDiv(\'report\');" id="link2">' + label2 + '</a> </td> ';
		else
	  		buffer += '<td class="ongletInactif"> <a href="javascript:ongletSelected=2;void(0);showDiv(\'notation\');hideDiv(\'insurance\');hideDiv(\'report\');" id="link2">' + label2 + '</a> </td> ';
	}
	if (onglet3 != "0" && uBuyer != 'W' ) {
		if (ongletSelected == 3)
	  		buffer += '<td class="ongletActif"> <a href="javascript:ongletSelected=3;void(0);showDiv(\'report\');hideDiv(\'notation\');hideDiv(\'insurance\');" id="link3">' + label3 + '</a> </td> ';
		else
	  		buffer += '<td class="ongletInactif"> <a href="javascript:ongletSelected=3;void(0);showDiv(\'report\');hideDiv(\'notation\');hideDiv(\'insurance\');" id="link3">' + label3 + '</a> </td> ';
	}
	buffer += '</tr>';
	buffer += '</table>';
	buffer += '<br><br>';
	if (onglet1 == "0" && onglet2 == "0" && onglet3 == "0") buffer = "<hr>";
	document.getElementById('onglets').innerHTML = buffer;
}

function showDiv(divName) {
	if (document.getElementById) {
		showOnglets();
		document.getElementById(divName).style.display = "block";
	}
}

function hideDiv(divName) {
	if (document.getElementById)
		document.getElementById(divName).style.display = "none";
}

function goBackButton() {
	if (window.location.href.indexOf("SearchCompanyResultPage.detailCompany") != -1 || window.location.href.indexOf("PortfolioEventPage.detailCompany") != -1)
		history.back();
	else {
		switch (getCurrentPage()) {
			case 'SearchCompanyPage':
				goToScenarioMarkOut('MainPage','MainPage.goSearchBuyer');
			case 'PortfolioPage':
				goToScenarioMarkOut('MainPage','MainPage.goPortfolio');
			case 'PortfolioEventPage':
				goToScenarioMarkOut('MainPage','MainPage.goPortfolioEvent');
			default:
				goToScenarioMarkOut('MainPage','MainPage.goPortfolio');
		}
	}
}

function turnInsuredRatingIntoAgreement(express) {
	var anUrl = getAScenarioMarkOutUrl('CompanyDetailPage','CompanyDetailPage.turnInsuredRatingIntoAgreement');
	anUrl += '&transformRating.expressTransformRating=' + express;
	goToUrl(anUrl);
}

function modifyAgreement(express) {
	var anUrl = getAScenarioMarkOutUrl('CompanyDetailPage','CompanyDetailPage.modifyAgreement');
	anUrl += '&transformRating.expressTransformRating=' + express;
	goToUrl(anUrl);
}

function displayGuarantorDetails(ind) {
	var curDiv = eval(document.getElementById('guarantor' + ind));
	if (curDiv.style.display == 'none')
		curDiv.style.display = 'block';
	else
		curDiv.style.display = 'none';
}

function printDetails() {
	if (document.getElementById) {
		var guarantorOn = true;
		showDiv('insurance');
		showDiv('notation');
		showDiv('report');
		if (document.getElementById('guarantor') && document.getElementById('guarantor').style.display == 'none') {
			guarantorOn = false;
			displayGuarantorDetails();
		}
		imprime();
		whichDiv();
		if (!guarantorOn) displayGuarantorDetails();
	} else
		imprime();
}	

function viewProductHistory(product) {
	var anUrl = getAScenarioMarkOutUrl('CompanyDetailPage','CompanyDetailPage.agreementHistory');
	anUrl += '&ProductHistory.productType=' + product;
	goToUrl(anUrl);
}

function reOrderRatingCheck(monitored) {
	var anUrl;
	if (!confirm(msg_reorder)) return false;
	if (!monitored)
		anUrl += goToScenarioMarkOut('CompanyDetailPage','CompanyDetailPage.commandNotation');
	else
		anUrl += goToScenarioMarkOut('CompanyDetailPage','CompanyDetailPage.commandMonitoredRating');
}


// ratingCommandACP Page _________________________________________________________________________
function setActionType() {
	var actionType = "";
	var urlInd = window.location.href.indexOf("ActionType.actionValue")
	if (urlInd != -1)
		actionType = window.location.href.substring(urlInd+23,(window.location.href.length));
	return actionType;
}

function submitFormACP() {
	if (document.form1.request_amount.value == "" || document.form1.request_amount.value < 1 )
		alert(mes4);
	else {
		var actionType = setActionType();
		if (actionType != "" && actionType == "Modify")
			anUrl= getAScenarioMarkOutUrl("ratingCommandACP","ratingModifyACP.submit");
		anUrl+= "&AgreementInput.request_date=" + document.form1.effect_date.value +
		"&AgreementInput.request_amount=" + document.form1.request_amount.value;
		goToUrl(anUrl);
	}
}


// modelsList Page _________________________________________________________________________
function goToModelsLetter(countryIso, countryCode) {
	var anUrl = getAScenarioMarkOutUrl('ModelsListPage','ModelsListPage.letters');
	anUrl += '&ModelCountry.countryIso=' + countryIso + '&ModelCountry.countryCode=' + countryCode;
	goToUrl(anUrl);
}


// exceedingCTDeclaration.xsl _________________________________________________________________________
function calendarReturnedDate(dateIsValid) {
	var curField = eval("document.form1.invoiceDate" + document.form1.dateModified.value);
	if (!dateIsValid) curField.value = '';
	else if (document.form1.effect_date.value != '') {
		curField.value = document.form1.effect_date.value;
		document.form1.effect_date.value = '';
	}
}

function updateDateModified(num) {
	document.form1.dateModified.value = num;
	popUp('/allnetWeb/xml-internal3/A01/source/calendar.html');
}

function validateECTForm(num) {
	var curDate, curAmount, curNotes;
	for (var i=0; i < 8; i++) {
		curDate = eval("document.form1.invoiceDate" + i);
		curAmount = eval("document.form1.amount" + i);
		if ( (curDate.value != '' && curAmount.value == '') || (curDate.value == '' && curAmount.value != '') ) {
			alert(err_input_incomplete);
			return;
		}
	}
	if (document.form1.inputAmount.value.length < 1 || document.form1.totalAmount.value.length < 1 || document.form1.inputAmount.value.length == "0") {
		alert(err_input_incomplete);
		return;
	}

	var anUrl = getAScenarioMarkOutUrl('ExceedingCTDeclarationPage','ExceedingCTDeclarationPage.submit');
	anUrl += '&ectDeclaration.currency=' + currency;
	anUrl += '&ectDeclaration.coefficient=' + coef;
	anUrl += '&ectDeclaration.totalAmount=' + document.form1.inputAmount.value;
	for (var i=0; i < 8; i++) {
		curDate = eval("document.form1.invoiceDate" + i);
		curAmount = eval("document.form1.amount" + i);
		curNotes = eval("document.form1.comment" + i);
		anUrl += '&ectDeclaration.invoiceDate' + i + '=' + formatKZUDate(curDate.value);
		anUrl += '&ectDeclaration.amount' + i + '=' + curAmount.value;
		anUrl += '&ectDeclaration.comment' + i + '=' + curNotes.value;
	}
	goToUrl(anUrl);
}

function calculateTotalAmount() {
	var total = 0;
	for (var i=0; i < 8; i++) {
		curAmount = eval("document.form1.amount" + i);
		if (isNaN(curAmount.value) || curAmount.value != '')
			total += parseInt(curAmount.value);
	}
	document.form1.totalAmount.value = total;
}

function invoiceDateValidation(curField, num) {
	document.form1.dateModified.value = num;
	if (curField.value.length > 0) dateValidation(curField.value);
}


// help pages _________________________________________________________________________
function getHelpProfile(codeProfil) {
	switch (codeProfil) {
		case "Pr10":
			return "A01_Pr10/";
		default:
			return "";
	}
}
