﻿// JScript File
    function loadF()
    {
        SetCaptcha();
        document.getElementById("form1").attributes["action"].value=document.getElementById("form1").attributes["action"].ownerDocument.URL;//document.getElementById("form1").attributes["action"].baseURI;        
        //window.scrollTo(0,0) ;
	    return false; 
    }
    function NewWindow(url,vHeight,vWidth)
    {
       winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
       winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
       winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
       newWin = window.open(url, '_blank', winDef);
       newWin.focus();               
    }       
    function Counter(field, countfield, maxlimit) 
    {           
        if (field.value.length > maxlimit.value)	{	            
        field.value = field.value.substring(0, maxlimit.value);
        }            
        else { 
        countfield.value = maxlimit.value - field.value.length;
        }           
    }
    function ToggleDisplay(id)
	{
		var elem = document.getElementById(id);		
		
		if (elem)
		{		    	        
		    if (elem.style.display != 'block')
		    {
			    elem.style.display = 'block';
			    elem.style.visibility = 'visible';
		    }
		    else
		    {
			    elem.style.display = 'none';
			    elem.style.visibility = 'hidden';
		    }
		}
	}
    function CleanFrom() 
    { 
        document.getElementById("form1").reset();
        return false;
    } 
  
    
    function PrintSubject()
    {  
	   	w=open();
	    w.document.writeln('<html>');
	    w.document.writeln('<head>');
	    w.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
	    w.document.writeln('<link rel="stylesheet" href="../App_Themes/Default/Default.css" type="text/css">');
	    w.document.writeln('</head>');
	    w.document.writeln('<body topmargin=3 leftmargin=0 marginheight=3 marginwidth=0>');
	    w.document.writeln('<table cellspacing=0 cellpadding=0 border=0 width=600 align=center>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td colspan="2" >');
	    w.document.writeln(document.getElementById('Banner').innerHTML);
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td  >');	    
	    w.document.writeln(document.getElementById('Content').outerHTML);	    	    
	    w.document.writeln('<a onclick="javascript:location.reload(true);window.print();" style=" cursor:hand" class="VNVN_17_UC_FOOTER_Print">');
	    w.document.writeln('<img src="../Images/icon_printthispage.jpg" />');	
	    w.document.writeln('  Print this page');
	    w.document.writeln('</a></td>');
	    w.document.writeln('<td  style="padding-left:15px;" class="VNVN_17_UC_PRODUCT_DETAIL_Text">');	    
	    w.document.writeln(document.getElementById('Content1').outerHTML);	    	    
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td colspan="2">');	    
	    w.document.writeln(document.getElementById('Footer').outerHTML);	    	    
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');	    
	    w.document.writeln('</table>');
	    w.document.writeln('</body>');
	    w.document.writeln('</html>');
	    w.document.title = document.title;	   
	    return false; 
    }

 
PositionX = 100;
PositionY = 15;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 100;
defaultHeight = 100;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=300,height=250,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle,smallimage)
{
     if (imageTitle=='') imageTitle = 'Popup Image';
    if (isNN){imgWin=window.open('about:blank','',optNN);}
    if (isIE){imgWin=window.open('about:blank','',optIE);}
   
     with (imgWin.document)
      {
      
              writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Loading...</title><style>body{margin:0px;} .DemoImage{width:50px;height:50px;padding:5px;}</style>');
              writeln('<sc'+'ript>');
              writeln('function loadimg(img){');
              writeln('window.resizeTo(500, 500)');
              writeln('var img=document.getElementById("img_Product"); var w = 500 - (document.getElementById("Zone").offsetWidth - img.width) + 50');
              writeln('var h = 500 - (document.getElementById("Zone").offsetHeight - img.height)+ 100');
              writeln('window.resizeTo(w, h)');
              writeln('}');
              writeln('function DisplayImage(stringid,sPath,sPath2){');
              writeln('var s_Image=document.getElementById("img_Product");');
              writeln('if(s_Image!=null){s_Image.src=sPath2; }}');
              writeln('</sc'+'ript>');
              writeln('</head>');
              writeln('<body ><center>');
              writeln('<div id="Zone" style="position:fixed; top:0px; left:0px; visibility:hidden; width:100%; height:100%"></div>');              
              writeln(document.getElementById("Product_pnl_Image").innerHTML);                
              writeln('<img id="img_Product" border="0" src="' + imageURL + '" onload="loadimg(this);" />');
              writeln('<div style="text-align:center;margin:20px 0px">');
              //writeln('<img id="img_Product" border="0" src="App_Themes/Default1/Images/closeme.jpg" onclick="javascript:self.close()"/>');
              writeln('</div>');
              
              
              //writeln('<div style="text-align:center;margin-bottom:20px 0px;background-color:#d2d7d0;font-family:tahoma;font-size:11px">' + document.getElementById("BoxFooter2").innerHTML + "</div>" );
              writeln('</center></body>');
              writeln('</html>');
        }
}


