$(document).ready(function() {
	init();
});

/* ---- init ---- */
var init = function() {
	initIndicativePriceInfo('');
}

/* ---- indicative price info ---- */
var initIndicativePriceInfo = function(selector) {
	$(selector + ' .ind').hover(function(event) {
		$("#indicativeinfo").css({top: event.clientY + 16 + $(window).scrollTop(), left: event.clientX + 16 + $(window).scrollLeft() }).show();
	}, function() {
		$("#indicativeinfo").hide();
	});
}

function getobj(o) {
	if (document.getElementById) {
		return document.getElementById(o);
	} else if (document.all) {
		eval("obj = document.all." + o);
		return obj;
	}
	return false;
}

function getproperties(o) {
	result = '';
	for (var i in o) {
		if (i == 'innerHTML' || i == 'innerText' || i == 'outerHTML' || i== 'outerText') continue;
		result += i + ' => ' + o[i] + '\n';
	}
	return result;
}

function update_offset_url(selfurl) {
	var offset = '';
	var sep    = selfurl.indexOf('?') > -1 ? '&' : '?';

	if (typeof(window.pageYOffset) == 'number') {
		if (window.pageXOffset > 0 || window.pageYOffset > 0) {
			offset = sep + 'offset_x=' + window.pageXOffset + '&offset_y=' + window.pageYOffset;
		}
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		if (document.body.scrollLeft > 0 || document.body.scrollTop > 0) {
			offset = sep + 'offset_x=' + document.body.scrollLeft + '&offset_y=' + document.body.scrollTop;
		}
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		if (document.documentElement.scrollLeft > 0 || document.documentElement.scrollTop > 0) {
			offset = sep + 'offset_x=' + document.documentElement.scrollLeft + '&offset_y=' + document.documentElement.scrollTop;
		}
	}
	return selfurl.replace('&amp;', '&') + offset;
}

function openwin(name, url, w, h, param) {
	wtop  = 10;
	wleft = 10;
	
	if (!param) {
		param = 'status=0, menubar=0, resizable=1, copyhistory=no, directories=no, scrollbars=auto';
	}
	var popup = window.open(url, name, param + ', width=' + w + ', height=' + h + ', top=' + wtop + ', left=' + wleft);
	popup.focus();
	return popup;
}

function atmeretez() {
	NS = (navigator.appName=="Netscape") ? true : false;
	iW = NS ? window.innerWidth  : document.body.clientWidth;
	iH = NS ? window.innerHeight : document.body.clientHeight;
	iW = document.images[0].width  - iW;
	iH = document.images[0].height - iH;
	window.resizeBy(iW, iH);
	self.focus();
}

function fixmeret(w, h) {
	NS = (navigator.appName=="Netscape") ? true : false;
	iW = NS ? window.innerWidth  : document.body.clientWidth;
	iH = NS ? window.innerHeight : document.body.clientHeight;
	W = (w > 1000 ? 1000 : w) - iW;
	H = (h > 680 ? 680 : h) - iH;
	window.resizeBy(W, H);
	self.focus();
	if (w > 1000 || h > 680) {
		document.body.scroll = "auto";
	}
}

function xmlhttp(id, url, param, method) {
	var myConn = new XHConn();
	if (!myConn) alert('XMLHTTP not available. Try a newer/better browser.');
	var fnWhenDone = function (oXML) {
		document.getElementById(id).innerHTML=oXML.responseText;
	}
	myConn.connect(url, method ? method : 'GET', param, fnWhenDone);
}

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

function getcookie(name) {
	eval('cookie = document.cookie.match(/(^' + name + '=|; ' + name + '=)([^;]+)/);');
	return cookie ? unescape(cookie[2]) : null;
}

function decode_string(base, ref) {
	base = unescape(base);
	ref  = unescape(ref);
	str = '';
	for (i=0; i<ref.length; i++) {
		str += base.charAt(ref.charCodeAt(i) - 48);
	}
	document.write(str);
}

function form_keepalive(id, url) {
	xmlhttp(id, url, '');
	self.setTimeout("form_keepalive('" + id + "', '" + url + "')", 120000);
}

/* ---- xhconn ---- */


/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/

function XHConn() {
	var xmlhttp, bComplete = false;
	try { 
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} catch (e) { 
		try { 
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		} catch (e) { 
			try { 
				xmlhttp = new XMLHttpRequest(); 
			} catch (e) { 
				xmlhttp = false; 
			}
		}
	}
	if (!xmlhttp) return null;
	this.connect = function(sURL, sMethod, sVars, fnDone) {
		if (!xmlhttp) return false;
		bComplete = false;
		sMethod = sMethod.toUpperCase();

		try {
			if (sMethod == "GET") {
				xmlhttp.open(sMethod, sURL+"?"+sVars, true);
				sVars = "";
			} else {
				xmlhttp.open(sMethod, sURL, true);
				xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && !bComplete) {
					bComplete = true;
					fnDone(xmlhttp);
				}
			}
			xmlhttp.send(sVars);
		}
		catch (z) { 
			return false; 
		}
		return true;
	  };
	  return this;
}


