
var jest_flash = 0;
var jest_flash_6 = false;
var jest_flash_7 = false;
var jest_flash_8 = false;

if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
    if (navigator.plugins && navigator.plugins["Shockwave Flash"]) {
    	if(navigator.plugins["Shockwave Flash"].description.charAt(navigator.plugins["Shockwave Flash"].description.indexOf('.')-1) >= 6) {
    		jest_flash_6 = true;
    	}
    	if(navigator.plugins["Shockwave Flash"].description.charAt(navigator.plugins["Shockwave Flash"].description.indexOf('.')-1) >= 7) {
    		jest_flash_7 = true;
    	}
    	if(navigator.plugins["Shockwave Flash"].description.charAt(navigator.plugins["Shockwave Flash"].description.indexOf('.')-1) >= 8) {
    		jest_flash_8 = true;
    	}
	if(navigator.plugins["Shockwave Flash"].description.charAt(navigator.plugins["Shockwave Flash"].description.indexOf('.')-2) == 1 &&
	   navigator.plugins["Shockwave Flash"].description.charAt(navigator.plugins["Shockwave Flash"].description.indexOf('.')-1) == 0) {
		jest_flash_6 = true;
		jest_flash_7 = true;
    		jest_flash_8 = true;
    	}
        jest_flash = true;
    }
}

else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
    document.write('<SCRIPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');

    document.write('jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
    document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
    document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
    document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
    document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))\n');
    document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n');
	document.write('if ( jest_flash <= 0 ) then jest_flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))\n');
    
    document.write('jest_flash_6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
    document.write('if ( jest_flash_6 <= 0 ) then jest_flash_6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))\n');
    document.write('if ( jest_flash_6 <= 0 ) then jest_flash_6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n');
    document.write('if ( jest_flash_6 <= 0 ) then jest_flash_6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))\n');

    document.write('jest_flash_7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")))\n');
    document.write('if ( jest_flash_7 <= 0 ) then jest_flash_7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n');
    document.write('if ( jest_flash_7 <= 0 ) then jest_flash_7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))\n');
    
    document.write('jest_flash_8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n');
    document.write('if ( jest_flash_8 <= 0 ) then jest_flash_8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))\n');
    
    document.write('</SCRIPT\> \n');
}


function hideTopLayer() {
	if(document.getElementById) // gecko(NN6) + IE5+ 
	{ 
		document.getElementById("topLayerSlot").style.display = 'none';
	}
	else if(document.all) //IE 4 
	{ 
		document.all["topLayerSlot"].style.display = 'none'; 
	} 
	else if(document.layers)  // NN4 
	{ 
		document.layers["topLayerSlot"].display = 'none';
	}
}

function hidePlayerLayer() {

	if(document.getElementById) // gecko(NN6) + IE5+ 
	{ 
		document.getElementById("playerLayer").style.marginTop = '-2000px';
	}
	else if(document.all) //IE 4 
	{ 
		document.all["playerLayer"].style.marginTop = '-2000px';
	} 
	else if(document.layers)  // NN4 
	{ 
		document.layers["playerLayer"].marginTop = '-2000px';
	}
}


function showPlayerLayer(binaryLink) {

	var sendText = binaryLink;

	if(document.getElementById) // gecko(NN6) + IE5+ 
	{ 
		document.getElementById("playerLayer").style.marginTop = '0px';
	}
	else if(document.all) //IE 4 
	{ 
		document.all["playerLayer"].style.marginTop = '0px';
	} 
	else if(document.layers)  // NN4 
	{ 
		document.layers["playerLayer"].marginTop = '0px';
	}
	
	window.document.myFlashPlayer.SetVariable("myVar", sendText);
	window.document.myFlashPlayer.Play();	
}

function getBrowserWindowSize() {
	myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}



var disclimerId = '';
 
	


function showDisclaimerLayer(binaryLink, sourceContentDivId, showDisclimerForm) {
	//console.log(sourceContentDivId);
	
	if(showDisclimerForm === true){
		
		document.getElementById('country_selection').style.display = 'none';
		document.getElementById('disclimer-wrong').style.display = 'none';
		changeDivContent( sourceContentDivId, 'disclimer-good' );
		document.getElementById('disclimer-good').style.display='block';
		
	}else{
		if(getCookie(sourceContentDivId) == 'false' || getCookie(sourceContentDivId) == 'true'){
		
			// dostęp już wcześniej zabroniony
			if (getCookie(sourceContentDivId) == 'false') {
				
				document.getElementById('country_selection').style.display = 'none';
				document.getElementById('disclimer-good').style.display='none';
				document.getElementById('disclimer-wrong').style.display = 'block';
				//disclimerStatusInfo = 'off';
			}
			// dostęp już wcześniej zezwolony
			if (getCookie(sourceContentDivId) == 'true') {
				
				document.getElementById('country_selection').style.display = 'none';
				document.getElementById('disclimer-wrong').style.display = 'none';
				changeDivContent( sourceContentDivId, 'disclimer-good' );
				document.getElementById('disclimer-good').style.display='block';
				//disclimerStatusInfo = 'on';
			}
		
		}else{
			document.getElementById('disclimer-wrong').style.display = 'none';
			document.getElementById('disclimer-good').style.display='none';
			document.getElementById('country_selection').style.display = 'block';
		}
	
		disclimerId = sourceContentDivId;
		
	}
	
	var layerHeight = (document.getElementById('table_main').offsetHeight+44) + 'px';
	
	document.getElementById('shadowLayer').style.height=layerHeight;
	document.getElementById('shadowLayer').style.visibility='visible';
	document.getElementById('disclaimerLayer').style.visibility='visible';
	document.getElementById('disclaimerLayer').style.visibility='visible';
	
}
	
	
	

