﻿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);
}
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(frmPopup_modalDialogVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = window.screen.availHeight + window.document.body.offsetHeight + 'px';////blanket_height + 'px';	
	blanket.style.width = window.screen.availWidth - 25 + 'px';//blanket_height*2-150 + 'px';
	var frmPopup_modalDialog = document.getElementById(frmPopup_modalDialogVar);
	frmPopup_modalDialog_height=blanket_height/2-150;//150 is half popup's height
	frmPopup_modalDialog.style.top = frmPopup_modalDialog_height + 'px';
	}
function window_pos(frmPopup_modalDialogVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var frmPopup_modalDialog = document.getElementById(frmPopup_modalDialogVar);
	window_width=window_width/2-150;//150 is half popup's width
	frmPopup_modalDialog.style.left = window_width + 'px';
}
function popup(windowname,strContent) {
	document.getElementById('ContentForm').innerHTML=strContent;
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
