﻿// JScript File
// Tự Động Mở Full Màn Hình
//window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
//top.window.fullScreen=true;
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//Bảo vệ website không cho người khác link vào frame của họ

if (top.location != self.location) 
{top.location = self.location}

//Chuyển đổi ngôn ngữ


function Translate(selectedlang) {
        if (location.hostname == 'theky21.com.vn' && selectedlang.value == 'vn|vn')
                return;
        else if(location.hostname != 'theky21.com.vn' && selectedlang.value == 'vn|vn')
                location.href = done('u');
        else if(location.hostname == 'theky21.com.vn' && selectedlang.value != 'vn|vn')
                location.href = 'http://translate.google.com/translate_p?client=tmpg&hl=en&langpair=' + selectedlang.value + '&u=' + location.href;
        else
                location.href = 'http://translate.google.com/translate_p?client=tmpg&hl=en&langpair=' + selectedlang.value + '&u=' + done('u');
}


function done(name) {
        name = name.replace(/[[]/,"[").replace(/[]]/,"]");

        var origURL = "[?&]"+name+"=([^&#]*)";
        var orig = new RegExp(origURL);
        var results = orig.exec(location.href);

        if(results == null)
                return '';
        else
                return results[1];
}




//Refresh Window
function refreshData()
{
    window.location.reload();
}
//

function viewStatus(sttStatus)
{
    var str = new String();
    str = "<-----  century21.com.vn - Always Bring Belief To You  ----->          ";
    this.window.status =str.substring(0,sttStatus);
    if(sttStatus<str.length)
        sttStatus++;
    else
    {
        window.status="";
        sttStatus=0;
    }
    
        opcTimeoutStatus = setTimeout('viewStatus('+sttStatus+')',100);
}
function popDemoQC(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,location=yes,addressbar=yes,width=1000,height=600');
newWindow.focus();
}
function popDemoList(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=no,resizable=no,scrollbars=yes,status=no,location=no,addressbar=no,width=650,height=1000');
newWindow.focus();
}
function popDemoNews(N) {
newWindow = window.open(N, 'popD','toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=no,addressbar=no,width=650,height=1000');
newWindow.focus();
}
function popDemoProject(N) {
newWindow = window.open(N, 'popD','toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,addressbar=no,width=800,height=800, left=0, top=0');
newWindow.focus();
}
//Open Window New
function popDemoGV(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=no,resizable=no,scrollbars=no,status=no,location=no,addressbar=no,width=200,height=300');
newWindow.focus();
}
function popDemoNT(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=no,resizable=no,scrollbars=no,status=no,location=no,addressbar=no,width=500,height=500');
newWindow.focus();
}
function popDemoCS(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=no,resizable=no,scrollbars=no,status=no,location=no,addressbar=no,width=1000,height=600');
newWindow.focus();
}
function popDemo590(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=no,resizable=no,scrollbars=no,status=no,location=no,addressbar=no,width=590,height=500');
newWindow.focus();
}
function popDemo(N) {
newWindow = window.open(N, 'popD','toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,location=yes,addressbar=yes,width=1000,height=600');
newWindow.focus();
}

opc=0;

function DelayContent()
{
   opc+=1;
   if(opc<=100)
   {
        var oject= document.getElementById("divContentPlace");        
        oject.style.filter="alpha(opacity="+opc+")";
        opcTimeout = setTimeout('DelayContent()',1000);
   }
   else
        clearTimeout(opcTimeout);
}

//The End
  

//Hiệu Ứng Logo
function DelayLogo(){
if(screen.availWidth<1280)
    return;

divLogoBannerDynamic.style.visibility= "visible";
divLogoBannerDynamic.style.filter="alpha(opacity=50)";
divLogoBannerDynamic.style.left=15;
divLogoBannerDynamic.style.top=window.document.body.scrollTop+10;
setTimeout('DelayLogo()',20);
}
//The End


