// JavaScript Document
function doPageLink()
{
	var args = getArgs();
	if(args["Preview"] || args["preview"])
		document.write("<a href=\"javascript:window.close()\">Close window</a>");
	
	else
	{
		var str = "<a href='javascript:history.back()'>";
		str += "<img src='images/skin/buttons/back.gif' alt='Return to the previous page' style='border-width:0px'";
		str += " onmouseover='switchImg(this)' onmouseout='switchImg(this)'";
		str == " /></a>";		
		document.write(str);		
	}
}
function noSubmit()
{
	return !(window.event && window.event.keyCode == 13);
}
function roundPrice(p)
{
	var pound = String.fromCharCode(163);
	var price = pound + (new Number(p)).toFixed(2);
	return price;
}
String.prototype.endsWith = function(s)
{
	return s == this.substr(this.length - s.length);
}
function Cookie(document, name, hours, path, domain, secure)
{
	this.$document = document;
	this.$name = name;
	if(hours) this.$expiration = new Date((new Date()).getTime() + hours * 3600000);
	else this.$expiration = null;
	if(path) this.$path = path; else this.$path = null;
	if(domain) this.$domain = domain; else this.$domain = null;
	if(secure) this.$secure = true; else this.$secure = false;
}
Cookie.prototype.store = function()
{
	var cookieval = "";
	for(var prop in this){
		if(prop.charAt(0) == '$' || ((typeof this[prop]) == 'function'))
			continue;
		if(cookieval != "")
			cookieval += '&';
//		cookieval += prop + ':' + escape(this[prop]);
		cookieval += prop + ':' + encodeURI(this[prop]);
	}
	
	var cookie = this.$name + '=' + cookieval;

	if(this.$expiration) cookie += '; expires=' + this.$expiration.toGMTString();
	if(this.$path) cookie += '; path=' + this.$path;
	if(this.$domain) cookie += '; domain=' + this.$domain;
	if(this.$secure) cookie += '; secure';
	
	this.$document.cookie = cookie;
}
Cookie.prototype.load = function()
{
	var allcookies = this.$document.cookie;
	if(allcookies == "")
		return false;
	
	var start = allcookies.indexOf(this.$name + '=');
	if(start == -1)
		return false;

	start += this.$name.length + 1;
	
	var end = allcookies.indexOf(';', start);
	if(end == -1)
		end = allcookies.length;
		
	var cookieval = allcookies.substring(start,end);
	
	var a = cookieval.split('&');
	for(var i = 0; i < a.length; i++)
		a[i] = a[i].split(':');
		
	for(var i = 0; i < a.length; i++)
		this[a[i][0]] = decodeURI(a[i][1]);
//		this[a[i][0]] = unescape(a[i][1]);
		
	return true;
}
Cookie.prototype.remove = function()
{
	var cookie;
	cookie = this.$name + '=';
	
	if(this.$path)
		cookie += this.$path;
	if(this.$domain)
		cookie += '; domain=' + this.$domain;
	
	cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	
	this.$document.cookie = cookie;
}
function getArgs()
{
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for(var i = 0; i < pairs.length; i++){
		var nIndex = pairs[i].indexOf('=');
		if(nIndex == -1)
			continue;
		var name = pairs[i].substring(0,nIndex);
		var val = pairs[i].substring(nIndex + 1);
//		args[name] = unescape(val);
		args[name] = decodeURIComponent(val);
	}
	return args;
}
function findPosition( obj )
{
	if( obj.offsetParent ) {
		for( var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent ) 
		{
			posX += obj.offsetLeft;
			posY += obj.offsetTop;
		}
		return [ posX, posY ];
	} 
	else
	{
		return [ obj.x, obj.y ];
	}
}
function switchImg(img)
{		
	if(typeof(img) == "string")
		img = document.getElementById(img);
		
	if(img.src.indexOf("_f2") != -1)
		img.src = img.src.replace(/_f2/, "");
		
	else
	{
		img.src = img.src.replace(/\.gif/, "_f2\.gif");
		img.src = img.src.replace(/\.jpg/, "_f2\.jpg");
		img.src = img.src.replace(/\.png/, "_f2\.png");
	}
}
function preload()
{
	imgs = new Array(arguments.length);
	for(var i = 0; i < arguments.length; i++)
	{
		imgs[i] = new Image();
		imgs[i].src = arguments[i];
	}
}
function checkStatus()
{
	if(document.forms[0]["Status"] && document.forms[0]["Status"].value)
	{
		alert(document.forms[0]["Status"].value);		
		document.forms[0]["Status"].value = "";		
		return false;
	}
	return true;
}
var imgs = null;

function openWindow(url, winName, top, left, width, height, scrll)
{
	this.width = arguments.length > 4 ? width : 800;
	this.height = arguments.length > 5 ? height : 340;
	this.scrll = arguments.length > 6 ? scrll : "yes";
	
	return window.open(url,winName,"width="+this.width+",height="+this.height+",location=no,toolbar=no,menubar=no,titlebar=yes,scrollbars="+this.scrll+",resizable=no,top="+top+",left="+left);
}

function doLink2(url, w, h, bScroll)
{	
	var left = screen.availWidth > 800 ? 30 : 0;
	var top = screen.availHeight > 480 ? 30 : 0;
	
	var width = arguments.length > 1 ? w : 640;
	var height = arguments.length > 2 ? h : 480;
	
	var scrll = arguments.length > 3 ? "yes" : "no";

	if(childWin2 && !childWin2.closed)
	{
		childWin2.location = url;
		childWin2.focus();
		return;
	}				
	
	childWin2 = openWindow(url, "ChildWindow2", top, left, width, height, scrll);
}

