// new window opener for print
function print_open_ctx (ctx) {
  wn=window.open ("",'orange_print',"width="+610+",height="+460+",top="+20+",left="+20+",scrollbars=1,resizable=1","dependend=yes");
  s='/kontoorange/print/'+ctx;
  wn.location.replace (s);
  wn.focus ();
  return false;
}


// flash checker
var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i];
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}


function Form_OnSubmit() {
        	frmEnquiry = document.forms["enquiry"];
        	if (frmEnquiry.elements["Request"].value == 0) {
        		window.alert("\"Požiadavka\" musí byt vyplnená");
        		return false;
        	};
        	if (frmEnquiry.elements["Kind"].value == 0) {
				window.alert("\"Druh nehnutelnosti\" musí byt vyplnený");
				return false;
			};
			if (frmEnquiry.elements["Email"].value == "" && frmEnquiry.elements["Phone"].value == "") {
				window.alert("\"Email\" alebo \"Telefón\" musí byt vyplnený");
				return false;
			};
			return true;
 }



var ival, imgname, total, steps, maxx, maxy, currentx, currenty, dx, dy;

function zoomImg(imgname, total, steps, maxx, maxy)	{
	//clearInterval(startT);
	// convert the total from seconds to miliseconds
	total = total * 10000;
	objref = eval("document.getElementById('"+imgname+"')");
	currentx = objref.width;
	currenty = objref.height;
	// work out how much we need to increase the image by each step
	// devide image sizes by number of steps to get the amount we need to change each step
	stepx = maxx / steps;
	stepy = maxy / steps;
	// devide the total time (in ms) by the number of steps to get the interval time
	inttime = total / steps;
	// set the interval to increase the size of the image by the required pixels
	functionRef = "resizeImg('"+imgname+"', "+stepx+", "+stepy+", "+maxx+", "+maxy+")";
	clearInterval(startT);
	ival = setInterval(functionRef, inttime);
	//alert ('yess');

}


function resizeImg(imgname, dx, dy, maxx, maxy) {
	objref = eval("document.getElementById('"+imgname+"')");
	currentx = objref.width;
	currenty = objref.height;
	if ((currentx>maxx-dx) && (currenty>maxy-dy)) {
		objref.height = currenty - dy;
		//objref.width = currentx - dx;
	}
	else {
		clearInterval(ival);
		document.getElementById(imgname).style.visibility = 'hidden';
		objref.height = maxy;
		objref.width = maxx;
		//restartBanner();
		//return (false);
		clearInterval(startT);
		restartBanner();
	 }

	/* if (document.getElementById(imgname).style.display == 'hidden') {
	 	alert ('yess');
	 	clearInterval(ival);
	 	clearInterval(startT);
	 	document.getElementById(imgname).style.display = 'block';
	 }*/

}


function startBannerTime() {
	functionRefs = "zoomImg('bannerIvanskaImg', 0.5, 300, 208, 3)";
	ainttime = 5000;
	path = window.location;
	if ((window.location == "http://www.tatrareal.sk") || (window.location == "http://www.tatrareal.sk/index.shtml") || (window.location == "http://tatrareal/")) {
		startT = setInterval(functionRefs, ainttime);
	}
}

function restartBanner() {
	functionRefs = "zoomImg2('bannerIvanskaImg', 0.5, 300, 208, 370)";
	ainttime = 5000;
	path = window.location;
	if ((window.location == "http://www.tatrareal.sk") || (window.location == "http://www.tatrareal.sk/index.shtml") || (window.location == "http://tatrareal/")) {
		startTs = setInterval(functionRefs, ainttime);
		//alert ('heelo');
	}

}

function resizeImg2(imgname, dx, dy, maxx, maxy) {
	objref = eval("document.getElementById('"+imgname+"')");
	currentx = objref.width;
	currenty = objref.height;
	if ((currentx<maxx+dx) && (currenty<maxy+dy)) {
		objref.height = currenty + dy;
		//objref.width = currentx + dx;
	}
	else {
		clearInterval(ivals);
		//document.getElementById(imgname).style.visibility = 'hidden';
		objref.height = maxy;
		objref.width = maxx;
		clearInterval(startTs);
		startBannerTime();
	   }
}


function zoomImg2(imgname, total, steps, maxx, maxy)	{
	document.getElementById(imgname).style.visibility = 'visible';
	//clearInterval(startT);
	// convert the total from seconds to miliseconds
	total = total * 10000;
	objref = eval("document.getElementById('"+imgname+"')");
	currentx = objref.width;
	currenty = objref.height;
	// work out how much we need to increase the image by each step
	// devide image sizes by number of steps to get the amount we need to change each step
	stepx = maxx / steps;
	stepy = maxy / steps;
	// devide the total time (in ms) by the number of steps to get the interval time
	inttime = total / steps;
	// set the interval to increase the size of the image by the required pixels
	functionRef = "resizeImg2('"+imgname+"', "+stepx+", "+stepy+", "+maxx+", "+maxy+")";
	clearInterval(startTs);
	ivals = setInterval(functionRef, inttime);
}

function closeBanner(bann) {
	document.getElementById(bann).style.display = 'none';
}

function checkForm() {
	if (document.getElementById('email').value == "") {
		alert ("Musíte zadať svoj Email");
		return (false);
	}

	else return (true);
}