
// swap images
function imgOn(imgName, imgPath) {
	document[imgName].src = imgPath;
}

function imgOff(imgName) {
	document[imgName].src = '/images/spacer.gif';
}

// go to URLLANG
function goToUrlLang(objList, dynamic) {
	i = objList.selectedIndex;
	if (i == 0) 
	  return;
	var lang = objList.options[i].value;
	if (dynamic) {
		var navig = getNavigationBar();
		//getAScenarioMarkOutUrl('index', lang, navig, false);
		getAScenarioMarkOutUrl2(lang);
	} else
		goToUrl("/" + lang + "/index.html");
}

// go to Demo
function goToDemo(demoName,w,h) {
	var lang = document.form1.selectLang.value;
	if (!document.layers) {
	var buffer = "";
	buffer += ' <html> \n';
	buffer += ' <head> \n';
	buffer += ' <title>@rating</title> \n';
	buffer += ' <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> \n';
	buffer += ' </head> \n';
	buffer += ' <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"> \n';
	buffer += ' <table height="100%" border="0" cellspacing="0" cellpadding="0" align="center"> \n';
	buffer += ' <tr> \n';
	buffer += ' <td valign="middle"> \n';
	buffer += ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + w + '" height="' + h + '"> \n';
	buffer += '   <param name="movie" value="/media/' + lang + '/' + demoName + '.swf"> \n';
	buffer += '   <param name="quality" value="high"> \n';
	buffer += '   <embed src="/media/' + lang + '/' + demoName + '.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed> \n';
	buffer += ' </object> \n';
	buffer += ' </td> \n';
	buffer += ' </tr> \n';
	buffer += ' </table> \n';
	buffer += ' </body> \n';
	buffer += ' </html> \n';
	popWinDemo = window.open('', 'popupWindowDemo', 'top=20,left=20,width='+(w*1+20)+',height='+(h*1+20)+',menubar=no,scrollbars=no,toolbar=no,location=no,status=no');
	popWinDemo.document.open();
	popWinDemo.document.write(buffer);
	popWinDemo.document.close();
	popWinDemo.focus();
	} else { 
	popUp('/media/' + lang + '/' + demoName + '.swf'); 
	}
}

function goToCofanetDemo(w,h) {
	var lang = document.form1.selectLang.value;
	window.open('http://www.coface.com/allnetWeb/xml-internal3/flash/' + lang + '/index.htm', 'popupWindowDemo', 'top=20,left=20,width='+w+',height='+h+',menubar=no,scrollbars=no,toolbar=no,location=no,status=no');
}

// pop up window
function popUp(url) {
	var popWin = null;
  	popWin = window.open(url, 'popupWindow', 'top=20,left=20,width=800,height=600,menubar=no,scrollbars=yes,toolbar=no,location=no,status=no');
	//if (document.layers) setTimeout("popWin.location.reload()", 25);
	if (popWin != null && popWin.open && (window.location.href.indexOf('partners.') != -1 && document.getElementById) ) popWin.focus();
}

// pop up window 2
function popUp2(url) {
  	popWin2 = window.open(url, 'popupWindow2', 'top=80,left=80,width=800,height=600,menubar=no,scrollbars=yes,toolbar=no,location=no,status=no');
	if (popWin2 != null && popWin2.open) popWin2.focus();
}
// pop up window (tailles specifiques pour affichage fenetres "thanx")
function popUp3(url) {
  	popWin3 = window.open(url, 'popupWindow3', 'top=100,left=100,width=700,height=300,menubar=no,scrollbars=no,toolbar=no,location=no,status=no');
	if (popWin3 != null && popWin3.open) popWin3.focus();
}
// pop up window pour affichage fenetre Newsletter
function popUp4(url) {
	var popWin4 = null;
  	popWin4 = window.open(url, 'popupWindow4', 'top=20,left=20,width=800,height=600,menubar=no,scrollbars=yes,toolbar=yes,location=no,status=no');
	//if (document.layers) setTimeout("popWin4.location.reload()", 25);
	if (popWin4 != null && popWin4.open && (window.location.href.indexOf('partners.') != -1 && document.getElementById) ) popWin4.focus();
}



// Generic functions
function goToUrl(anUrl) {
	window.location.href = anUrl;
}


