﻿// JScript File
 function OpenWindow(Url) {     
    window.open(Url);        
   } 
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 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  href="App_Themes/Default1/default.css" rel="stylesheet" type="text/css"/>  ');
     w.document.writeln('<style>.ArticleDetailDesc,.Footer_Text_Link{color:#000;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>');
     w.document.writeln('<img src ="Images/upload/Banner.jpg" alt="" style="border:0;" align="asbmiddle"/>');
     w.document.writeln('</td>');
     w.document.writeln('</tr>');
     w.document.writeln('<tr>');
     w.document.writeln('<td valign="top" >');     
     
     w.document.writeln('<a onclick="javascript:location.reload(true);window.print();" style=" cursor:hand;color:#000;font-size:12px;" class="Paging">');
     w.document.writeln('<img src="App_Themes/Default1/Images/icon_print.jpg" style="vertical-align:middle;"/>'); 
     w.document.writeln('Print this page');
     w.document.writeln('</a></td>');     
     w.document.writeln('</tr>');
     w.document.writeln('<tr>');
     w.document.writeln('<td valign="top" >');     
     w.document.writeln(document.getElementById('Content').innerHTML);          
     w.document.writeln('</td>');
     w.document.writeln('</tr>');
     w.document.writeln('<tr>');
     w.document.writeln('<td align="center" style="padding-top:20px;color:#000! important;font-size:12px! important;font-family:tahoma">');     
     w.document.writeln(document.getElementById('BoxFooter').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 PrintProduct()
    {  
	   	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  href="default.css" rel="stylesheet" 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('<img src ="images/logo.gif" alt="" style="border:0;" align="asbmiddle"/>');
	    w.document.writeln('</td>');
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td colspan="2" valign="top" >');	    
	    
	    w.document.writeln('<a onclick="javascript:location.reload(true);window.print();" style=" cursor:hand" class="Paging">');
	    w.document.writeln('<img src="Images/print.gif" />');	
	    w.document.writeln('  Print this page');
	    w.document.writeln('</a></td>');	    
	    w.document.writeln('</tr>');
	    w.document.writeln('<tr>');
	    w.document.writeln('<td valign="top" width="40%" >');	    
	    w.document.writeln(document.getElementById('Content').outerHTML);	    	    
	    w.document.writeln('</td>');
	    w.document.writeln('<td valign="top" >');	    
	    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" style="padding-top:20px;">');	    
	    w.document.writeln(document.getElementById('BoxFooter').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; 
    }
    function FitPic(w) {         
       var i=0;       
       if (navigator.appName == 'Netscape') 
         i=-10;       
       if (w.document.images[0]) w.window.resizeTo(w.document.images[0].width, w.document.images[0].height + 50 - i);      w.self.focus();
       alert('ok');
     }
   function PopupPic(sPicURL, w, h) {         
   	    ww=open('_blank','popupWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + w + ',height=' + h + ',screenX=150,screenY=150,top=150,left=150');   	    
	    ww.document.writeln('<html>');
	    ww.document.writeln('<head>');
	    ww.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');	    
	    ww.document.writeln('</head>');
	    ww.document.writeln('<body topmargin=3 leftmargin=0 marginheight=3 marginwidth=0 onclick="javascript:window.close();">');
	    ww.document.writeln('<img src ="'+sPicURL+'" width="'+w+'" height="'+h+'" alt="" style="border:0;" align="asbmiddle" />');
	    ww.document.writeln('</body>');
	    ww.document.writeln('</html>');	    
	    ww.document.title = document.title;	   
	    return false; 
   } 
   function CleanFrom() { 
    document.getElementById("form1").reset();
   }   
   
  

function OpenWindow(url, vHeight, vWidth)
{
   var winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,';
   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();               
}     

  
PositionX = 200;
PositionY = 10;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// 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=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,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><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;');
        writeln('height=100-(document.body.clientHeight-document.images[0].height);');//writeln('height=100-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
        writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
        if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close();" onclick="self.close();">');
        writeln('<img name="George" src='+imageURL+' style="display:block" onclick="javascript:self.close();"></body></html>');
        close();		
  }
}
/*========================================Slide Show=====================================*/

var iTransaction = 1
	var t = -1
	var w = 0
	var h = 0
   	function loadImage(arrImg)
	{
        t = t + 1;   

		if(t >	arrImg.length - 1)
		{
			t = 0;			
		}		
		
		
		
		var arrTitle = Title.split(",");
		showImage(arrImg[t], arrTitle[t]);
	}
    function showImage(linkImage, title)
    {
        var TransitionEffect = document.getElementById('VNVN_17_UC_SlideShow_h_ImageStyleEffect');
        var Img_Link = document.getElementById( 'Img_ID' );
        var Title_Link = document.getElementById( 'Title_ID' );
        
        if((w>0) && (h>0))
        {
            Img_Link.width = w;
            Img_Link.height = h;
        }
        
        var browserName = navigator.appName;
        //alert(browserName);
        if(browserName == 'Microsoft Internet Explorer')
        {
            //alert(browserName);
		    Img_Link.filters.item(0).apply();        
            //--------------------------------------------            
            if(TransitionEffect.value == 0)
            {
                iTransaction = Math.round(Math.random() * (23 - 1)) + 1 ;
                Img_Link.filters.revealTrans.transition = iTransaction; 
            }
            else
            {
                Img_Link.filters.revealTrans.transition = TransitionEffect.value; 
            }    
            
            //---------------------------------------------                
            Img_Link.filters.item(0).play();
        }
        //Filter();
        Img_Link.src = linkImage.replace("~/","./");
        Title_Link.innerHTML="Dung";//title;
        alert(Title_Link.innerHTML);
        
    }
	
	function StopTimer()
	{
		window.clearInterval(timer);
	}
	function setSize()
	{
	}    
   
    function getToArray(str)
    {
		mycars = str.split(",");	
	}
	function getarrImage()
	{
	    var hf = document.getElementById('VNVN_17_UC_SlideShow_h_arrImage');
	    getToArray(hf.value);
	    loadImage(mycars);
	}
	var mycars = new Array();
	var times=3000;
	function StartTimer(time, imagewidth, imageHeight)
	{
	    //Khong dung slide show
		//timer = window.setInterval( getarrImage , time );
		if((imagewidth > 0) && (imageHeight>0))
		{
		    w = imagewidth;
		    h = imageHeight;
		}		
		times=time;
	}	         
	function go() 
	{ 
        Egg1.filters[0].Apply();

        if (Egg1.style.visibility == "visible") 
        { 
        Egg1.style.visibility = "hidden"; 
        Egg1.filters.revealTrans.transition=12; 
        } 
        else 
        { 
        Egg1.style.visibility = "visible"; 
        Egg1.filters[0].transition=12; 
        } 
        Egg1.filters[0].Play(); 
    }   
    function Bt_First_Click()
    {
        var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById('VNVN_17_UC_SlideShow_h_arrImage');
	    getToArray(hf.value);
	    t=0;          
        Img_ID.src = mycars[t].toString().replace("~/","./");                 
        Display(t);
    }  
    function Bt_Back_Click()
    {
        var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById('VNVN_17_UC_SlideShow_h_arrImage');
	    getToArray(hf.value);
        if ( t > 0 )
            t = t - 1;
        else
            t=mycars.length-1;     
        Img_ID.src = mycars[t].toString().replace("~/","./");                   
        Display(t);
    }
    function Bt_Next_Click()
    { 
	     var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById('VNVN_17_UC_SlideShow_h_arrImage');
	    getToArray(hf.value);
        if ( t <mycars.length )
            t = t + 1;
        else
            t=0;     
        Img_ID.src = mycars[t].toString().replace("~/","./");
        Display(t);
    }
     function Bt_Last_Click()
    {
        var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById('VNVN_17_UC_SlideShow_h_arrImage');
	    getToArray(hf.value);          
	    t=mycars.length-1;
        Img_ID.src = mycars[t].toString().replace("~/","./");             
        Display(t);
    }  
    function Display(t)
    {        
	    var hdnTitle = document.getElementById('VNVN_17_UC_SlideShow_h_arrTitle');
		var Title=hdnTitle.value;           
		var Title_ID = document.getElementById('Title_ID');  
		Title_ID.innerHTML= Title.split(",")[t].toString();     		
    }  
    
    function Clear_Form()
	{	    
	    document.getElementById("form1").reset();
	}
    function Counter(field, countfield, maxlimit) 
    {           
        //alert (maxlimit);
        if (field.value.length > maxlimit)	{	            
            field.value = field.value.substring(0, maxlimit);
        }            
        else { 
            countfield.value = maxlimit - field.value.length;
        }     
    }



// FLoating Advertise

var slideTime = 700;
var _timout_for_stop_menu = 25; // == not Use
var floatAtBottom = false;
function xMoveTo(e,iX,iY) {
  xLeft(e,iX);
  xTop(e,iY);
}
function xLeft(e,iX) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xDef(e.style.left) && typeof(e.style.left)=="string") {
    if(arguments.length>1) e.style.left=iX+"px";
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(arguments.length>1) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  else if(xDef(e.left)) {
    if(arguments.length>1) e.left=iX;
    else iX=e.left;
  }
  return iX;
}

