chosen = 4;
// Initialisiert den Waehler auf Seite 1:
function initChooser() {
  $('one').addEvents({
  'mouseenter': function(){
	  if (chosen!=1 && chosen!=4) {
		  hover(1);
	  }	
  },
  'mouseleave': function(){
	  if (chosen!=1 && chosen!=4) {
		  leave(1);
	  }
  },
  'click': function() {
	  chosen = 1;
	  choose(1);
	  $('priceselect').value = '1';
  }
  });
  $('two').addEvents({
  'mouseenter': function(){
	  if (chosen!=2 && chosen!=4) {
		  hover(2);
	  }	
  },
  'mouseleave': function(){
	  if (chosen!=2 && chosen!=4) {
		  leave(2);
	  }
  },
  'click': function() {
	  chosen = 2;
	  choose(2);
	  $('priceselect').value = '2';
  }
  });
  $('three').addEvents({
  'mouseenter': function(){
	  if (chosen!=3 && chosen!=4) {
		  hover(3);
	  }	
  },
  'mouseleave': function(){
	  if (chosen!=3 && chosen!=4) {
		  leave(3);
	  }
  },
  'click': function() {
	  chosen = 3;
	  choose(3);
	  $('priceselect').value = '3';
  }
  });
  $('priceselect').addEvents({
  'change': function() {
	  if (this.value == '1') {
		  chosen = 1;
		  choose(1);
	  }
	  else if (this.value == '2') {
		  chosen = 2;
		  choose(2);
	  }else if (this.value == '3') {
		  chosen = 3;
		  choose(3);
	  }else {
		  chosen = 4;
		  leave(4);
		  waitAndBlink();
	  }
  }
  });
}
// Chooser Seite 1 Blinken
var anAus = false;
function waitAndBlink(){
	if(anAus && chosen==4){
		hover(4);
	}
	else {
		leave(4);
	}
	anAus=!anAus;
	if (chosen==4) setTimeout("waitAndBlink()",700);
}
function hover(who) {
  if (who==1 || who==4) {
	$('one').style.backgroundPosition = "0px -222px";
	$('buttonone').style.color = "#ffffff";
  }
  if (who==2 || who==4) {
	$('two').style.backgroundPosition = "0px -222px";
	$('buttontwo').style.color = "#ffffff";
  }
  if (who==3 || who==4) {
	$('three').style.backgroundPosition = "0px -222px";
	$('buttonthree').style.color = "#ffffff";
  }
}
function leave(who) {
  if ((who==1 || who==4) && chosen!=1) {
	$('one').style.backgroundPosition = "0px 0px";
	$('buttonone').style.color = "#4C4C4C";
	$('buttonone').innerHTML = "BMW Serie 1";
	$('titleone').style.color = "#4C4C4C";
  }
  if ((who==2 || who==4) && chosen!=2) {
	$('two').style.backgroundPosition = "0px 0px";
	$('buttontwo').style.color = "#4C4C4C";
	$('buttontwo').innerHTML = "20.000 &euro;";
	$('titletwo').style.color = "#4C4C4C";
  }
  if ((who==3 || who==4) && chosen!=3) {
	$('three').style.backgroundPosition = "0px 0px";
	$('buttonthree').style.color = "#4C4C4C";
	$('buttonthree').innerHTML = "Equipo Multimedia";
	$('titlethree').style.color = "#4C4C4C";
  }
}
function choose(who) {
  if (who==1) {
	$('one').style.backgroundPosition = "0px -444px";
	$('buttonone').style.color = "#ffffff";
	$('buttonone').innerHTML = "Tu elecci&oacute;n: BMW Serie 1";
	$('titleone').style.color = "#ffffff";
	leave(2);
	leave(3);
  }
  if (who==2) {
	$('two').style.backgroundPosition = "0px -444px";
	$('buttontwo').style.color = "#ffffff";
	$('buttontwo').innerHTML = "Tu elecci&oacute;n: 20.000 &euro;";
	$('titletwo').style.color = "#ffffff";
	leave(1);
	leave(3);
  }
  if (who==3) {
	$('three').style.backgroundPosition = "0px -444px";
	$('buttonthree').style.color = "#ffffff";
	$('buttonthree').innerHTML = "Tu elecci&oacute;n: Equipo Multimedia";
	$('titlethree').style.color = "#ffffff";
	leave(1);
	leave(2);
  }
}

blinkerStatus = false;
function init_blinker() {
  Blinkers = $$('.blinker');
  if (Blinkers.length > 0) {
	for (i=0; i < Blinkers.length; i++) {
	  if (blinkerStatus) {
		Blinkers[i].style.visibility = 'visible';
	  } else {
		Blinkers[i].style.visibility = 'hidden';
	  }
	}
  }
  blinkerStatus = !blinkerStatus;
  setTimeout('init_blinker()',700);
}


var nolink = false;
var noexitpop = false;

function uncommercialpage1(num) {
	if(nolink) {
		//if(!noexitpop) window.open("http://ilead.itrack.it/clients/ext.aspx?openpopup=0&targetpage=popup&cid=9172&sid=49874&wid=1043&swid=exit", "gewinnriese", "width=350,height=572,scrollbars=no");	
		//if(!noexitpop) window.open("http://ad.netdialogs.de/index.php?action=loadCampaignAd&campaignID=5&campaignAdID=48&websiteID=4&externalID=exitpop&openPopup=0", "tcom", "width=832,height=662,scrollbars=yes");	
		//if(!noexitpop) window.open("http://www.planet49.com/cgi-bin/wingame.pl?partner_pk=1&wingame_pk=34&sub_id=exitpop", "immo", "width=660,height=710,scrollbars=yes");	
		ajaxstats(num);
	} 
}

