function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


unOf = new Image(); unOf.src = "images/home/chiffres/1-gray.gif" ;
unOn = new Image(); unOn.src = "images/home/chiffres/1-red.gif" ;
deuxOf = new Image(); deuxOf.src = "images/home/chiffres/2-gray.gif" ;
deuxOn = new Image(); deuxOn.src = "images/home/chiffres/2-red.gif" ;
troisOf = new Image(); troisOf.src = "images/home/chiffres/3-gray.gif" ;
troisOn = new Image(); troisOn.src = "images/home/chiffres/3-red.gif" ;
sendOf = new Image(); sendOf.src = "images/home/submit/find-gray.gif" ;
sendOn = new Image(); sendOn.src = "images/home/submit/find-red.gif" ;


function rollover(btnName,btnSwitch)
{
	if(document.images)document.images[btnName].src = eval(btnSwitch + ".src")
}

function highlightform(which){
	unhighlightform();
	if(which == 1){
		rollover('un','unOf');
		rollover('deux','deuxOn');
	}
	if(which == 2){
		rollover('un','unOf');
		rollover('trois','troisOn');
	}
	if(which == 3){
		rollover('un','unOf');
		rollover('send','sendOn');
	}
}

function unhighlightform(){
	rollover('un','unOn');
	rollover('deux','deuxOf');
	rollover('trois','troisOf');
	rollover('send','sendOf');
}




function dynamicSelect(id1, id2) {
	// Browser and feature tests to see if there is enough W3C DOM support
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_mac = (agt.indexOf("mac") != -1);
	if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) {
		// Obtain references to both select boxes
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		// Clone the dynamic select box
		var clone = sel2.cloneNode(true);
		// Obtain references to all cloned options
		var clonedOptions = clone.getElementsByTagName("option");
		// Onload init: call a generic function to display the related options in the dynamic select box
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		// Onchange of the main select box: call a generic function to display the related options in the dynamic select box
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
	}
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	//fix the bg color of the select boxes because of Google Toolbar
	document.getElementById("COUNTRY_CODE_ORIGIN").style.backgroundColor = "#ed1c24";
	document.getElementById("OPERATOR_ID_ORIGIN").style.backgroundColor = "#ed1c24";
	document.getElementById("COUNTRY_CODE").style.backgroundColor = "#ed1c24";

	// Delete all options of the dynamic select box
	while (sel2.options.length) {
		sel2.remove(0);
	}
	// Create regular expression objects for "select" and the value of the selected option of the main select box as class names
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	//alert(sel1.options[sel1.selectedIndex].value)
	feedbackform('COUNTRY_CODE_ORIGIN',sel1.options[sel1.selectedIndex].value);
	// Iterate through all cloned options
	for (var i = 0; i < clonedOptions.length; i++) {
		// If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			// Clone the option from the hidden option pool and append it to the dynamic select box
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}





var field_1 = false;
var field_2 = false;
var field_3 = false;
var field_4 = false;

function feedbackform(field,chosen){
	if(field == 'COUNTRY_CODE_ORIGIN'){
		if(chosen != 0){ field_1 = true; }
		else{ field_1 = false; }
	}
	else if(field == 'OPERATOR_ID_ORIGIN'){
		if(chosen != 0){ field_2 = true; }
		else{ field_2 = false; }
	}
	else if(field == 'contract_type'){
		if(chosen != 0){ field_3 = true; }
	}
	else if(field == 'COUNTRY_CODE'){
		if(chosen != 0){ field_4 = true; }
		else{ field_4 = false; }
	}

	if(field_1 && field_2 && field_3 && field_4){ highlightform(3); }
	else if(field_1 && field_2 && field_3){ highlightform(2); }
	else if(field_1){ highlightform(1); }
	else { unhighlightform(); }

	//alert("field_1:" + field_1 + "\n" + "field_2:" + field_2 + "\n" + "field_3:" + field_3 + "\n" + "field_4:" + field_4)
}

function initform(){
	document.myform.COUNTRY_CODE_ORIGIN.selectedIndex = 0;
	document.myform.OPERATOR_ID_ORIGIN.selectedIndex = 0;
	document.myform.COUNTRY_CODE.selectedIndex = 0;
}