var _whats_hot_delay=200;
var _show_category = "";
var _last_load_category = "";
var _do_category = null;
var _show_child = "";
var _last_load_child = "";
var _do_child = null;

function categoryMouseOver(el) {
	try	{
		var id = el.id;
		if (_last_load_category == id) {
			return;
		}
		_show_category = id;
		_do_category = setTimeout("doCategoryMouseOver('"+id+"')", _whats_hot_delay);
	}
	catch (ex) {}
}

function doCategoryMouseOver(id) {
	var content = GetE("content_"+id);
	if (content!=null && content!=undefined) {
		GetE("product_display").innerHTML = content.innerHTML;
		setLastLoadCategory(id);
		return;
	}
	var surl = "/product/category_product";
	var postData = "type=category&id=" + id;
	var args = id;
	var request = Connect.asyncRequest('POST', surl, { success:successCategory, failure:failureCategory, argument:args }, postData)
}

function categoryMouseOut(el) {
	if (_show_category == el.id) {
		clearTimeout(_do_category);
	}
}

function setLastLoadCategory(id) {
	try { 	
		_last_load_category = id;
		var cats = GetTags(GetE("hot_categories"), "div");
		if (cats!=null) {
			for (var i=0; i<cats.length; i++) {
				if (cats[i].className == "item category_focus") {
					cats[i].className = "item";
				}
			}
		}
		GetE(id).className = "item category_focus";
	} catch (ex) {}
}

function successCategory(o) {
	try { 	
		if(o.responseText == undefined) {
			failureCategory(o);
			return;
		}
		setLastLoadCategory(o.argument);
		GetE("product_display").innerHTML = o.responseText;
		var div = document.createElement("div");   
		div.id = "content_" + o.argument;  
		div.innerHTML = o.responseText;
		GetE("product_display_content").appendChild(div);
		return;
	} catch (ex) {
		failureCategory(o);
		return;       
    }
}

function failureCategory(o) {
	window.location.reload();
}

function childMouseOver(el) {
	try	{
		var id = el.id;
		if (_last_load_child == id) {
			return;
		}
		_show_child = id;
		_do_child = setTimeout("doChildMouseOver('"+id+"')", _whats_hot_delay);
	}
	catch (ex) {}
}

function childMouseOut(el) {
	if (_show_child == el.id) {
		clearTimeout(_do_child);
	}
}

function doChildMouseOver(id) {
	var content = GetE("content_"+id);
	if (content!=null && content!=undefined) {
		GetE("product_display_detail").innerHTML = content.innerHTML;
		setLastLoadChild(id);
		return;
	}
	var surl = "/product/category_product";
	var postData = "type=child&id=" + id;
	var args = id;
	var request = Connect.asyncRequest('POST', surl, { success:successChild, failure:failureChild, argument:args }, postData)
}


function setLastLoadChild(id) {
	try { 	
		_last_load_child = id;
		var tr = GetE("product_display_list").rows[0];	
		for (var i=0; i<tr.cells.length; i++) {
			if (tr.cells[i].className=="focus") {
				tr.cells[i].className = "child";
			}
		}
		GetE(id).className = "focus";
	} catch (ex) {}
}

function successChild(o) {
	try { 	
		if(o.responseText == undefined) {
			failureChild(o);
			return;
		}
		setLastLoadChild(o.argument);
		GetE("product_display_detail").innerHTML = o.responseText;
		var div = document.createElement("div");   
		div.id = "content_" + o.argument;  
		div.innerHTML = o.responseText;
		GetE("product_display_content").appendChild(div);
		return;
	} catch (ex) {
		failureChild(o);
		return;       
    }
}

function failureChild(o) {
	window.location.reload();
}