function popProduct(imageDesignURL,imageFrameUrl,imageTitle)
{
    if (imageTitle=='') imageTitle = 'Popup Image';
    if (isNN){imgWin=window.open('about:blank','',optNN);}
    if (isIE){imgWin=window.open('about:blank','',optIE);}
    with (imgWin.document)
    {
        writeln('<html><head><title>Loading...</title><link href="../App_Themes/default/Default.css" rel="stylesheet" type="text/css" /><link href="App_Themes/default/Default.css" rel="stylesheet" type="text/css" /><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
        writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
        writeln('width=(document.images[0].width-document.body.clientWidth)+100;');
        writeln('height=(document.images[0].height-document.body.clientHeight)+100;');
        writeln('window.resizeBy(width,height);}');writeln('if (isNN){');       
        writeln('window.innerWidth=document.images["George"].width+100;');writeln('window.innerHeight=document.images["George"].height+100;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');
        writeln('function innitFrame(){if(document.forms[0]["George"].width>document.images["George"].height){document.forms[0]["Frame"].width=document.forms[0]["George"].width+10;document.forms[0]["Frame"].height=document.images["George"].height+5;}else{document.forms[0]["Frame"].width=document.forms[0]["George"].width+10;document.forms[0]["Frame"].height=document.images["George"].height+8;}}');
        writeln('</sc'+'ript>');
        if (!AutoClose) writeln('</head><body bgcolor=#fff0e7 scroll="no" onload="reSizeToImage();doTitle();self.focus();innitFrame();">')
        else writeln('</head><body bgcolor=#fff0e7 scroll="no" onload="reSizeToImage();doTitle();self.focus();innitFrame();" >');
        writeln('<form id="form1" runat="server">');
        writeln('<table cellspacing="20px;" width="100%" border="0"><tr style="width:100%"><td style="width:10px;"></td><td style="width:100%">');
         writeln('<div id="examplematScript" >');
        writeln('<img id="George" name="George" src='+imageDesignURL+' alt="" />');
        writeln('</div>');
        writeln('<div id="exampleframe">');
        writeln('<img id="Frame" name="Frame" src='+imageFrameUrl+' alt="" width="javascript:document.images[0].width" height="javascript:document.images[0].height" />');
        writeln('</div>');
       
        
        writeln('</br>');
        writeln('<div onclick="javascript:self.close();" style="text-align:center"><a href="#">Close</a></div>');
        writeln('</td><td style="width:10px;"></td></tr></table>');
        writeln('</form>');
        writeln('</body></html>');
        close();		
  }
}

function getDataTotbState(id1,id2)
{
    var obj = document.getElementById(id1);
    var tb = document.getElementById(id2);
    tb.value  = obj.options[obj.selectedIndex].innerHTML;
}

var optionsArr = null;

function ddl_Singer_OnChange(ddl, ctrlDDL, index, voteNumber)
{
   if (!ddl) ddl = document.getElementById(ctrlDDL + 0);
   if (!optionsArr)
   {
        optionsArr = {};
        for (var i = 0 ; i < ddl.options.length ; i++)
        {
         var item = ddl.options[i];
         optionsArr[item.value] = { text : item.innerHTML, choose : false};
        }
        for (var i = 0 ; i < voteNumber ; i++)
        {
            var curDDL = document.getElementById(ctrlDDL + i);
            var value = curDDL.value;
            if (optionsArr[value].choose)
            {
                for (var v in optionsArr) 
                    if (!optionsArr[v].choose) value = v;
            }
            optionsArr[value].choose = true;
            curDDL.value 	= value;
			curDDL.oldValue	= value;
        }
   }

	var oldValue = ddl.oldValue;
	var newValue = ddl.value;   
	if (oldValue != null) optionsArr[oldValue].choose = false;
	if (newValue != null)
	{
		optionsArr[newValue].choose = true;
		ddl.oldValue = newValue;
	}
	for (var i = 0 ; i < voteNumber ; i++)
	{
		if (i == index)
			continue;
		var curDDL			= document.getElementById(ctrlDDL + i);
		var value			= curDDL.value;
		curDDL.innerHTML	= "";
		for (var v in optionsArr)
		{
			var item = optionsArr[v];
			if (!item.choose || v == value)
			{
				var opt			= document.createElement("OPTION");
				curDDL.options.add(opt);
				opt.value		= v;
				opt.innerHTML	= item.text;
			}
		}
		if (value)
			curDDL.value = value;
	}
}
function DisplayDate(stringid,sPath)
{            
    var objArticle_Date1 = new calendar2(document.getElementById(stringid)); 
    objArticle_Date1.year_scroll = true; 
    objArticle_Date1.time_comp = false;        
    objArticle_Date1.popup("",sPath);
}
 
function DisplayImage(stringid,sPath,sPath2)
{
    var s_Image=document.getElementById("Product_img_Product");
    if(s_Image!=null)
    {
        s_Image.src=stringid;
    }
}


 function PrintOrder()
    {  
	   	w=open();
	    w.document.writeln('<html>');
	    w.document.writeln('<head>');
	    w.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
	    w.document.writeln('<link rel="stylesheet" href="../App_Themes/Default/Default.css" type="text/css">');
	    w.document.writeln('<style> td,span,a,a:hover {font-size:12px}, .VNVN_20_CSS_Tracking_Value,.VNVN_20_CSS_BillingShipping_Info_Value,.VNVN_17_UC_FOOTER_Text,.ShoppingCart_Total,.VNVN_20_CSS_BillingShipping_Info_Title ,.VNVN_20_CSS_Tracking_Title {font-size:12px;} body{background-color:#fff;color:#000;font-size:11px;font-family:tahoma }</style>  ');
	    w.document.writeln('</head>');
	    w.document.writeln('<body topmargin=3 leftmargin=0 marginheight=3 marginwidth=0>');
	    w.document.writeln('<table cellspacing=0 cellpadding=0 border=0 width=600 align=center>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td colspan="2" >');
	    w.document.writeln(document.getElementById('Position_1901').innerHTML);
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td  >');	    
	    w.document.writeln(document.getElementById('dvContainFullOrder').innerHTML);	    	    
	    w.document.writeln('<a onclick="javascript:location.reload(true);window.print();" style=" cursor:pointer;" class="VNVN_17_UC_FOOTER_Print">');
	    w.document.writeln('<img src="../Images/icon_printthispage.jpg" style="cursor:pointer;" />');	
	    w.document.writeln('  Print this page');
	    w.document.writeln('</a></td>');
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td colspan="2">');	    
	    w.document.writeln(document.getElementById('Footer').innerHTML);	    	    
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');	    
	    w.document.writeln('</table>');
	    w.document.writeln('</body>');
	    w.document.writeln('</html>');
	    w.document.title = document.title;	   
	    return false; 
    }    
    
    
    Function.prototype.bind = function(){    
    
    var method = this;//this la function truyen vao
    
    if(arguments.length < 2 && arguments[0] === undefined)
        return this;
    //arguments nay chi read ,ko co cac phuong thuc nhu 1 mang binh thuong ma ta khai bao de su dung 
        
    var args = [];
    for(i=0;i<arguments.length; i++)
    {
        args.push(arguments[i]);
    }
    var object = args.shift();//shift lay ra fan tu dau tien cua mang.  
    return function(){
        return method.apply(object,args);//truyen args cho method
    };   

}

function loadProductBox(sArr,ilimit,ilimittime,listptitle)
{
    if(sArr.split(';').length >0)
    {
        
        var func = function()
        {
            CalloadProductBox(sArr,ilimit,listptitle);
        }
        func();
        ilimittime = (ilimittime ==0)? 10000 :ilimittime ;//ilimittime
        window.setInterval(func,ilimittime);
    }
}
function random_number(min,max) {

    return (Math.round((max-min) * Math.random() + min));
} 

function CalloadProductBox(sArr,ilimit,listptitle)
{
    document.getElementById('ContainPBox').innerHTML = '' ;
    var aArr = sArr.split(";");
    var pos;
    var aArr2 = new Array();
    var arrKeeppos = new Array();
    var temp;
    for(var i=0;i<ilimit;i++)
    {
        temp = random_number(0,aArr.length-2);//Math.ceil(Math.random() * (aArr.length-2)) ;
        var j;
        for (j=0;j<arrKeeppos.length;j++)
            {
                if(temp == arrKeeppos[j])
                {
                    temp = random_number(0,aArr.length-2);  
                    j==0;
                }
            }
        if(j==0 || j== arrKeeppos.length) { pos = temp;arrKeeppos[j] = temp };
        aArr2 = aArr[pos].split('|');
        var proid =  aArr2[0];
        var ContainItem = document.createElement('div');
        ContainItem.className = 'dvContainItemPBox'; 
        
        var CTIMG = document.createElement('div');
        var AImg = document.createElement('a');
        var img = document.createElement('img');
        img.src = aArr2[3];
        AImg.href = aArr2[7];
        img.className = "PBoxRightAimage";
        CTIMG.appendChild(AImg);
        AImg.appendChild(img);
        CTIMG.className ="AlignCenter";
        ContainItem.appendChild(CTIMG);
        
        
        var CTTitle = document.createElement('div');
        var aTitle = document.createElement('a');
        aTitle.id = 'aTitle_'+ proid;
        aTitle.innerHTML = aArr2[1];
        aTitle.href = aArr2[7];
        aTitle.className = "VNVN_17_UC_PRODUCT_LIST_Title";
        CTTitle.appendChild(aTitle);
        CTTitle.className ="AlignCenter";
        ContainItem.appendChild(CTTitle);
        
        var CTSPType = document.createElement('div');
        var SPType = document.createElement('span');
        SPType.innerHTML = aArr2[4];
        CTSPType.appendChild(SPType);
        CTSPType.className ="AlignCenter";
        ContainItem.appendChild(CTSPType);
        
        var CTSPDics = document.createElement('div');
        var SPDics = document.createElement('span');
        SPDics.innerHTML = aArr2[2];
        CTSPDics.appendChild(SPDics);
        CTSPDics.className ="AlignCenter";
        ContainItem.appendChild(CTSPDics);
        
        var CTSPrice = document.createElement('div');
        var SPPrice = document.createElement('span');
        SPPrice.innerHTML = aArr2[5];
        SPPrice.className = "VNVN_17_UC_PRODUCT_LIST_Price";
        CTSPrice.appendChild(SPPrice);
        CTSPrice.className ="AlignCenter";
        ContainItem.appendChild(CTSPrice);
        
        if((aArr2[6].toString().indexOf('$0.0')) != 0)
        {
            var CTSLPrice = document.createElement('div');
            var SPLPrice = document.createElement('span');
            var SPTitleLPrice = document.createElement('span');
            SPTitleLPrice.innerHTML = listptitle;
            CTSLPrice.appendChild(SPTitleLPrice);
            SPLPrice.innerHTML = aArr2[6];
            SPLPrice.className = "VNVN_17_UC_PRODUCT_LIST_ListPrice";
            CTSLPrice.appendChild(SPLPrice);
            CTSLPrice.className ="AlignCenter";
            ContainItem.appendChild(CTSLPrice);
        }    
            
        var CTAdd = document.createElement('div');
        var hp = document.createElement('a');
        hp.id = 'a_'+ proid;
        var img = document.createElement('img');
        img.id = 'img_' + proid;
        img.src = '../Images/icon_addtocart.jpg';
        hp.onclick = AddtocartClientHandler.bind(hp,proid);
        CTAdd.appendChild(hp);
        CTAdd.className ="AlignCenter";
        hp.appendChild(img);
        ContainItem.appendChild(CTAdd);
        
        document.getElementById('ContainPBox').appendChild(ContainItem);
       
    }
}

function AddtocartClientHandler(id) 
{
    BubbleEventServer(id);
}
function ReceiveServerAddtocart(arg)
{
    window.location.reload(arg);
}


function OpenWindow(Url) {     
    window.open(Url);        
   } 
   
function DisableControl(o,event)
{
    OnPleaseWait("AdminDvWait",event);
    o.enabled=false; 
    return true;
}
function OnPleaseWait(sCtrID,event){    
    var ctrWait = document.getElementById(sCtrID);//findTheDivByID    
    if(ctrWait!=null  && event!=null)
    {
        ctrWait.style.display = "block";        
        var y=event.clientY+document.documentElement.scrollTop;
        if(event.clientY==0)
            ctrWait.style.top = y +200+ "px";
        else
            ctrWait.style.top = y+ "px";
        if(event.clientX==0)            
            ctrWait.style.left =event.clientX+300 +document.documentElement.scrollLeft + "px";
        else
            ctrWait.style.left =event.clientX+50+document.documentElement.scrollLeft + "px";
    }
}
//=========================================================================
// Off Please wait...
//=========================================================================
function OffPleaseWait(sCtrID){    
    var ctrWait = document.getElementById(sCtrID);
    ctrWait.style.display = "none";
}