var calendar = null;
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}
function showCalendar(id) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
		calendar.parseDate(el.value); // set it to a new date
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

function changeColor(color){
    document.getElementById('main_img_lay').className='main_img_'+color;
    var colorCookImge='main_img_'+color;
    Set_Cookie('colorCookImg',colorCookImge,'1','/','polskiekrajobrazy.pl');
}

function getCookiee(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 Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}



var isNN,isIE,isOpera;
var imageTitle="Podgl±d";
var imgWin;
var adding;
function showFull()
{
		img_tiny=showFull.arguments[0];
		w=showFull.arguments[1];
		h=showFull.arguments[2];
		PositionX = 100;
		PositionY = 100;
		defaultWidth = w?w:520;
		defaultHeight = h?h:520;
		var AutoClose = true;
		
		if (parseInt(navigator.appVersion.charAt(0))>=4){
		isNN=(navigator.appName=="Netscape")?1:0;
		isOpera=(navigator.appName=="Opera")?1:0;
		isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		if (parseInt(navigator.appVersion.indexOf('MSIE 7.0'))!=-1){
			adding=140;
		}else{
			adding=0;
		}
		var optNN='statusbar=yes,scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
		var optIE='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
		
		if (isNN||isOpera){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}

		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('</head><body bgcolor=000000 scroll="no" >')
			writeln('<img name="George" id="George" src="'+img_tiny+'"  style="display:block"></body></html>');
			close();
			
	}
// 	window.setTimeout('onimageload()',1);

		
		
return false;
}


function onimageload(){
	if(imgWin.document.getElementById("George").complete){
			
			if (isOpera){
				width=imgWin.document.images[0].width+8;
				height=imgWin.document.images[0].height+40;
				imgWin.resizeTo(width,height);
			}
			if(isIE){
				imgWin.resizeTo(0,0);
				width=100-(imgWin.document.body.clientWidth-imgWin.document.images[0].width);
				height=100-(imgWin.document.body.clientHeight-imgWin.document.images[0].height);
				width+=adding;	
				imgWin.resizeTo(width,height);
			}
			if (isNN){
					width=imgWin.document.images[0].width+10;
					height=imgWin.document.images[0].height+59;
					imgWin.resizeTo(width,height);
			}
			
			if(imgWin.innerHeight&&!isOpera){
				imgWin.resizeTo(0,0);
				imgWin.innerHeight=imgWin.document.getElementById("George").height;
				imgWin.innerWidth=imgWin.document.getElementById("George").width;
				
			}
			imgWin.document.title=imageTitle;	
	}else{
		window.setTimeout('onimageload()',1);
	}
}