function xGetElementById(e) {
  if(typeof(e)!="string") return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else if(document.layers) e=xLayer(e);
  else e=null;
  return e;
}
function xTop(e,iY) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xDef(e.style.top) && typeof(e.style.top)=="string") {
    if(arguments.length>1) e.style.top=iY+"px";
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(arguments.length>1) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  else if(xDef(e.top)) {
    if(arguments.length>1) e.top=iY;
    else iY=e.top;
  }
  return iY;
}
function xResizeEvent() { // window resize event simulation
  setTimeout("xResizeEvent()", 250);
  var cw = xClientWidth(), ch = xClientHeight();
  if (window.xPCW != cw || window.xPCH != ch) { window.xPCW = cw; window.xPCH = ch; window.xREL(); }
}
function xScrollEvent() { // window scroll event simulation
  setTimeout("xScrollEvent()", 250);
  var sl = xScrollLeft(), st = xScrollTop();
  if (window.xPSL != sl || window.xPST != st) { window.xPSL = sl; window.xPST = st; window.xSEL(); }
}
//Event
function xAddEventListener(e,eventType,eventListener,useCapture) {
  if(!(e=xGetElementById(e))) return;
  eventType=eventType.toLowerCase();
  if((!xIE4Up && !xOp7) && e==window) {
    if(eventType=='resize') { window.xPCW=xClientWidth(); window.xPCH=xClientHeight(); window.xREL=eventListener; xResizeEvent(); return; }
    if(eventType=='scroll') { window.xPSL=xScrollLeft(); window.xPST=xScrollTop(); window.xSEL=eventListener; xScrollEvent(); return; }
  }
  var eh="e.on"+eventType+"=eventListener";
  if(e.addEventListener) e.addEventListener(eventType,eventListener,useCapture);
  else if(e.attachEvent) e.attachEvent("on"+eventType,eventListener);
  else if(e.captureEvents) {
    if(useCapture||(eventType.indexOf('mousemove')!=-1)) { e.captureEvents(eval("Event."+eventType.toUpperCase())); }
    eval(eh);
  }
  else eval(eh);
}
//window
function pepsi_floating_init()
{
	//xMoveTo('floating_banner_right', 900 - (1024-screen.width), 0);
	//xMoveTo('floating_banner_left',  (1024-screen.width), 0);

	//winOnResize(); // set initial position
	//xAddEventListener(window, 'resize', winOnResize, false);
	//xAddEventListener(window, 'scroll', winOnScroll, false);	
}

