/*
 copyright (c) VINCINELLI GROUP 
*/

function toggleImg(id, src, className) {
	if (document.getElementById) {
		document.getElementById(id).className = className;
		document.getElementById(id).src = src;
		document.getElementById(id).style.cursor = "pointer";
	}
}

function setMeActive(id, bigSrc) {
	document.getElementById('bigimage').src = bigSrc;
}

function showPic(id, action, url, X, Y) {
	if (action == 'hide') {
		parent.getEl('piclayer').style.display='none';
	}
	else  if (action == 'show') {
		getmousePos();
		parent.getEl('piclayer').style.display = 'inline';
		parent.getEl('piclayer').style.left = X+mousex+'px';
		parent.getEl('piclayer').style.top = Y+mousey+'px';
		parent.getEl('piclayer').innerHTML = '<img src=\"/site/img/gallery/loading.gif\">';
		
		URL = url+id;
		h_get(URL, printPic);
	}
}

function printPic() {
	if (req.readyState == 4) {
		if (document.getElementById('piclayer')) {
			parent.getEl('piclayer').innerHTML = '';
			parent.getEl('piclayer').innerHTML = req.responseText;
		}
	}
}

/////////////////////////////////////////////////////////////

function loadDesc(id) {
	if (document.getElementById) {
		document.getElementById('picDesc').innerHTML = "<div class=\"text\">Wait while loading</div>";
		sendRequest("http://" + document.location.host + "/index.php", "POST", true, "IsPostBack=1&act=loadPicDesc&picid=" + id, showDesc);
	}
}

function showDesc(request) {
	if (document.getElementById) {
		// alert(request.responseText);
		var product = request.responseXML.getElementsByTagName("product")[0].getAttributeNode("val").value;
		var client  = request.responseXML.getElementsByTagName("client")[0].getAttributeNode("val").value;
		var year    = request.responseXML.getElementsByTagName("year")[0].getAttributeNode("val").value;
		//document.getElementById('picDesc').innerHTML = (request.status == 200) ? ("product" + product + "<br>client" + client "<br>year" + year) : "<div class=\"text red\">Server internal error</div>";
		var str = "<span style=\"color:#999\">product</span>: " + product+Math.random()*10 + "<br><span style=\"color:#999\">client</span>: " + client + "<br><span style=\"color:#999\">year</span>: " + year;
		document.getElementById('picDesc').innerHTML = (request.status == 200) ? str : "<div class=\"text red\">Server internal error</div>";
	}
}

///

function putDesc(id) {
	document.getElementById('picDesc').innerHTML = picdesc_arr[id];
}