giatri1=10;
function MoCuaSo()
{    
	document.frmHomePage.picHinh1.style.filter="alpha(opacity="+giatri1+")";
	document.frmHomePage.picHinh1.width=150;
	//document.frmHomePage.picHinh1.width=document.frmHomePage.BangMain.style.width;
	giatri1+=1;
	if(giatri1>=100)
		clearTimeout(iwin);	
	iwin=setTimeout("MoCuaSo()",500);
}


function XuLyHinh()
{
    strPage=new String();
    strPage=window.location+"#";    
    ViTriCuoi=strPage.lastIndexOf(".aspx");
    ViTri=0;
    if(ViTriCuoi<0)
        ViTri=1;
    else
    {
        ViTriDD=strPage.lastIndexOf("/");
        strPage=strPage.substring(ViTriDD+1,ViTriCuoi);
        if(strPage.toLowerCase().indexOf("default")==0)
            ViTri=1;
        else if(strPage.toLowerCase().indexOf("about")==0)
            ViTri=2;
        else if(strPage.toLowerCase().indexOf("product")==0)
            ViTri=3;
        else if(strPage.toLowerCase().indexOf("service")==0)
            ViTri=4;
        else if(strPage.toLowerCase().indexOf("cartshop")==0)
            ViTri=4;
        else if(strPage.toLowerCase().indexOf("link")==0)
            ViTri=5;
        else if(strPage.toLowerCase().indexOf("contact")==0)
            ViTri=6;
    }
    strImageUrl="Images/MenuBar/Skin/";
    document.frmHomePage.imgHomePage.src=strImageUrl+"HomePage1.gif";		
	document.frmHomePage.imgAbout.src=strImageUrl+"About1.gif";
	document.frmHomePage.imgProduct.src=strImageUrl+"Product1.gif";
	document.frmHomePage.imgService.src=strImageUrl+"Service1.gif";
	document.frmHomePage.imgLink.src=strImageUrl+"Link1.gif";
	document.frmHomePage.imgContact.src=strImageUrl+"Contact1.gif";
	switch(ViTri)
	{
		case 1: document.frmHomePage.imgHomePage.src=strImageUrl+"HomePage2.gif";break;		
		case 2: document.frmHomePage.imgAbout.src=strImageUrl+"About2.gif";break;
		case 3: document.frmHomePage.imgProduct.src=strImageUrl+"Product2.gif";break;
		case 4: document.frmHomePage.imgService.src=strImageUrl+"Service2.gif";break;
		case 5: document.frmHomePage.imgLink.src=strImageUrl+"Link2.gif";break;
		case 6: document.frmHomePage.imgContact.src=strImageUrl+"Contact2.gif";break;		
	}
}
function XuLyHinhAnh(ViTri,ThuTu)
{

    strImageUrl="Images/MenuBar/Skin/";
    document.frmHomePage.imgHomePage.src=strImageUrl+"HomePage1.gif";		
	document.frmHomePage.imgAbout.src=strImageUrl+"About1.gif";
	document.frmHomePage.imgProduct.src=strImageUrl+"Product1.gif";
	document.frmHomePage.imgService.src=strImageUrl+"Service1.gif";
	document.frmHomePage.imgLink.src=strImageUrl+"Link1.gif";
	document.frmHomePage.imgContact.src=strImageUrl+"Contact1.gif";
	switch(ViTri)
	{
		case 1: document.frmHomePage.imgHomePage.src=strImageUrl+"HomePage"+ThuTu+".gif";break;		
		case 2: document.frmHomePage.imgAbout.src=strImageUrl+"About"+ThuTu+".gif";break;
		case 3: document.frmHomePage.imgProduct.src=strImageUrl+"Product"+ThuTu+".gif";break;
		case 4: document.frmHomePage.imgService.src=strImageUrl+"Service"+ThuTu+".gif";break;
		case 5: document.frmHomePage.imgLink.src=strImageUrl+"Link"+ThuTu+".gif";break;
		case 6: document.frmHomePage.imgContact.src=strImageUrl+"Contact"+ThuTu+".gif";break;		
	}
}
ChiSo1=0;
function XuLyLoGo1()
{	
	ChiSo1++;
	if(ChiSo1==26)
		ChiSo1=6;	
	document.frmHomePage.picHinh1.src="images/Logo/LogoCNTT"+ChiSo1+".jpg";
	if(ChiSo1==25)
		iqBody1=setTimeout("XuLyLoGo1()",3000);
	else if(ChiSo1>=10)
		iqBody1=setTimeout("XuLyLoGo1()",250);
	else if(ChiSo1==9)
		iqBody1=setTimeout("XuLyLoGo1()",3000);
	else
		iqBody1=setTimeout("XuLyLoGo1()",1000);
	
}