function hideDisclaimerLayer(){
    document.getElementById('disclaimerLayer').style.visibility="hidden";
    document.getElementById('shadowLayer').style.visibility="hidden";
}

function changeDivContent( sourceId, targetId )
{
    var divTarget = document.getElementById( targetId );
    var divSource = document.getElementById( sourceId );
    if( divTarget && divSource )    {   
        divTarget.innerHTML = divSource.innerHTML;
    }
}



//console.log('disclimerStatusInfo: '+disclimerStatusInfo);

function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
	return true;
}



function validate() {
	var country_code = document.getElementById('country_code').value;
	var corrected_country_code = '';

	var l = country_code.length;
	// usunięcie niedozwolonych znaków
	for (x = 0; x <= l; x++) {
		var _char = country_code.substr(x, 1);
		if (isNaN(_char) == false) {
			corrected_country_code += _char;
		}
	}
	
	// usunięcie wiodących zer
	if (corrected_country_code.substr(0, 1) == '0') corrected_country_code = corrected_country_code.substr(1);
	if (corrected_country_code.substr(0, 1) == '0') corrected_country_code = corrected_country_code.substr(1);
	if (corrected_country_code.substr(0, 1) == '0') corrected_country_code = corrected_country_code.substr(1);

	if (corrected_country_code == '' || corrected_country_code == '0') {
		alert(emptyCode);
		return false;
	}


	
	if (corrected_country_code != document.getElementById('selected_country').value) {
		// kody niezgodne = odmowa dostępu
		alert(wrongCode);
		return false;
	} else {
		// kody zgodne
		
		// jeżeli kraj na liście zabronionych
		if (   corrected_country_code == 1
			|| corrected_country_code == 61
			|| corrected_country_code == 27
			|| corrected_country_code == 81
		   ){
				
				document.getElementById('country_selection').style.display = 'none';
				document.getElementById('disclimer-good').style.display='none';
				document.getElementById('disclimer-wrong').style.display = 'block';
				setCookie(disclimerId, false, 720);
						
		} else {
			// dostęp zezwolony
			document.getElementById('country_selection').style.display = 'none';
			document.getElementById('disclimer-good').style.display='none';
			changeDivContent( disclimerId, 'disclimer-good');
			document.getElementById('disclimer-good').style.display='block';
			setCookie(disclimerId, true, 720);
			return true;			
		}
	}
}



function setCookie(c_name,value,expirehours) {
	try {
		console.log("setCookie expirehours: " + expirehours);
	} catch (e) {}

	if (expirehours>0) {
		var today = new Date();
		today.setTime(today.getTime());
		expireseconds = expirehours * 60 * 60 * 1000; // 1000 bo milisekundy a nie sekundy
		var expires_date = new Date( today.getTime() + (expireseconds) );
		document.cookie = c_name + "=" + escape(value) + ((expireseconds==null) ? "" : ";expires="+expires_date.toGMTString());
	} else {
		document.cookie = c_name + "=" + escape(value) + '; path=/';
	}
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function getUrlParam(name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

function movePlayerLayer(id, bannerHeight)
{
	var initialYPos = -bannerHeight;
	var stopYPos = 0;

	var el=doc.getElementById?doc.getElementById(id):doc.all?doc.all[id]:doc.layers[id];
	window[id + "_object"] = el;
	if(doc.layers) el.style=el;
	el.currentYPos = el.stopYPos = initialYPos;
	el.stylePosPx=function(y){this.style.top=y+px;};
	el.move=function()
	{
	
		var posY;

		posY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;

		posY += stopYPos-initialYPos;
		
		this.currentYPos += (posY + this.stopYPos - this.currentYPos)/1;
		this.stylePosPx(this.currentYPos);
		setTimeout(this.id + "_object.move()", 1);
	}
	return el;
}


var ns = (navigator.appName.indexOf("Netscape") != -1);
var doc = document;
var px = document.layers ? "" : "px";
function moveTopLayer(id, bannerHeight)
{
	var initialYPos = -bannerHeight;
	var closeButtonHeight = 25;
	var stopYPos = getBrowserWindowSize()/2 - bannerHeight/2 - closeButtonHeight;

	var el=doc.getElementById?doc.getElementById(id):doc.all?doc.all[id]:doc.layers[id];
	window[id + "_object"] = el;
	if(doc.layers) el.style=el;
	el.currentYPos = el.stopYPos = initialYPos;
	el.stylePosPx=function(y){this.style.top=y+px;};
	el.move=function()
	{
	
		var posY;

		posY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;

		posY += stopYPos-initialYPos;
		
		this.currentYPos += (posY + this.stopYPos - this.currentYPos)/8;
		this.stylePosPx(this.currentYPos);
		setTimeout(this.id + "_object.move()", 30);
	}
	return el;
}
//funkcje do obejscia obramowania dla activ contentu w IE
function objectStartLine() {
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
}
function objectEndLine() {
	document.writeln('>');
}
function embedEndLine() {
	document.writeln(' allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}
function embedPlayer() {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width=100% height=100% id="myFlashPlayer"> <param name="wmode" value="transparent" /> <param name="allowScriptAccess" value="sameDomain" /> <param name=movie value="/images/flash/root_player.swf"> <param name=quality value=high> <param name="FlashVars" value="xmlUrl=/player.xml" /> <embed src="/images/flash/root_player.swf" quality=high width=100% height=100% type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="myFlashPlayer" allowScriptAccess="sameDomain" swLiveConnect="true" FlashVars="xmlUrl=/player.xml" wmode="transparent"> </embed> </object>');
}