function uncommercial(num,url) {
	if(nolink) {
		//if(!noexitpop) window.open("http://ilead.itrack.it/clients/ext.aspx?openpopup=0&targetpage=popup&cid=9172&sid=49874&wid=1043&swid=exit", "gewinnriese", "width=350,height=572,scrollbars=no");	
		//if(!noexitpop) window.open("http://ad.netdialogs.de/index.php?action=loadCampaignAd&campaignID=5&campaignAdID=48&websiteID=4&externalID=exitpop&openPopup=0", "tcom", "width=832,height=662,scrollbars=yes");	
		//if(!noexitpop) window.open("http://www.planet49.com/cgi-bin/wingame.pl?partner_pk=1&wingame_pk=34&sub_id=exitpop", "immo", "width=660,height=710,scrollbars=yes");	
		ajaxstats(num);
	} 
}

function uncommercialp4(num,url) {
	if(nolink) {
		if(!noexitpop && url) window.open(url, "vista", "width=660,height=710,scrollbars=yes");	
		ajaxstats(num);
	} 
}

function ajaxstats(page) {

	if(window.XMLHttpRequest)
	{
    	try 
		{
			req = new XMLHttpRequest();
        } 
		catch(e) 
		{
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } 
	else if(window.ActiveXObject) 
	{ 
       	try 
		{
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} 
		catch(e) 
		{
        	try 
			{
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} 
			catch(e) 
			{
          		req = false;
        	}
		}
    }
	if(req && page != 0) 
	{
		urlx = "/cgi-bin/49lp.pl?file=images/pixel.gif&partner_pk="+page+"&ident=close&wingame_pk=32";
		randurl = urlx + "&" + Math.random();
		req.open("GET", randurl, true);
		req.send("");	
	}
}

	
var wieoft = 0;

function checkform() {	
	
	if (!document.register.agb.checked) { 
		wieoft++; 
		if(wieoft <= 2) { 
			//printSound();
			alert('Haben Sie alle Felder\nvollständig und richtig\nausgefüllt und angekreuzt?'); 
			return false;
		}		
	}
	return true;
		
}

// Selectboxen aus- und wieder einblenden f&uuml;r ie6. Einblendung muss im Schliessen-Link des hinteren GWS-Layers eingebaut sein 

function istvorhanden(id) {
    if (document.getElementById(id) && document.getElementById(id).style.display == "block"){
      return true;
    }else{
      return false;
    }
  
}
	
var errortext = true;
		

function fillcheck()
{
	ausgabe = true;
	for(i=0;i<(document.inter.length);i++)
	{
		//alert("name:"+document.inter.elements[i].name + ", ind:" + document.inter.elements[i].name.indexOf("question::"));
		if ((document.inter.elements[i].name.indexOf("coreg_pk_") > -1) && document.inter.elements[i].checked == true) {
			errortext = false;
			if(document.inter.elements[i+1].name.indexOf("confirmbox::") > -1 && document.inter.elements[i+1].checked == false) { 
				errorcbtext = document.inter.elements[i+1].name.split("::");				
					alert("Sie muessen noch die Checkbox des gewaehlten Angebots bestaetigen!");
					ausgabe = false;					
			}
		}
	}


	if (errortext == true) {
		hidetagsIE('select');
		document.getElementById('werbeflaeche_coreg').style.display = 'block';
		//alert("Bitte w&auml;hlen Sie mindestens ein Gratis Angebot aus,\nindem Sie die Checkbox anklicken.");
		ausgabe = false;
	} 

	return ausgabe;	

}


function inter_check_all() {
	return;
	for(i=0;i<(document.inter.length);i++) {
		if ((document.inter.elements[i].name.indexOf("question::") > -1)) document.inter.elements[i].checked = true;
	}
}


function openit(url,name, w, h) {
			if(!w)w=400;
			if(!h)h=500;
			var size = "scrollbars=yes,width=" + w + ",height=" + h + "";
			//alert(size);
	     	window.open(url,name,size);
	   	}
		
function checkthebox(el) {
	document.getElementsByName(el)[0].checked = !document.getElementsByName(el)[0].checked;
}	
	


function coreg_check()
{
	ausgabe = false;
	errortext = false;
	for(i=0;i<(document.inter.length);i++)
	{
		//alert("name:"+document.inter.elements[i].name + ", ind:" + document.inter.elements[i].name.indexOf("question::"));
		if ((document.inter.elements[i].name.indexOf("coreg_pk_") > -1) && document.inter.elements[i].checked == true) {
			errortext = false;
		}
	}

	if (errortext == true) {
		hidetagsIE('select');
		ausgabe = false;
		//vorher Abfrage einblenden
		showlayer('werbeflaeche');
	} 
	else
	{
		ausgabe = true;
	}
	return ausgabe;	
}

// Text aus Input in ID uebertragen:
fillIn = function(textSource,ID) {
  var el = $(ID);
  if (el) {
	el.set('html',textSource.value);
  }
}
// Fills the vcard values on startup
function checkVpPrefill() {
    if ($('street_type').value != '') { fillIn($('street_type'),'vp_street_type');}
    if ($('street').value != '') { fillIn($('street'),'vp_street'); } 
    if ($('streetnr').value != '') { fillIn($('streetnr'),'vp_streetnr'); } 
    if ($('apartment').value != '') { fillIn($('apartment'),'vp_apartment'); } 
    if ($('door').value != '') { fillIn($('door'),'vp_door'); }
	if ($('city').value != '') { fillIn($('city'),'vp_city'); }
	if ($('zipcode').value != '') { fillIn($('zipcode'),'vp_zipcode'); }
	if ($('tel_number').value != '') { fillIn($('tel_number'),'vp_tel_number'); } 
}