function btnSave_Click(i)
{
//    var oject= document.getElementById("txtQuantity"+i);    
//    var object=document.getElementById("divCart");   
// 	object.innerHtml = (oject.value);  
    
    var oject= document.getElementById("txtQuantity"+i);
    if(oject.value==0 || oject.value==null)
    {
        alert("Bạn Chưa Nhập Dữ Liệu");
        oject.focus();
    }
    else if(isNaN(oject.value)==true)
    {
        alert("Dữ Liệu Nhập Vào Phải Là Số");
        oject.value="";
        oject.focus();
    }
    else if(oject.value.indexOf('.')>=0)
    {
        alert("Dữ Liệu Nhập Vào Phải Là Số Nguyên");
        oject.value="";
        oject.focus();
    }
    else
        window.location="CartShop.aspx?intIndexUpdate="+i+"&strTextBox="+oject.value;
    
}

function btnSaveNew_Click()
{
//    var oject= document.getElementById("txtQuantity"+i);    
//    var object=document.getElementById("divCart");   
// 	object.innerHtml = (oject.value);  
    
    var oject= document.getElementById("txtQuantityNew");
    if(oject.value==0 || oject.value==null)
    {
        alert("Bạn Chưa Nhập Dữ Liệu");
        oject.focus();
    }
    else if(isNaN(oject.value)==true)
    {
        alert("Dữ Liệu Nhập Vào Phải Là Số");
        oject.value="";
        oject.focus();
    }
    else if(oject.value.indexOf('.')>=0)
    {
        alert("Dữ Liệu Nhập Vào Phải Là Số Nguyên");
        oject.value="";
        oject.focus();
    }
    else
        window.location="CartShop.aspx?intIndexUpdate=-1&strTextBox="+oject.value;
    
}
ChiSo2=0;
function NgayHienHanh()
{
	
	var d = new Date();
	thu=d.getDay();
	switch(thu)
	{
		case 0: Thu="Chủ Nhật"; break;
		case 1: Thu="Thứ Hai"; break;
		case 2: Thu="Thứ Ba"; break;
		case 3: Thu="Thứ Tư"; break;
		case 4: Thu="Thứ Năm"; break;
		case 5: Thu="Thứ Sáu"; break;
		case 6: Thu="Thứ Bảy"; break;		
	}
	ngay=d.getDate();
	thang=d.getMonth()+1;
	nam=d.getFullYear();		
//	ChiSo2++;
	strNgayHT=new String();
	strNgayHT="Hôm Nay: "+Thu+ " Ngày " + ngay +" Tháng "+thang+" Năm "+nam;	
	document.getElementById("spnNgayHeThong").setAttribute("innerText",strNgayHT);
//  document.getElementById("spnNgayHeThong").setAttribute("innerText",strNgayHT.substring(0,ChiSo2));
//    if(ChiSo2<=strNgayHT.length)
//        idNHT=setTimeout("NgayHienHanh()",250);
//    else
//    {
//        ChiSo2=0;       
//        idNHT=setTimeout("NgayHienHanh()",5000);
//    }
    
}
    
