var ie=(document.all)?true:false;
var ns=(document.layers)?true:false;
var oNewWindow;
//------------------------------------------------------------------
function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{ 
		newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}
//------------------------------------------------------------------
function fixColumns()
{
        if (document.getElementById("subContent")!=null && document.getElementById("sideBar")!=null) 
        { 
	        var h1 = document.getElementById("subContent").offsetHeight;
	        var h2 = document.getElementById("sideBar").offsetHeight;
	        var max = h1;
	        if(h2 > h1)
			{
	        	document.getElementById("subContent").style.height = h2 + "px";
			}
		}
}
//------------------------------------------------------------------
function toggleVisibility(me)
{
			if (me.style.display=="block")
			{
				me.style.display="none";
			}else {
				me.style.display="block";
			}
}
//------------------------------------------------------------------
function pozostaloZnakow(e)
{
	strLen=document.frm_platnosc.prezent_tresc.value.length;
	pozostalo=512-strLen;
	if (pozostalo<0) 
	{
		document.frm_platnosc.prezent_tresc.value=document.frm_platnosc.prezent_tresc.value.substr(0,512);		
	}
	document.frm_platnosc.liczba_znakow.value=pozostalo;
}
//------------------------------------------------------------------
function hide_layer(d) 
{
    if(d.length < 1)
    {
	return;
    }

    document.getElementById(d).style.display = "none";
}
//------------------------------------------------------------------
function show_layer(d)
{
    if(d.length < 1)
    {
	return; 
    }


    if(ie)
    {
	x = (document.body.scrollWidth/2)-225;
	y = document.body.scrollHeight - 400;
    }
    else
    {
	x = (document.width/2)-225;
	y = document.height - 400; 	
    }
    obj = document.getElementById(d);
    obj.style.left = x + 'px';
    obj.style.top = y + 'px';
    obj.style.display = 'block';
}
//------------------------------------------------------------------
function check_banner(flash_div,flash_data,flash_w,flash_h)
{
	 //jezeli cos sie dzieje z adserwerem i nie ma wcale kodu flasha
	 if (document.getElementById(flash_div).offsetHeight<flash_h)
	 {
	 	flash="<object type='application/x-shockwave-flash' data='"+flash_data+"' width='"+flash_w+"' height='"+flash_h+"'>";		
	 	flash=flash+"<param name='movie' value='"+flash_data+"' />";
	 	flash=flash+"<param name='wmode' value='transparent'/>";			
	 	flash=flash+"Nie masz zainstalowanego odtwarzacza Flash.";		
		flash=flash+"</object>";
	 	document.getElementById(flash_div).innerHTML=flash;
	 } 
	 
	 
	 //flash sie pojawia ale movienotloaded
	 
	 //alert(document.getElementById('mymovie').tagName);
	 var sfEls = document.getElementById(flash_div).getElementsByTagName("EMBED");
	 if (sfEls.length==0) 
	 {
	 	var sfEls = document.getElementById(flash_div).getElementsByTagName("OBJECT");
	 }

	 for (var i=0; i<sfEls.length; i++) 
	 { 
		 //alert(sfEls[i].PercentLoaded());
		 if (sfEls[i].PercentLoaded()==0)
		 {
	 		flash="<object type='application/x-shockwave-flash' data='"+flash_data+"' width='"+flash_w+"' height='"+flash_h+"'>";		
	 		flash=flash+"<param name='movie' value='"+flash_data+"' />";
	 		flash=flash+"<param name='wmode' value='transparent'/>";			
	 		flash=flash+"Nie masz zainstalowanego odtwarzacza Flash.";		
			flash=flash+"</object>";
	 		document.getElementById(flash_div).innerHTML=flash; 
		 }
	 }

}
//------------------------------------------------------------------
function pokaz_kartki(id_okazji,id_kartka)
{
	
	html_kartka="<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
	
	if (id_okazji=='')
	{
	
		html_kartka="<tr><td></td></tr>";
		
	} else {

		html_kartka='<strong>Wybierz pocztówkę: </strong>'+html_kartka;
		rzad=0;
		pierwszy=-1;
		for (i=0; i < kartki.length; i++) 
		{ 
			selected="";
			class1="kartka_box";

			if (kartki[i][0]==id_okazji)
			{
			  
				if (id_kartka==0)
				{	
				
					if (pierwszy==-1) 
					{
						selected=" checked='checked'"
						class1="kartka_box_selected";
						pierwszy=i;
					}
					 
				} else {
				
					if (id_kartka==kartki[i][1])
					{
						selected=" checked='checked'"
						class1="kartka_box_selected";
					}
										
				}
				
			  			
				rzad++;
				if (rzad==1) 
				{
					html_kartka=html_kartka+'<tr>';
				}
				
				html_kartka=html_kartka+"<td align='center'>";
				//html_kartka=html_kartka+"<input name='prezent_kartka' type='radio' value='"+kartki[i][1]+"' class='kartka_radio'"+selected+" onclick=\"document.getElementById('okazja_kartka_"+i+"').className='kartka_box_selected'\"/>";
				html_kartka=html_kartka+"<input name='prezent_kartka' type='radio' value='"+kartki[i][1]+"' class='kartka_radio'"+selected+"/>";
				html_kartka=html_kartka+"<div id='okazja_kartka_"+i+"' class='"+class1+"'>";
				html_kartka=html_kartka+"<table border='0' cellspacing='0' cellpadding='0' style='width:180px; height:180px;'>";
				html_kartka=html_kartka+"<tr>";
				html_kartka=html_kartka+"<td align='center'>";
				html_kartka=html_kartka+"<table border='0' cellspacing='0' cellpadding='0'>";
				html_kartka=html_kartka+"<tr>";
				html_kartka=html_kartka+"<td><a href=\"javascript:void(image_popup('img.php?zasob=kartka&amp;plik="+kartki[i][3]+"'));\"><img src='img.php?zasob=kartka&amp;plik="+kartki[i][2]+"' alt='' border='0'/></a></td>";
				html_kartka=html_kartka+"</tr>";
				html_kartka=html_kartka+"</table>";
				html_kartka=html_kartka+"</td>";
				html_kartka=html_kartka+"</tr>";
				html_kartka=html_kartka+"</table>";
				html_kartka=html_kartka+"</div>";
				html_kartka=html_kartka+"</td>";

				if (rzad==3) 
				{
					html_kartka=html_kartka+'</tr>';
					rzad=0;
				}
				
				
			}
			
			if (i==kartki.length-1)
			{
				if (rzad==1) html_kartka=html_kartka+'<td>&nbsp;</td><td>&nbsp;</td></tr>';
				if (rzad==2) html_kartka=html_kartka+'<td>&nbsp;</td></tr>';
			}		

		}

	}

   	html_kartka=html_kartka+"</table>";
	document.getElementById('okazja_kartki').innerHTML=html_kartka;

}
//------------------------------------------------------------------
function image_popup(img)
{

    var myWidth = 0, myHeight = 0;
      
	if( typeof( window.innerWidth ) == 'number' ) 
	{
	    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;
	}

	x=(myWidth/2)-(400);	
	y=(myHeight/2)-(300);	
	
	if (navigator.appName=='Opera')
	{
		
		oNewWindow=window.open('','_blank','width=250,height=250,top='+y+',left='+x);
			
	} else {
	
		if (oNewWindow==undefined)
		{
			oNewWindow=window.open('','ImagePopup','width=250,height=250,top='+y+',left='+x);
		} else {
			oNewWindow.close();
			oNewWindow=window.open('','ImagePopup','width=250,height=250,top='+y+',left='+x);
		}
		
	}

	var html = oNewWindow.document;
	html.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	html.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">');
	html.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
	html.write('<title>Podgląd</title>');
	html.write('<style type="text/css">');
	html.write('#img {display: none;}');
	html.write('#preloader {border: 0px solid red;width:32px;height:32px;background:url(loader2.gif) no-repeat;margin-top:125px;margin-left:125px;}');
	html.write('</style>');
	html.write('</head><body style="margin:0px">');
	html.write('<div id="preloader"></div>');
	html.write('<a href="javascript:self.close()"><img id="img" border="0" src="'+img+'" onload="this.style.display=\'block\';document.getElementById(\'preloader\').style.display=\'none\';window.resizeBy(document.images[0].width-250,document.images[0].height-250);self.focus();"/></a>');
	html.write('</body></html>');
	html.close();
	return false;
}
//------------------------------------------------------------------
function popup(URLtoOpen,Width,Height) 
{ 
		
    var myWidth = 0, 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;
	}
		
	x=(myWidth/2)-(Width/2);	
	y=(myHeight/2)-(Height/2);	
	
	newWindow=window.open(URLtoOpen,'Popup','width='+Width+',height='+Height+',top='+y+',left='+x);
	
}
//------------------------------------------------------------------