function winOnResize() {
	checkScreenWidth();
	winOnScroll(); // initial slide
}
function winOnScroll() {
  var y = xScrollTop();
  if (floatAtBottom) {
    y += xClientHeight() - xHeight('floating_banner_left');
  }  
  
  xSlideTo('floating_banner_left', 0 , y, slideTime);
  xSlideTo('floating_banner_right', 0, y, slideTime);
}
	
function checkScreenWidth()
{
	if( screen.width <= 800 )
	{
		document.getElementById('floating_banner_left').style.display = 'none';
		document.getElementById('floating_banner_right').style.display = 'none';
	}
}
function xScrollLeft() {
  var offset=0;
  if(xDef(window.pageXOffset)) offset=window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft;
  else if(document.body && xDef(document.body.scrollLeft)) offset=document.body.scrollLeft;
  return offset;
}
function xScrollTop() {    
  var offset=0;
  if(xDef(window.pageYOffset)) offset=window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
  else if(document.body && xDef(document.body.scrollTop)) offset=document.body.scrollTop;
  return offset;
}

function xSlideTo(e,x,y,uTime) {
  if (!(e=xGetElementById(e))) return;
  if (!e.timeout){
  	e.timeout = _timout_for_stop_menu;
  }	 
  e.xTarget = x; e.yTarget = y; e.slideTime = uTime; e.stop = false;
  e.yA = e.yTarget - xTop(e); e.xA = e.xTarget - xLeft(e); // A = distance
  e.B = Math.PI / (2 * e.slideTime); // B = period
  e.yD = xTop(e); e.xD = xLeft(e); // D = initial position
  var d = new Date(); e.C = d.getTime();
  if (!e.moving) xSlide(e);
}  
 