function GioHienHanh()
{
	//window.fullscreen="Yes";
	var d = new Date();	
	gio=d.getHours();
	hh=((gio>=12)?" PM":" AM");
	gio=gio % 12;
	if(gio<10)
	    gio="0"+gio;	    
	phut=d.getMinutes();
	if(phut<10)
	    phut="0"+phut;
	giay=d.getSeconds();
	if(giay<10)
	    giay="0"+giay;
    this.document.getElementById("spnGioHeThong").innerText = gio + ":" + phut +":"+giay+" "+ hh;
    
    idGHT=setTimeout("GioHienHanh()",1000);
} 
var a=new Array("box in","box out", "circle in","circle out","wipe up","wipe down","wipe right","wipe left",
"vertical blind","horizon blind","checkerboard across","checkerboard down","random dissolse","split vertical in",
"split vertical out","split horizontal out","strips left down","strips left up","strips right down","strips right up",
"random bars horizontal","random bars vertical","random");
var i=0;
var j=-1;
function Show()
{
	i++;
	j++;
	if(i>7) i=0;
	if(j>23) j=0;
	document.frmHomePage.picHinh1.filters[0].transition=a[j];
	document.frmHomePage.picHinh1.filters[0].apply();
	document.frmHomePage.picHinh1.src="../images/LoGo/LogoCNTT"+i+".gif";
	document.frmHomePage.picHinh1.filters[0].play();
	setTimeout("Show()",100);
}
function getValueTextBox(DivId){
	var oject= document.getElementById(DivId);
 	Session["ValueTxt"]=object.value;
 	
 }
function ShowDiv(DivId){
	var oject= document.getElementById(DivId);
	if(oject!=null)
	{
	
 	    oject.style.visibility= "visible";
 	    
 	    //oject.style.position="fixed";
 	}
 	
 }
 function HideDiv(DivId){
 
	var oject= document.getElementById(DivId);
	if(oject!=null)
	{
 	    oject.style.visibility= "hidden";
 	   
        //oject.style.position="absolute";
	    //oject.style.height=0;	    
 	}
 	
	}
function ShowDiv1(DivId){
    
	var oject= document.getElementById(DivId);
	if(oject!=null)
	{
	
 	    oject.style.visibility= "visible";
 	    oject.style.display="block";
 	    
 	    //oject.style.position="fixed";
 	}
 	
 }
 function ShowAsk(DivId){
    
	var oject= this.document.getElementById(DivId);
	if(oject!=null)
	{
	
 	    oject.style.visibility= "visible";
 	    oject.style.display="block";
 	    
 	    //oject.style.position="fixed";
 	}
 	
 }
 function HideAsk(DivId){
    
	var oject= this.document.getElementById(DivId);
	if(oject!=null)
	{
	
 	    oject.style.visibility= "hidden";
 	    oject.style.display="none";
 	    
 	    //oject.style.position="fixed";
 	}
 	
 }
 function HideDiv1(DivId){
 
	var oject= document.getElementById(DivId);
	if(oject!=null)
	{
 	    oject.style.visibility= "hidden";
	     oject.style.display="none";
	    	    
 	}
 	
	}


//var trangDuAn=0;
//function ShowDuAn(strDuAnCT)
//{                        
//var strShow=new String();
//strShow=strDuAnCT+"#";
//var arrDuAnCT= new Array();
//arrDuAnCT = strShow.split('#');
//trangDuAn++;
//int sotrang=arrDuAnCT.length/3;
//if(3*sotrang!=arrDuAnCT.length)
//sotrang++;
//if(trangDuAn>sotrang)
//trangDuAn=0;
//var strTemp=new String();
//strTemp="<table cellpadding='0' cellspacing='0' style='width:100%'>";
//for(int i=(trangDuAn-1)*3;i<trangDuAn*3;i++)
//{
//str+="<tr><td align='left' valign='middle' style='height:25px'>&nbsp;&nbsp;&nbsp;<img src='controls/images/tenchop.gif' />&nbsp;&nbsp;";
//str+=arrDuAnCT[i]+"</td></tr>";
//}
//str+="</table>";
//divDuAnCity.innerHtml=str;  
//}
     
