//make it popup! simply add the class 'poplink' to every link!
window.addEvent('domready', function() {
	var popLinks = $$('a.poplink');
	popLinks.each(function(el){
		el.set({
			'events': {
				'click': function() {
					window.open(this.href,'','scrollbars=yes,width=400,height=450,resizable=yes');
					return false;
				}
			}
		})
	});
	//do not call popunder on elements with class 'preventPop':
	$$('.preventPop').each(function(el){
		el.addEvents({
			'mouseenter': function(){
				preventPop = true;
			},
			'mouseleave': function(){
				preventPop = false;
			}
		});
	});
	
	if ($('coreg') && $('submit_inter')) {
		$('submit_inter').addEvent('click', function() {
			if (fillcheck()) {
				popunder(urlForCoregPopunder,'specialoffer','scrollbars=yes,width=970,height=720');
				//alert('blub');
				document.form_coreg.submit();
			}
		});
	}
	
	//setting maxlength for tel_number (task 44824)
	var test_page = document.body;
	if (test_page.id == 'reg_full') {
	  var country_select = $('landselect');
	  var tel_input = $('tel_number');
	  if (country_select && tel_input) {
		  country_select.addEvent('change',function(el){
			  if (this.value == '1') {
				  tel_input.value = '';
				  tel_input.setAttribute('maxLength','8');
			  } else if (this.value == '2') {
				  tel_input.setAttribute('maxLength','11');
			  } else {
				  tel_input.removeAttribute('maxLength');
			  }
		  });
	  }
	}
});
	
function openWindow(url,width,height) {
	window.open(url,'','scrollbars=yes,width='+width+',height='+height+',resizable=yes');
} 

function MM_openBrWindow(theURL,winName,features) { 
	window.open(theURL,winName,features);
}


/* Globales Script das Selectboxen sichtbar und unsichtbar macht ************************************************************************************************* */

function hidetagsIE(TagNamen){
	if ( navigator.userAgent.indexOf("MSIE 6") != -1 ){
		var no = 0;
		while (document.getElementsByTagName(TagNamen)[no]){
			document.getElementsByTagName(TagNamen)[no].style.visibility = "hidden"; 
			no++;
		}
	}
}

function showtagsIE(TagNamen){
	if ( navigator.userAgent.indexOf("MSIE 6") != -1 ){
		var no = 0;
		while (document.getElementsByTagName(TagNamen)[no]){
			document.getElementsByTagName(TagNamen)[no].style.visibility = "visible"; 
			no++;
		}
	}
}

/* Deutsche URL - vermutlich überflüssig
function popUnderP1() {
	var notshown = new Array(1088,0,831,1092,941,1042,155,1027,876,1080,983,813,1107,1038)
	
	if (document.getElementById("register")) {
		var ppk = document.getElementById("register").partner_pk.value;
	} else {
		var ppk = document.forms[0].partner_pk.value;
	}
	var nopop = false;
	for (i=0;i<notshown.length;i++) {
		if(ppk == notshown[i] || ppk == '') { 
			nopop = true;
			break;
		}
	}
	//alert('PPK ist '+ppk+' | '+notshown.length+":"+nopop)
	if(!nopop) {
		var pu = window.open("http://www.winmycar.de/perl/lp.pl?file=index1.html&partner_pk=1014&sub_id=GWS-PopUnder","","width=940,height=790,scrollbars=1,resizable=1");
		pu.blur();
	}
}*/

/* Globales Script das DIVs sichtbar und unsichtbar macht ************************************************************************************************* */

function hidelayer(divs) {
	document.getElementById(divs).style.display = "none";
	if(divs == "popinfo") document.getElementById("landselect").style.display = "block";
}
	
function showlayer(divs) {
	document.getElementById(divs).style.display = "block";
	if(divs == "popinfo") document.getElementById("landselect").style.display = "none";
}
	
/* Coreg Checkbox anhaken beim Klick aufs Bild ************************************************************************************************* */

function checkthebox(el) {
	document.getElementsByName(el)[0].checked = !document.getElementsByName(el)[0].checked;
}

/* Funktion für die Erstellung der SkyScrapper der gewinner auf der 1. Seite  */
var winnerH1 = "Chosen winners of the last season!";
var winnerImages = '2,20,7,6,5';
function writeImages(h1, images) {
	var winnerlinks = images.split(",");
	for (i=0;i<winnerlinks.length;i++) {
		//document.write('<a href="javascript:MM_openBrWindow(\'/wingame/'+sponsor_switch_wingame+'/winner.htm\',\'\',\'scrollbars=yes,width=910,height=700\')"><img src="http://de.static.planet49.com/gewinner/winners/images/'+winnerlinks[i]+'.jpg" id="winner'+i+'" /><br\/></a>');
		document.write('<img src="http://de.static.planet49.com/gewinner/winners/images/'+winnerlinks[i]+'.jpg" id="winner'+i+'" /><br\/>');
	}
	document.getElementById("skyH1").innerHTML = h1;
}


/* Function for savin the click action on start layer
  0=close on X; 1=click in button; 2=click on background; 3=autoclose
*/
var lclick = function(ident) {
	var reqUrl = 'http://www.planet49.com.au/cgi-bin/global.pl?todo=log_misc&ident=layer_startpage_'+ident;
	var req = new Request({url: reqUrl, method: 'GET'});
	req.send();
	if($('register')) document.register.start_layer_action.value = 'layer_startpage_'+ident+'_fullreg';
	if($('freetest_form')) document.freetest_form.start_layer_action.value = 'layer_startpage_'+ident+'_fullreg';
}

