function STrim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}
var LT;
function fnShowShoppingItem(){
	if(document.getElementById('shoppingBagId').style.display == "block")
		document.getElementById('shoppingBagId').style.display = "none";
	LT=getPosition(document.getElementById('shopBagPos'));
	if(LT[0]>900){
		document.getElementById('idShoppingBag').style.left=LT[0]+(-200)+'px';
	}else{
		document.getElementById('idShoppingBag').style.left=LT[0]+(670)+'px';	
	}
	if(document.getElementById('isHOME').value==1){
		document.getElementById('idShoppingBag').style.top=LT[1]+38+'px';
	}else{
		document.getElementById('idShoppingBag').style.top=LT[1]+208+'px';
	}
	//document.getElementById("idShoppingBag").innerHTML = '<div style="position:absolute; right:-90px;" align="left"><img src="http://90.0.0.225/chennaisilks/skin/frontend/default/default/images/ajax-loader-l.gif" border="0" align="center" title="Loading.... Please wait"></div>';
	//shopping_items();
	document.getElementById("idShoppingBag").style.display = "block";
	
	if(STrim((document.getElementById("idShoppingBag").innerHTML).stripTags()) == 'No Items in shopping cart'){
		fnHideShoppingItem();
	}
	
}
function getPosition(who){
	var T= 0,L= 0;
	while(who){
		L+= who.offsetLeft;
		T+= who.offsetTop;
		who= who.offsetParent;
	}
	return [L,T];    
}
function fnHideShoppingItem(){
	setTimeout("fnHideItems()",3000);
}
function fnHideItems(){
	document.getElementById("idShoppingBag").style.display = "none";
}
function shopping_items(){ 
		if(document.getElementById('shoppingBagId')!=null){
			document.getElementById('shoppingBagId').style.display="none";
		}
		if ( window.XMLHttpRequest){
			http = new XMLHttpRequest();
		} else if ( window.ActiveXObject ){
			http = new ActiveXObject("Microsoft.XMLHTTP");
		}
		http.onreadystatechange = httpChanges;
		var url = "http://90.0.0.225/chennaisilks/show_cart_items.php?arg="+document.getElementById("hidQuoteID").value+"&arg1="+document.getElementById("hidCart").value;
		http.open("GET",url,true);
		http.send(null);
}

function httpChanges(){
	if ( http.readyState == 4 ){
		var str_all_response	= http.responseText;
		if ( str_all_response!=""  ){
			var dropmenuobj = document.getElementById("idShoppingBag");
			if(str_all_response == "<div align='center' style='border:#b0c6d3 1px solid; background-color:#145279; color:#ffffff; width:160px; float:left;'>No Items in shopping cart</div>"){
				dropmenuobj.innerHTML=str_all_response;
				fnHideShoppingItem();
			}else
				dropmenuobj.innerHTML=str_all_response;
		}
	}
}