function xSlide(e) {
  if (!(e=xGetElementById(e))) return;
  var now, s, t, newY, newX;
  now = new Date();
  t = now.getTime() - e.C;
  if (e.stop) { e.moving = false; }
  else if (t < e.slideTime) {
    setTimeout("xSlide('"+e.id+"')", e.timeout);
    s = Math.sin(e.B * t);
    newX = Math.round(e.xA * s + e.xD);
    newY = Math.round(e.yA * s + e.yD);
    xMoveTo(e, newX, newY);
    e.moving = true;    
  }  
  else {
    xMoveTo(e, e.xTarget, e.yTarget);
    e.moving = false;
    
  }  
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=="" || typeof(arguments[i])=="undefined") return false;}
  return true;
}
function xClientWidth() {
  var w=0;
  if(xOp5or6) w=window.innerWidth;
  else if(xIE4Up && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
function xClientHeight() {
  var h=0;
  if(xOp5or6) h=window.innerHeight;
  else if(xIE4Up && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}
var xVersion='3.8',xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if(document.layers) xNN4=true;
else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}


//Search Google
function Google_Search()
{
    var tb_Content = document.getElementById('tb_Search_Content');
    var rdo_SiteSearch = document.getElementsByName('SiteSearch');
    var s_SiteSearch,s_Domain;
    var i;
    
    for( i = 0; i < rdo_SiteSearch.length; i++ )
    {
        if ( rdo_SiteSearch[i].checked )
        {
            s_SiteSearch = rdo_SiteSearch[i].value;                
            break;
        }
    }       
    
    s_Domain = "www.hopluu.net";
    if ( s_SiteSearch == "www")        
        s_SiteSearch = "";
    
    window.open('http://www.google.com/search?ie=utf-8&oe=utf-8&vnType=0&domains=' + s_Domain + '&sitesearch' + '=' + s_SiteSearch + '&q=' + tb_Content.value  );
}

var ListAdvertise = {};

function ChangeBannerAdvertise(id, time)
{
	var arr		= ListAdvertise[id];
	var imgObj	= document.getElementById(id);
	
	if (arr.length > 0 && imgObj)
	{
		var index = imgObj.curIndex;		
		if (!index || index >= arr.length) index = 0;
		
		var curImg = arr[index++];
		if(curImg[0].indexOf('<')<0)
		   imgObj.innerHTML="<img src='"+curImg[0]+ "' alt='"+ curImg[2] +"'>"; 
		else
		    imgObj.innerHTML=curImg[0];	
		imgObj.lnk	= curImg[1];
		imgObj.curIndex			= index;
		setTimeout("ChangeBannerAdvertise('" + id + "', " + time + ")", time);
	}
}

function OnAdvertiseClick(img, catId, flag)
{
//alert('VNVN_19_CountViewed.aspx?Url=' + img.lnk + '&CatID=' + catId + '&flag=' + flag)
	if (img.lnk)
		OpenWindow('VNVN_Web/VNVN_19_CountViewed.aspx?CatID=' + catId + '&flag=' + flag+'&Url=' + img.lnk );
}

function InitPaging(id)
{
 var totalPage = parseInt(document.getElementById(id + '_Lbl_TotalPage').innerHTML);
 
 var button = new Array('First', 'Back', 'Next', 'Last', 'Go');
 for (var i = 0 ; i < button.length ; i++)
 {
  var obj  = document.getElementById(id + '_Btn_' + button[i]);
  if (obj != null)
  {
   obj.ctrID = id;
   obj.cmd  = button[i];
   obj.onclick = PagingChange;
  }
 }
 var obj   = document.getElementById(id + '_Ddl_ItemPerPage');
 if (obj)
 {
 obj.ctrID  = id;
 obj.cmd   = "Go";
 obj.onchange = PagingChange;
 }
}
function PagingChange()
{
 var totalPage = parseInt(document.getElementById(this.ctrID + '_Lbl_TotalPage').innerHTML);
 var curPage  = 1;
 var savePage = 1;
 try{curPage = savePage = parseInt(document.getElementById(this.ctrID + '_Tbx_Page').value);
 }catch(e){return false;}
 var pageSize = 0;
 try{pageSize = parseInt(document.getElementById(this.ctrID + '_Ddl_ItemPerPage').value);
 }catch(e){pageSize = 15;}
 switch (this.cmd)
 {
  case 'First':
   if (curPage == 1)
    return false;
   curPage = 1;
   break;
  case 'Back':
   curPage --;
   break;
  case 'Next':
   curPage ++;
   break;
  case 'Last':
   if (curPage == totalPage)
    return false;
   curPage = totalPage;
   break;
  case 'Go':
   break;
 }
 if (curPage < 1 || curPage > totalPage)
 {
  document.getElementById(this.ctrID + '_Tbx_Page').value = savePage;
  return false;
 }
 var query = getQueryParams();
 query["Page"] = curPage;
 query["psize"]= pageSize;
 location.href = "?" + toQueryString(query);
 return false;
}

function getQueryParams()
{
 var query = {};
 var url  = location.href;
 var index = url.indexOf("?");
 if (index != -1)
  query = toQueryParams(url.substr(index + 1));
 return query
}

function toQueryParams(str) 
{
    str = str.replace(/^\s+/, '').replace(/\s+$/, '');   
    var match = str.match(/([^?#]*)(#.*)?$/);
    if (!match) return {};
 
 var arr = match[1].split('&');
 var hash = {};
 for (var i = 0 ; i < arr.length ; i++)
 {   
  var pair = arr[i];   
  if ((pair = pair.split('='))[0]) 
  {
   var key = decodeURIComponent(pair.shift());
   var value = pair.length > 1 ? pair.join('=') : pair[0];
   if (value != undefined) value = decodeURIComponent(value);
   hash[key] = value;
        }
 }
 return hash;
}

function toQueryString(hash)
{
 var parts = [];
 for (var key in hash)
 {
  var value = hash[key];
  if (value == null) 
   continue;
  key = encodeURIComponent(key);
  parts.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
 }
 return parts.join('&');
}


function googleSearch()
{
	var f = document.getElementById('SearchForm');
	
	var s_action = f.action;
	var s_target = f.target;
	
	f.action = "http://www.google.com/custom";
	f.target = "_top";
	f.method = "get";
	f.submit();
	f.action = s_action;
	f.target = s_target;
}




/*========================================Slide Show=====================================*/

var iTransaction = 1
	var t = -1
	var w = 0
	var h = 0
   	function loadImage(arrImg,arrTitle)
	{
        t = t + 1;   

		if(t >	arrImg.length - 1)
		{
			t = 0;			
		}		
		//var arrTitle = Title.split(",");
		showImage(arrImg[t], arrTitle[t]);
	}
    function showImage(linkImage, title)
    {
        var TransitionEffect = document.getElementById('SlideShow1_h_ImageStyleEffect');
        var Img_Link = document.getElementById( 'Img_ID' );
        var Title_Link = document.getElementById( 'Title_ID' );
        
        if((w>0) && (h>0))
        {
            Img_Link.width = w;
            Img_Link.height = h;
        }
        
        var browserName = navigator.appName;
        //alert(browserName);
        if(browserName == 'Microsoft Internet Explorer')
        {
            //alert(browserName);
		    Img_Link.filters.item(0).apply();        
            //--------------------------------------------            
            if(TransitionEffect.value == 0)
            {
                iTransaction = Math.round(Math.random() * (23 - 1)) + 1 ;
                Img_Link.filters.revealTrans.transition = iTransaction; 
            }
            else
            {
                Img_Link.filters.revealTrans.transition = TransitionEffect.value; 
            }    
            
            //---------------------------------------------                
            Img_Link.filters.item(0).play();
        }
        //Filter();
        Img_Link.src = linkImage.replace("~/","./");
        Title_Link.innerHTML=title;
        //alert(Title_Link.innerHTML);
        
    }
	
	function StopTimer()
	{
		window.clearInterval(timer);
		document.getElementById('Img2').style.display='none';
		document.getElementById('Img1').style.display='';
	}
	
	function setSize()
	{
	}    
   
    function getToArray(str,strTitle)
    {
		mycars = str.split(",");	
		mytitle= strTitle.split(",");	
	}
	function getarrImage(ID)
	{	
	//alert(ID);
	    var hf = document.getElementById(ID+'_h_arrImage');
	    var hf_Title = document.getElementById(ID+'_h_arrTitle');
	    getToArray(hf.value,hf_Title.value);
	    loadImage(mycars,mytitle);
	}
	var mycars = new Array();
	var times=500;
	function StartTimer(time, imagewidth, imageHeight,ID)
	{	 
	    //Khong dung slide show
		timer = window.setInterval('getarrImage(\"'+ID+'\")', time );
		if((imagewidth > 0) && (imageHeight>0))
		{
		    w = imagewidth;
		    h = imageHeight;
		}		
		times=time;
	}	         
	function go() 
	{ 
        Egg1.filters[0].Apply();

        if (Egg1.style.visibility == "visible") 
        { 
        Egg1.style.visibility = "hidden"; 
        Egg1.filters.revealTrans.transition=12; 
        } 
        else 
        { 
        Egg1.style.visibility = "visible"; 
        Egg1.filters[0].transition=12; 
        } 
        Egg1.filters[0].Play(); 
    }   
    function Bt_First_Click(ID)
    {
        var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById(ID+'_h_arrImage');
        var hf_Title = document.getElementById(ID+'_h_arrTitle');
	    getToArray(hf.value,hf_Title.value);
	    t=0;          
        Img_ID.src = mycars[t].toString().replace("~/","./");                 
        Display(t,ID);
    }  
    function Bt_Back_Click(ID)
    {
        var Img_ID = document.getElementById('Img_ID');        
        var hf = document.getElementById( ID+'_h_arrImage');
        var hf_Title = document.getElementById(ID+'_h_arrTitle');
	    getToArray(hf.value,hf_Title.value);
        if ( t > 0 )
            t = t - 1;
        else
            t=mycars.length-1;     
        Img_ID.src = mycars[t].toString().replace("~/","./");                   
        Display(t,ID);
    }
    function Bt_Next_Click(ID)
    { 
	    var Img_ID = document.getElementById('Img_ID');        	    
        var hf = document.getElementById(ID+'_h_arrImage');
        var hf_Title = document.getElementById(ID+'_h_arrTitle');
	    getToArray(hf.value,hf_Title.value);
	    if(t<0)    
	        t=0;
        if ( t<mycars.length-1 )
        {
            t = t + 1;            
        }   
        else
            t=0;     
        Img_ID.src = mycars[t].toString().replace("~/","./");
        Display(t,ID);
    }
function Bt_Last_Click(ID)
{
    var Img_ID = document.getElementById('Img_ID');        
    var hf = document.getElementById(ID+'_h_arrImage');
    var hf_Title = document.getElementById(ID+'_h_arrTitle');
    getToArray(hf.value,hf_Title.value);
    t=mycars.length-1;
    Img_ID.src = mycars[t].toString().replace("~/","./");             
    Display(t,ID);
}  

function Display(t,ID)
{        
    var hdnTitle = document.getElementById(ID+'_h_arrTitle');
	var Title=hdnTitle.value;           
	var Title_ID = document.getElementById('Title_ID');  
	Title_ID.innerHTML= Title.split(",")[t].toString();     		
}  
    
function showPlayer(id, url)
{
	var div = document.getElementById("BasicAudioMediaControl");
	if (div && div.parentNode)
	{
		div.parentNode.removeChild(div);
		var audio_div = document.getElementById('audio_flash_' + id);
		if (audio_div)
			audio_div.appendChild(div);
		BasicAudioMediaControl.changeUrl(url);
	}
}

var saveDocMove = null;
var tooltipIsShow = false;
var tooltipTimer = null;

function showToolTip(e, briefDiv)
{
	if (!e) e = window.event;
	var div = document.getElementById(briefDiv);
	if (!div || div.innerHTML == "")
		return;
		
	var tooltip = document.getElementById('ToolTipContainer');
	if (tooltipIsShow)
	{
		document.onmousemove	= saveDocMove;
		saveDocMove				= null;
		_hideToolTip();
	}
	if (tooltip)
	{
		tooltip.onmouseover = function(){window.clearTimeout(tooltipTimer);}
		tooltip.onmouseout	= hideToolTip;

		tooltipIsShow			= true;
		tooltip.innerHTML		= div.innerHTML;
		tooltip.style.display	= '';
		tooltip.style.height	= "auto";
		tooltip.scrollTop		= 0;
		if (tooltip.offsetHeight > 400)
		{
			tooltip.style.height	= "400px";
			tooltip.style.overflow = "auto";
		}
		
		toolTipMove(e);
		
		saveDocMove = document.onmousemove;
		document.onmousemove = toolTipMove;
	}
}

function toolTipMove(event)
{
	if (!event) event = window.event;
	
	var tooltip = document.getElementById('ToolTipContainer');
	var doc = document.documentElement;
	var curX = event.clientX;
	var curY = event.clientY;
	
	var winwidth	= doc.clientWidth;
	var winheight	= doc.clientHeight;
	
	var rightedge	= curX + tooltip.offsetWidth + 10;
	var bottomedge	= curY + tooltip.offsetHeight + 10;
	
	if (rightedge > winwidth)
		curX -= tooltip.offsetWidth + 20;
	if (bottomedge > winheight)
		curY -= tooltip.offsetHeight + 20;

	tooltip.style.top = curY + doc.scrollTop + 10 + "px";
	tooltip.style.left = curX + doc.scrollLeft + 10 + "px";
}

function hideToolTip()
{
	if (tooltipIsShow)
	{
		document.onmousemove	= saveDocMove;
		saveDocMove				= null;
		tooltipTimer			= window.setTimeout(_hideToolTip, 200);
	}
}

function _hideToolTip()
{
	window.clearTimeout(tooltipTimer);
	if (tooltipIsShow)
	{
		tooltipIsShow = false;		
		var tooltip = document.getElementById('ToolTipContainer');
		if (tooltip) tooltip.style.display = 'none';
	}
}

