// JavaScript Document
/**
 * @uses:	This file is used to manage ajax for getting color code.
 * 
 * @author:	CIPL/SW/013
 * @dated:	Sunday March 09, 2008
 * 
 * @modified date:
 * @reason to modify:
 * @modify by: 
 */
function OnKeyPress_fn(e, frmName) {
	var eventcode = (e.keyCode) ? e.keyCode : (e.charCode) ? e.charCode : (e.which) ? e.which : void(0);
	if (eventcode == 13) {
		AddtoCart_Click_fn(frmName);
	};
}
function Readmore_Click_fn() {
	document.getElementById('div_longdesc').style.display = 'block';
	document.getElementById('div_shortdesc').style.display = 'none';
	//document.getElementById('div_link').innerHTML = '<a href="javascript:Readshort_Click_fn();" class="morelink-small">Read More...</a>&nbsp;<img src="images/common/up.jpg" border="0" />';
	document.getElementById('div_link').innerHTML = '<a href="javascript:Readshort_Click_fn();" class="morelink-small">Read More...</a>';
}
function Readshort_Click_fn() {
	document.getElementById('div_longdesc').style.display = 'none';
	document.getElementById('div_shortdesc').style.display = 'block';
	//document.getElementById('div_link').innerHTML = '<a href="javascript:Readmore_Click_fn();" class="morelink-small">Read More...</a>&nbsp;<img src="images/common/down.jpg" border="0" />';
	document.getElementById('div_link').innerHTML = '<a href="javascript:Readmore_Click_fn();" class="morelink-small">Read More...</a>';
}

function AddtoCart_Click_fn_backup(frmName) {
	var frmobj	=	eval("document."+frmName);
	var prd_id = frmobj.hi_prd_id.value;
	if (!IsNumeric(frmName,"tb_quantity","Quantity must be an integer.")) {
		return false;
	} else {	
		frmobj.action = "addtocart.php?prd_id="+prd_id;
	}
}

function AddtoCart_Click_fn(frmName) {
	var frmobj	=	eval("document."+frmName);
	var prd_id = frmobj.hi_prd_id.value;
	var quantity = frmobj.tb_quantity.value;
	if (quantity == 0) {
		alert("Quantity must be greater than zero.");
		return false;
	}
	
	if (!isInteger(quantity)) {
		alert("Quantity must be an integer.");
		return false;
	} else {	
		frmobj.action = "addtocart.php?prd_id="+prd_id;
	}
}

function Color_Select_fn(frmName) {
	var frmobj	=	eval("document."+frmName);
	var strparameters = getParameters(frmName);
	
	objxmlhttprequest.open("POST", "product_detail.ajax.php", true);
	objxmlhttprequest.onreadystatechange = function() {
		if(objxmlhttprequest.readyState == 4) {
			var response = objxmlhttprequest.responseText;
			if(response == "fail") {
				return false;
			} else {
				document.getElementById('div_colorcode').innerHTML = response;
			}
		}	//	End of if.
	};
	
	objxmlhttprequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	objxmlhttprequest.setRequestHeader('Content-Length', strparameters.length);
	objxmlhttprequest.setRequestHeader('Connection', 'close');
	
	objxmlhttprequest.send(strparameters);
}
function displayLargeImg() {
	var w, h, l, t;
	w = 450;
	h = 370;
	l = screen.width/4;
	t = screen.height/4;  
	
	l = l - 10;
	t = t - 90;              

	document.getElementById('div_MainMenu').style.display = 'none';
	document.getElementById('div_ProductMenu').style.display = 'none';
	displayFloatingDiv('div_LargeImg','Large Image', w, h, l, t);     		        
}

function hideLargeImg() {
	document.getElementById('div_MainMenu').style.display = 'block';
	document.getElementById('div_ProductMenu').style.display = 'block';
	hiddenFloatingDiv('div_LargeImg');
}