function doLink(url, w, h, bScroll)
{	
	var left = screen.availWidth > 800 ? 60 : 0;
	var top = screen.availHeight > 600 ? 60 : 0;
	
	var width = arguments.length > 1 ? w : 640;
	var height = arguments.length > 2 ? h : 480;
	
	var scrll = arguments.length > 3 ? "yes" : "no";

	if(childWin && !childWin.closed)
	{
		childWin.location = url;
		childWin.focus();
		return;
	}				
	
	childWin = openWindow(url, "ChildWindow", top, left, width, height, scrll);
}

function killChild()
{
	try
	{
		if(childWin2 && !childWin2.closed)
			childWin2.close();
			
		if(childWin.childWin2 && !childWin.childWin2.closed)
			childWin.childWin2.close();
			
		if(childWin && !childWin.closed)
			childWin.close();
	}
	catch(ex)
	{
	//	Ignore permission denied errs
	}
}
function doPrint(url, w, h)
{
	if(arguments.length < 3)
		h = 500;
		
	if(arguments.length < 2)
		w = 700;
		
	doLink(url, w, h, false);
}
function doTrustHeaderScript()
{
	if(trustEnabled)
	{
		var str = "<script language='JavaScript' src='http://www.trustlogo.com/trustlogo/javascript/trustlogo.js' type='text/javascript'></script>";
		if(location.protocol == "https:")
			str = "<script language='JavaScript' src='https://secure.comodo.net/trustlogo/javascript/trustlogo.js' type='text/javascript'></script>";
		document.write(str);
	}
}
function insertTrustLogo()
{
	if(trustEnabled)
	{
		var str = "<div style='text-align:center; padding-bottom: 4px'>";
		str += "<script type='text/javascript'>TrustLogo('" + location.protocol + "//www.property.com.ua/assets/secure_site2.gif', 'SC', 'none');</script>"
		str += "</div>";
		document.write(str);
	}
}
function isPrinting()
{
	var p = getArgs()["Print"];
	if(p)
	{
		p = getArgs()["Preview"];
		return p && p == "1";
	}
	return false;
}
function onLoadEx()
{
	if(isPrinting())
	{
		document.body.style.padding = "50px";
		print();
	}
}

var childWin = null;
var childWin2 = null;
onfocus = killChild;
//doTrustHeaderScript();
function doTour2(size)
{
	var w = 180;
	var h = 120;
	if(size == 320)
	{
		w = 320;
		h = 240;
	}
	if (pluginlist.indexOf("RealPlayer") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/lviv2real.htm", w, h + 30);
		
	else if (pluginlist.indexOf("Flash") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/lviv2flash.htm", w, h);
		
	else
		doLink("http://www.property.com.ua/mmlink.htm", 320, 260);
}
function doTour(size)
{
	var w = 180;
	var h = 120;
	if(size == 320)
	{
		w = 320;
		h = 240;
	}
	if (pluginlist.indexOf("RealPlayer") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/realtour.htm", w, h + 30);
		
	else if (pluginlist.indexOf("Flash") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/flashtour.htm", w, h);
		
	else
		doLink("http://www.property.com.ua/mmlink.htm", 320, 260);
}
function doIvanTour()
{
	size = 320;
	w = 315;
	h = 240;

	if (pluginlist.indexOf("RealPlayer") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/ivanrealtour.htm", w, h + 30);
		
	else if (pluginlist.indexOf("Flash") != -1)
		doLink("http://www.property.com.ua/movies/" + size + "/ivanflashtour.htm", w, h);
		
	else
		doLink("http://www.property.com.ua/mmlink.htm", 320, 260);
}
function getReal(win)
{
	win.close();
	document.forms["Real"].submit();
}
function getFlash(win)
{
	win.close();
	document.forms["Flash"].submit();
}
function writeHeader()
{
	var IE = navigator.appName.indexOf('Microsoft') != -1 && navigator.userAgent.indexOf('MSIE') != -1;
	var IEstr = "<div style=\"font-size:14px; font-family: arial; font-weight: bold; color:#0066FF; margin-left: 7px; margin-bottom:-14px\">Convert currency</div>";
	var NNstr = "<div style=\"font-size:14px; font-family: arial; font-weight: bold; color:#0066FF; margin-left: 7px; margin-bottom: 4px\">Convert currency</div>";
	
	var str = IE ? IEstr : NNstr;	
	document.write(str);
}
function doImgs()
{
	if(screen.availWidth < 1000)
		document.images["map"].src = "images/skin/map_sm.jpg";
	
	else
		document.images["map"].src = "images/skin/map250.jpg";	
}
function closeCats(n)
{
	for(var i = 0; i < numCats; i++)
		if(i != n)
			if(document.getElementById("cats" + i))
				document.getElementById("cats" + i).style.display = "none";
}
function toggleCats(n)
{
	closeCats(n);
	
	if(document.getElementById)
	{
		var e = document.getElementById("cats" + n);
		
		if(e.filters && e.filters[0])
		{
			e.filters[0].Apply();
			e.filters[0].Play();
		}
		
		if(e.style.display == "none")
			e.style.display = "block";
		
		else
			e.style.display = "none";			
	}
}
var numCats = 3;
function navigate()
{	    
	if(frames["lhs"] && insertsEnabled)			
		frames["lhs"].location.replace("inserts.htm");
			
	if(frames["rhs"] && googleEnabled)
		frames["rhs"].location.replace("google.htm");
}
var trustEnabled = false;
var insertsEnabled = true;
var googleEnabled = false;

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com



