
var leftOptions = [];

function checkBoxValidate(cb) {
for (j = 0; j < 17; j++) {
if (eval("document.myForm.alert_region[" + j + "].checked") == true) {
document.myForm.alert_region[j].checked = false;
if (j == cb) {
document.myForm.alert_region[j].checked = true;
         }
      }
   }
}

function initPage()
{
	oLeft = document.myForm.leftSelect;
	oRight = document.myForm.rightSelect;
	oLeftRight = document.getElementById( "btnLeft2Right" );
	oRightLeft = document.getElementById( "btnRight2Left" );
	
	oSelectedValues = document.myForm.selectedValues;
	oDebugInfo = document.getElementById( "debugInfo");
	
	if ( leftOptions.length == 0 )
	{
		for ( var i = 0; i < oLeft.options.length; i++ )
		{
			var o = oLeft.options[ i ];
			leftOptions.push( [ o.value, o.text, 1 ] );
		}
	};
};

function left2right()
{
	var leftIndex = oLeft.selectedIndex,
	o = oLeft.options[ leftIndex ],
	newOptionIndex = oRight.options.length;
	
	if ( newOptionIndex == 1 && oRight.options[ 0 ].text == "" )
		newOptionIndex--;
		
	oRight.options[ newOptionIndex ] = new Option( o.text , o.value );
	
	oSelectedValues.value += o.value + ",";
	
	rebuildLeft( o );	
	
	if ( leftIndex == oLeft.options.length )
		leftIndex--;

	oLeft.selectedIndex = leftIndex
	
	checkButtons();

};

function right2left()
{
	var rightIndex = oRight.selectedIndex,
	o = oRight.options[ rightIndex ];

	for ( var i = 0; i < leftOptions.length; i++ )
	{
		if ( leftOptions[ i ][ 0 ] == o.value )
		{
			 leftOptions[ i ][ 2 ] = 1;
			 break;
		};
			
	};
	
	oSelectedValues.value = oSelectedValues.value.replace( new RegExp( "(,?)" + o.value + "," ), "$1" );
	
	rebuildLeft();
	
	for (var i = oRight.selectedIndex; i < oRight.options.length - 1; i++ )
	{
		oRight.options[ i ].value = oRight.options[ i + 1 ].value;
		oRight.options[ i ].text = oRight.options[ i + 1 ].text;
	};
	oRight.options.length--;

	if ( rightIndex == oRight.options.length )
		rightIndex--;

	oRight.selectedIndex = rightIndex
	
	checkButtons();		
	
};

function rebuildLeft( o )
{
	oLeft.options.length = 0;
	leftOptionIndex = 0;
	for ( var i = 0; i < leftOptions.length; i++ )
	{
		var theOption = leftOptions[ i ];
		if ( 1 * theOption[ 2 ]  && ( !o || theOption[ 0 ] != o.value ) )
		{
			oLeft.options[ leftOptionIndex++ ] = new Option( theOption[ 1 ], theOption[ 0 ] );
		}
		else 
		{
			theOption[ 2 ] = 0;
		}
	};
	
	

};


function checkButtons()
{
	oLeftRight.disabled = ( oLeft.selectedIndex == -1 );
	oRightLeft.disabled = ( oRight.selectedIndex == -1 );
};

var commun_url = "/commun_de/";

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_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_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];}
}

function MM_reloadPage(init) {  //Netscape 4 Resize Fix
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function verif_rech_motcle(masque, val)
{
	if (	(val == "") || (val == masque) || (val.length == 1 ) )
	{ 
		 alert('Bitte geben Sie ein Suchwort ein'); 
		 return false; 
	}
	else
	{
		document.getElementById("search_go").disabled = true;
	}
}
function verif_rech_metier(val)
{
	if (val == "")
	 { 
			alert('Bitte wählen Sie eine Branche aus!'); 
		  
		  return false; 
	 } 
}
function change_action()
{
	document.form_trade.action = document.form_trade.metier.value;
}
//Fonction qui vide le contenu du champ
function vide_champ(field,rech) 
{ 
	val = field.value;
	
	if (val == rech) 
	{
		field.value = "";
	} 
}

function addFavorite(id_site) 
{
	js_audience('favoris', id_site);
	
	qtitle = "Quotatis : Handwerk, Dienstleistungen, Versicherungen: Kostenlos bis zu 5 Angebote mit einer Anfrage";

	if( window.sidebar && window.sidebar.addPanel ) {
		//Gecko (Netscape 6 etc.) - add to Sidebar
		window.sidebar.addPanel(qtitle,'http://www.quotatis.de?sqn=1621', '' );
	} else if( window.external && ( navigator.platform == 'Win32' ||
		  ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
		//IE Win32 or iCab - 
		window.external.AddFavorite('http://www.quotatis.de?sqn=1621',qtitle);
	} else if( window.opera && window.print ) {
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
	} else if( document.layers ) {
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
		//not target page)
		window.alert( 'Bitte drücken Sie CTRL + D um die Seite zu Ihern Boockmarks hinzuzufügen' );
	} else {
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
	return false;
}


function js_audience(prg, id_site)
{
	obj = MM_findObj('PrgF');
	obj.src = commun_url + "Progs_http/Prog_count_aud.php?prg="+prg+"&id_site="+id_site;
}
function incident_desac()
{
	ouverture_incident = false;
}
function popcnil()
{
	var positiontop=document.body.clientHeight/2;
	var positionleft=document.body.clientWidth-600;
	positiontop=positionleft=10;
	winopened = window.open(commun_url + 'popup/popcnil.php','popcnil','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=600,height=500,top='+ positiontop +',left='+ positionleft);
	winopened.focus();
}
