﻿var baseopacity=0
var _strMaugoc;
function showtext(thetext){
if (!document.getElementById)
return
textcontainerobj=document.getElementById("tabledescription")
browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
document.getElementById("tabledescription").innerHTML=thetext
highlighting=setInterval("gradualfade(textcontainerobj)",50)
}
function hidetext(){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
textcontainerobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
textcontainerobj.filters.alpha.opacity=degree
else if (document.getElementById && baseopacity==0)
document.getElementById("tabledescription").innerHTML=""
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
	if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
		cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99)
	else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=20
	else if (window.highlighting)
		clearInterval(highlighting)
}
function swapimages(item,strSrc)
 {
    item.src=strSrc;     
 } 
 
 function changimage()
 {
	 document.getElementById("idPrice_imgTemplate").src = "images/general/blank.gif";
	 if(window.Form1.idPrice_drpSize.value.length==0)
		return;
	 document.getElementById("idPrice_imgTemplate").src = "images/upload/product/" + stridproduct + window.Form1.idPrice_drpSize.value + ".gif";
 }
 
function countprice()
{		
	var strid = stridproduct + "/";	
	window.idPrice_lblOneProduct.innerHTML = "0";
	window.idPrice_lblSum.innerHTML = "0";
	window.idPrice_lblSumpm.innerHTML = "0";
	
	if(window.Form1.idPrice_drpSize.value.length==0)
		return;	
	strid += window.Form1.idPrice_drpSize.value;
	if(window.Form1.idPrice_drpCatePage.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCatePage.value;
	if(window.Form1.idPrice_drpCanGap.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCanGap.value;
	if(window.Form1.idPrice_drpCanMang.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCanMang.value;
	if(window.Form1.idPrice_drpCateMe.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCateMe.value;
	if(window.Form1.idPrice_drpSum.value.length==0)
		return;
	strid += window.Form1.idPrice_drpSum.value;	
	SumPrice(strid);		
	//Start_Callback(detailproduct.StartLoadData(strid));		
	
}

function SumPrice(strid)
{
	var intStop;
	intStop = tableprice.length;
	for(i=0;i<=intStop;i++)
	{
		if(i==intStop){
			alert("Sản phẩm chưa có đơn giá!");
			return;
		}
		if(tablepricecode[i]==strid)
		{			
			var intPrices,intCount;
			intPrices = parseFloat(tableprice[i].replace(".","").replace(".","").replace(".","").replace(".","").replace(".",""));	
			
			intCount = parseFloat(window.Form1.idPrice_drpSum.options[window.Form1.idPrice_drpSum.selectedIndex].text.replace(".","").replace(".","").replace(".","").replace(".","").replace(".",""));
			window.idPrice_lblOneProduct.innerHTML = Math.ceil(intPrices/intCount);
			window.idPrice_lblSum.innerHTML = intCount;
			window.idPrice_lblSumpm.innerHTML = tableprice[i];						
			break;
		}
		
	}
}

/*function countpricecus()
{		
	var strid = stridproduct + "/";	
	window.idPrice_lblOneProduct.innerHTML = "0";
	window.idPrice_lblSum.innerHTML = "0";
	window.idPrice_lblSumpm.innerHTML = "0";
	
	if(window.Form1.idPrice_drpSize.value.length==0)
		return;	
	strid += window.Form1.idPrice_drpSize.value;
	if(window.Form1.idPrice_drpCatePage.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCatePage.value;
	if(window.Form1.idPrice_drpCanGap.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCanGap.value;
	if(window.Form1.idPrice_drpCanMang.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCanMang.value;
	if(window.Form1.idPrice_drpCateMe.value.length==0)
		return;
	strid += window.Form1.idPrice_drpCateMe.value;
	if(window.Form1.idPrice_txtNumber.value.length==0)
		return;
	//strid += window.Form1.txtNumber.value;	
	SumPricecus(strid);		
	//Start_Callback(detailproduct.StartLoadData(strid));		
	
}

function SumPricecus(strid)
{
	var intStop;
	intStop = tableprice.length;
	for(i=0;i<=intStop;i++)
	{
		if(i==intStop){
			alert("Sản phẩm chưa có giá!");
			return;
		}
		if(tablepricecode[i].indexOf(strid)!=-1)
		{			
			var intPrices,intCount;
			var lNumberPro = numberpro[i].replace("stemp",window.Form1.idPrice_txtNumber.value).replace("stemp",window.Form1.idPrice_txtNumber.value).replace("stemp",window.Form1.idPrice_txtNumber.value).replace("stemp",window.Form1.idPrice_txtNumber.value).replace("stemp",window.Form1.idPrice_txtNumber.value).replace("stemp",window.Form1.idPrice_txtNumber.value)			
			if(eval(lNumberPro))
			{			
				intCount = window.Form1.idPrice_txtNumber.value;
				intPrices = parseFloat(eval(tableprice[i].replace("stemp",window.Form1.idPrice_txtNumber.value).replace(".","").replace(".","").replace(".","").replace(".","").replace(".","").replace(".","").replace(".","")))				
				window.idPrice_lblOneProduct.innerHTML = Math.ceil(intPrices/intCount);
				window.idPrice_lblSum.innerHTML = intCount;
				window.idPrice_lblSumpm.innerHTML = intPrices;						
				break;
			}
		}
		
	}
}*/

function checknum()
{
	field = window.Form1.idPrice_txtNumber;
	if (field.value.length>0 && (field.value != parseInt(field.value)))
	{
		window.alert('Xin chỉ nhập các số tự nhiên!');
		field.value = field.value.replace(field.value.substring(field.value.length-1,field.value.length),'');
		return false;
	}
	else
	{	
		if((field.value.length == 0) || (parseInt(field.value) < "1"))
			field.value = "";		
	}
		
	countpricecus();
}
function Start_Callback(rs)
{
	var str = rs.value;
	//iitop.innerHTML = str;	
	alert(str);
} 

function showbk(strID){ 	

			if (document.getElementById("ipos" + strID.replace("=",""))!= null){
				document.getElementById("ipos" + strID.replace("=","")).className="style1";				
				document.getElementById("aipos" + strID.replace("=","")).style.color ="white";				
			}			
}
		
	function hidevisi(itemold,itemnew)
		{	
			//document.getElementById("hide" + itemold).text = "1";
			document.getElementById(itemold).style.display = "none";
			document.getElementById(itemnew).style.display = "block";
		}
function window_onscroll() {	
	if(document.getElementById("divWindow")!=null)
	{
		if (statestand){
			document.getElementById("divWindow").style.posTop = intPosWindow  + window.document.body.scrollTop;	
		}
	}
}
function updateses()
{
	//var ss=_default._updateses();
	//alert(ss.value);
	window.setTimeout('updateses()', 6000);
}