
addNamespace("KY.Web.HoverMenu");

KY.Web.HoverMenu = Class.create();

Object.extend(KY.Web.HoverMenu.prototype, {
	objXML: null,
	r: null,
	pid: null,
	width:300,
	height:200,
	timer: -1,
	htmlText: null,
	urlpath: null,
	expandcollapseTimer: null,
	hide: function() {
		if (this.timer != -1) { clearTimeout(this.timer); }
		this.div.style.display = 'none';
	},
	expand:function(){
		var bounds = MS.Position.getBounds(this.div);
		if(bounds.height >= this.height && bounds.width >= this.width){
			clearInterval(this.expandcollapseTimer);
			bounds.height = this.height;
			bounds.width = this.width;
		}
		if(bounds.height < this.height) bounds.height += 40;
		if(bounds.width < this.width) bounds.width += 20;
		MS.Position.setBounds(this.div, bounds);
	},
	onimageload:function(){

		this.expandcollapseTimer = setInterval(this.expand.bind(this),50);

		var table = document.getElementById("producthover_main_table");
		var tableBounds = MS.Position.getBounds(table);
		this.height = tableBounds.height;

	},
	show: function() {
		clearInterval(this.expandcollapseTimer);
		this.r = MS.Position.getBounds(this.ele);
		MS.Position.setBounds(this.div, this.r);
		this.div.style.overflow = "hidden";
		this.div.style.cursor = "auto";
		this.ele.style.cursor = "auto";
		
		if(this.div.innerHTML != this.htmlText)
		{
			this.div.innerHTML = this.htmlText;
			this.div.style.zIndex = MaxZIndex() + 1;
		}

		this.div.style.width = "0px";
		this.div.style.height = "0px";
		this.div.style.display = "inline";

		var image = document.getElementById("producthover_image");
		addEvent(image, "load", this.onimageload.bind(this)); 
	},
	onmouseout: function(e) {
		this.hide();
	},
	onmouseover: function(e) {
		if (this.timer != -1) { clearTimeout(this.timer); }

		this.r = MS.Position.getBounds(this.ele);
		MS.Position.setBounds(this.div, this.r);
		this.div.style.cursor = "progress";
		this.ele.style.cursor = "progress";
		this.div.style.width = "30px";
		this.div.style.height = "30px";
		//this.div.innerHTML = "<table width=\"30px\" height=\"30px\"><tr><td align='left' valign='top'><img alt='Yukleniyor...' border='0' src='/resim/ajax-loader.gif'></td></tr></table>";
		//this.div.innerHTML = "<table width=\"30px\" height=\"30px\"><tr><td align='left' valign='top'></td></tr></table>";
		this.div.style.display = "none";
		this.timer = setTimeout(this.preparedata.bind(this),750);
	},
	preparedata: function() {
		if (this.htmlText == null) { this.getData(); return; }
		else { this.show(); }
	},
	getData: function() {
		objXML = null;
		if (window.XMLHttpRequest) {
			objXML = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			objXML = new ActiveXObject("Microsoft.XMLHTTP");
		}
	
		var b = this;
		var url = window.location.protocol + "//" + window.location.hostname + this.urlpath + this.pid;
		if (objXML) {
			objXML.onreadystatechange = function() {
				if(objXML.readyState == 4)
				{
					if(objXML.status != 200) { return; }
				}
				else 
				{
					return;
				}
				b.htmlText = objXML.responseText;
				b.show();
			};
		}

		this.r = MS.Position.getBounds(this.ele);
		MS.Position.setBounds(this.div, this.r);
		this.div.style.cursor = "progress";
		this.ele.style.cursor = "progress";
		//this.div.innerHTML = "<table width=\"30px\" height=\"30px\"><tr><td align='left' valign='top'></td></tr></table>";
		//this.div.innerHTML = "<table width=\"30px\" height=\"30px\"><tr><td align='center'><img alt='Yükleniyor...' border='0' src='/resim/ajax-loader.gif'></td></tr><tr><td align='center'>Yukleniyor...</td></tr>"
		this.div.style.display = "none";
		objXML.open("GET", url, true);
		objXML.setRequestHeader("Accept-Charset", "iso-8859-9");
		objXML.setRequestHeader("Accept-Language", "tr");
		objXML.send(null);
	},
	initialize: function(eleId, pId, divId, width, height, surl) {
		this.pid = pId;
		this.width = width;
		this.height= height;
		this.ele = $(eleId);
		this.urlpath = surl;

		if (this.urlpath == "")
		{
			this.urlpath = "/producthover.asp?r=";
		}
		this.r = MS.Position.getBounds(this.ele);
		this.div = document.getElementById(divId);
		addEvent(this.ele, "mouseover", this.onmouseover.bind(this));
		addEvent(this.ele, "mouseout", this.onmouseout.bind(this));

	}
}, false);

addNamespace("KY.Web.HoverMenuArray");