function getAScenarioMarkOutUrl(page, lang, navig, init){
	var sysurl="";
	if (init)
		sysurl = "/G3.servlet?codeApplication=xpageloader&wf.page=InitPage&wf.action=InitPage.init&format=html&lang="+lang+"&Page.pageName="+page+"&PageHeader.navigationBar="+navig+'&PageHeader.image='+getImage()+'&PageHeader.urlBack='+getUrlBack()
	else
		sysurl = "/G3.servlet?codeApplication=xpageloader&wf.page=others&wf.action=others.pageDispatcher&format=html&lang="+lang+"&Page.pageName="+page+"&PageHeader.navigationBar="+navig+'&PageHeader.image='+getImage()+'&PageHeader.urlBack='+getUrlBack()
	return sysurl;
}

//function getAScenarioMarkOutUrl(page, lang, navig, scenario, initpage, action){
//	var sysurl = getsysUrl();
//	sysurl += "/G3.servlet?codeApplication=true&wf.scenario="+scenario+"&wf.page="+initpage+"&wf.action="+action+"&format=html&lang="+lang+"&Page.pageName="+page+"&PageHeader.navigationBar="+navig+"&Language.isoCode="+lang
//	return sysurl;
//}
function getAScenarioMarkOutUrl2(lang){
	var sysurl = "";
	sysurl=sysurl+"/XCRCofaceratingHomePage.servlet?lang=" + lang + "&homePage=home";
	goToUrl(sysurl);
}
	
function goToScenarioMarkOut(page, lang, navig, init){
	var anUrl= getAScenarioMarkOutUrl(page, lang, navig, init);
	goToUrl(anUrl);
}
//function goToScenarioMarkOut(page, lang, navig, scenario, initpage, action){
//	var anUrl= getAScenarioMarkOutUrl(page, lang, navig, scenario, initpage, action);
//	goToUrl(anUrl);
//}
	
function getNavigationBar() {
	var navig
	var urlInd = window.location.href.indexOf("PageHeader.navigationBar")
	if ( urlInd != -1) {
		navig = window.location.href.substring(urlInd+29,(window.location.href.length+1));
	} else {
		navig = 0;
	}
	return navig;
}	

function goService(service) {
	var lang=getLang();
	var navig=getNavigationBar(); 
	var image=getImage();
	var urlBack=getUrlBack();
	var urlBank='/bankAtAClick.servlet?lang='+lang+'&PageHeader.navigationBar='+navig+'&PageHeader.image='+image+'&PageHeader.urlBack='+urlBack
	var urlProt='/protectionAtClick.servlet?lang='+lang+'&PageHeader.navigationBar='+navig+'&PageHeader.image='+image+'&PageHeader.urlBack='+urlBack
	var urlPage='/G3.servlet?codeApplication=xpageloader&wf.page=InitPage&wf.action=InitPage.init&lang='+lang+'&PageHeader.navigationBar='+navig+'&PageHeader.image='+image+'&PageHeader.urlBack='+urlBack
	var urlXql='/Xql.servlet?lang='+lang+'&PageHeader.navigationBar='+navig+'&PageHeader.image='+image+'&PageHeader.urlBack='+urlBack
	if (service == 'serv1') {
	 goToUrl(urlBank);
	}
	if (service == 'serv2') {
	 goToUrl(urlXql);
	}
	if (service == 'serv3') {
	 goToUrl(urlProt);
	}
	if (service == 'home') {
	 goToUrl(urlPage);
	}
	}
	
	// pop up window with building of the URL before.
function popUpFormWithSelect(form,url,select) {
  var urlComplete=url;
  var nbElement = form.length;
	
  for (var i=0; i<nbElement; i++) {
   	if (    (form.elements[i].type == "hidden")
         || (form.elements[i].type == "textarea")
         || ((form.elements[i].type == "select-one") && (select=="true"))
  	     || (form.elements[i].type == "text")) {
  	
    	urlComplete += "&" + form.elements[i].name + "=" + form.elements[i].value;
    }
  }
  //alert("urlComplete: " + urlComplete);
  popUp3(urlComplete);
}

// pop up window with building of the URL before. Not including the select input.
function popUpForm(form,url) {
	popUpFormWithSelect(form,url,'false');
}

function showImage(){
	var image=getImage();
	var urlBack=getUrlBack();
	
	document.write('<td width="130" colspan="2" rowspan="3" valign="top">');
	if (urlBack != "") {
		document.write('<a href="' + urlBack + '">');
	}
	
	if ( image.indexOf("logocofacerating.gif") != -1) {
		document.write('<img src="' + image + '" width="130" height="41" border=0/>');
	} else {
		document.write('<img src="' + image + '" width="100" height="33" border=0/>');	
	}
	
	if (urlBack != "") {
		document.write('</a>');
	}
	document.write('</td>')
}
	
function getDefaultImage(){
	document.write('<td width="130" colspan="2" rowspan="3" valign="top"><img src="/images/logo.gif" width="130" height="41"/></td>');
}
	
	
	