KY.Web.HoverMenuArray = Class.create();

Object.extend(KY.Web.HoverMenuArray.prototype, {
	count: 0,
	w:0,
	h:0,
	arrayEle: null,
	arrayValue: null,
	timer: -1,
	addItem: function(eleid, pId) {
		this.arrayEle[this.count] = eleid;
		this.arrayValue[this.count] = pId;
		this.count++;
	},
	addItem2: function(eleid, pId) {
		this.arrayEle[this.count] = eleid;
		this.arrayValue[this.count] = pId;
		this.count++;

		if ($("hoverdiv_image")) {
			this.div = $("hoverdiv_image");
		}
		else {
			this.div = document.createElement("div");
			this.div.id = "hoverdiv_image";
			this.div.style.display="none";
			document.body.appendChild(this.div);
			addEvent(this.div, "mouseover", this.ondivmouseover.bind(this));
			addEvent(this.div, "mouseout", this.ondivmouseout.bind(this));
		}
		new KY.Web.HoverMenu(eleid, pId, this.div.id, this.w, this.h, "/producthover.asp?r=");

	},
	ondivmouseover: function(e) {
		if (this.timer != -1) { clearTimeout(this.timer); }
		this.div.style.display='inline';
	},
	ondivmouseout: function(e) {
		this.timer = setTimeout(this.hide.bind(this),1000);
	},
	hide: function(e) {
		this.div.style.display='none';
		this.timer = -1;
	},
	initialize: function(width, height) {
		this.arrayEle = new Array();
		this.arrayValue = new Array();
		this.w = width;
		this.h = height;
	},
	clear: function() {
		this.arrayEle = new Array();
		this.arrayValue = new Array();
		this.arrayUrl = new Array();
	},
	create: function() {
		if ($("hoverdiv_image")) {
			this.div = $("hoverdiv_image");
		}
		else {
			this.div = document.createElement("div");
			this.div.id = "hoverdiv_image";
			this.div.style.display="none";
			document.body.appendChild(this.div);
			addEvent(this.div, "mouseover", this.ondivmouseover.bind(this));
			addEvent(this.div, "mouseout", this.ondivmouseout.bind(this));
		}

		for (i = 0; i < this.count; i++ )
		{
			if (this.arrayEle[i] == null) { continue; }
			new KY.Web.HoverMenu(this.arrayEle[i], this.arrayValue[i], this.div.id, this.w, this.h, "/producthover.asp?r=");
		}
	}
},false);


addNamespace("KY.Web.HoverMenuArray2");

KY.Web.HoverMenuArray2 = Class.create();

Object.extend(KY.Web.HoverMenuArray2.prototype, {
	count: 0,
	w:0,
	h:0,
	arrayEle: null,
	arrayValue: null,
	arrayUrl: null,
	timer: -1,
	addItem: function(eleid, pId, urlpath) {
		this.arrayEle[this.count] = eleid;
		this.arrayValue[this.count] = pId;
		this.arrayUrl[this.count] = urlpath;
		this.count++;
	},
	ondivmouseover: function(e) {
		if (this.timer != -1) { clearTimeout(this.timer); }
		this.div.style.display='inline';
	},
	ondivmouseout: function(e) {
		this.timer = setTimeout(this.hide.bind(this),1000);
	},
	hide: function(e) {
		this.div.style.display='none';
		this.timer = -1;
	},
	initialize: function(width, height) {
		this.arrayEle = new Array();
		this.arrayValue = new Array();
		this.arrayUrl = new Array();
		this.w = width;
		this.h = height;
	},
	clear: function() {
		this.arrayEle = new Array();
		this.arrayValue = new Array();
		this.arrayUrl = new Array();
	},
	create: function() {
		if ($("hoverdiv_image")) {
			this.div = $("hoverdiv_image");
		}
		else {
			this.div = document.createElement("div");
			this.div.id = "hoverdiv_image";
			this.div.style.display="none";
			document.body.appendChild(this.div);
			addEvent(this.div, "mouseover", this.ondivmouseover.bind(this));
			addEvent(this.div, "mouseout", this.ondivmouseout.bind(this));
		}

		for (i = 0; i < this.count; i++ )
		{
			if (this.arrayEle[i] == null) { continue; }
			new KY.Web.HoverMenu(this.arrayEle[i], this.arrayValue[i], this.div.id, this.w, this.h, this.arrayUrl[i]);
		}
	}
},false);


function activateHoverMenu(imgid, pid, divid) {
	setTimeout("initHoverMenu('" + imgid+ "', '" + pid + "', '"+ divid+"')", 2);

}
function initHoverMenu(imgid, pid, divid) {
	new KY.Web.HoverMenu(imgid, pid, divid, 188, 100, "");
}

objHArray = new KY.Web.HoverMenuArray(188,100);
objHArray2 = new KY.Web.HoverMenuArray2(60, 100);

