// Do nothing
function doNothing(){window.status='';}

// Open popup window
function doOpenLinkToPopupWindow(){
	var url = arguments[0]||'/';
	var width = arguments[1]||400;
	var height = arguments[2]||400;
	var resizable = arguments[3]||'yes';
	var scrollbars = arguments[3]||'yes';
	var left = ((document.body.clientWidth - width) / 2) + window.screenLeft;
	var top = (((document.body.clientHeight - height) / 2)) + window.screenTop;
	window.open(url, '', 'width='+width+',height='+height+',left='+left+',top='+top+',resizable='+resizable+',scrollbars='+scrollbars);
}

// Open banner
function doOpenpapaCMSBanner(id,isGroup){
	if(isGroup==1)
	{
		eval("var current=crt" + id);
		eval("var itemID=bnrID" + id + current);
	}
	else
		var itemID=id;
	frmWebPlusHiddenForm.txtID.value = itemID;
	frmWebPlusHiddenForm.txtLocation.value = location.href;
	frmWebPlusHiddenForm.action = '../i-web/banner.asp?subobject=item&action=open';
	frmWebPlusHiddenForm.submit();
}

// Change banner (for web banner or special banner)
function doChangeWebPlusBanner(id,max){
	eval("var current=crt" + id);
	if(current<max)
	{
		eval("crt" + id + "++");
		current++;
	}
	else
	{
		eval("crt" + id + "=0");
		current=0;
	}	
	eval("var nextImg = bnr" + id + current);
	document.images['imgCMS'+id].src = nextImg.src;
}

// Open web link
function doOpenWebPlusLink(url){
	iwebhidden.txtLocation.value = location.href;
	iwebhidden.action = url;
	iwebhidden.submit();
}

// Information for updating hits counter
function doGetWebPlusCounterInfo(){
	// Browser
	var browser = '';
	if(navigator.appName=='Netscape')
		browser = 'NS';
	if(navigator.appName=='Microsoft Internet Explorer')
		browser = 'MSIE';
	if(navigator.appVersion.indexOf('MSIE 3')>0)
		browser = 'MSIE';
	// Screen resolution
	var screenWidth = screen.width;
	var screenHeight = screen.height; 
	// Color depth
	var colorDepth = 256;
	if (navigator.appName != 'Netscape')
		colorDepth = screen.colorDepth;
	else 
		colorDepth = screen.pixelDepth;
	// Referer
	var referer = '' + escape(document.referrer);
	// Counter URL
	return '&w=' + screenWidth + '&h=' + screenHeight + '&c=' + colorDepth + '&b=' + browser + '&r=' + referer
}

// Return the string determines full date of client (International)
function getFullDate(){
	var now = new Date();
	var month = "";
	var day = "";
	var first_date_num="";

  if (now.getDate() < 10)
		first_date_num="0";
	else
		first_date_num="";
			
	switch (now.getDay()){
		case 0: day="Sunday";break;
		case 1: day="Monday";break;
		case 2: day="Tuesday";break;
		case 3: day="Wednesday";break;
		case 4: day="Thursday";break;
		case 5: day="Friday";break;
		case 6: day="Saturday";break;
	}
	
	switch (now.getMonth()){
		case  0: month="January";break;
		case  1: month="February";break;
		case  2: month="March";break;
		case  3: month="April";break;
		case  4: month="May";break;
		case  5: month="June";break;
		case  6: month="July";break;
		case  7: month="August";break;
		case  8: month="September";break;
		case  9: month="October";break;
		case 10: month="November";break;
		case 11: month="December";break;
	}
	
	return day + ", " + month + " " + first_date_num + now.getDate() + ", " + now.getFullYear();
}

// Return the string determines full date of client (Vietnamese)
function getFullDateInVietnamese(){
	var now = new Date();
	var month = "";
	var day = "";
	var first_date_num="";

  if (now.getDate() < 10)
  	first_date_num="0";
	else
		first_date_num="";
			
	switch (now.getDay()){
		case 0: day="Ch&#7911; nh&#7853;t";break;
		case 1: day="Th&#7913; hai";break;
		case 2: day="Th&#7913; ba";break;
		case 3: day="Th&#7913; t&#432;";break;
		case 4: day="Th&#7913; n&#259;m";break;
		case 5: day="Th&#7913; s&#225;u";break;
		case 6: day="Th&#7913; b&#7843;y";break;
	}
	
	return day + " ng&#224;y " + first_date_num + now.getDate() + " th&#225;ng " + (now.getMonth()+1) + " n&#259;m " + now.getFullYear();
}

// Return the string determines full date & time of client (GMT)
function getFullDateTimeInGMT(){
	var now = new Date();
	var month = "";
	var day = "";
	var date = now.getDate();

	if ((date==1)||(date==21)||(date==31)) {date = date + "st"};
	if ((date==2)||(date==22)) {date = date + "nd"};
	if ((date==3)||(date==23)) {date = date + "rd"};
			
	switch (now.getDay()){
		case 0: day="Sunday";break;
		case 1: day="Monday";break;
		case 2: day="Tuesday";break;
		case 3: day="Wednesday";break;
		case 4: day="Thursday";break;
		case 5: day="Friday";break;
		case 6: day="Saturday";break;
	}
	
	switch (now.getMonth()){
		case  0: month="January";break;
		case  1: month="February";break;
		case  2: month="March";break;
		case  3: month="April";break;
		case  4: month="May";break;
		case  5: month="June";break;
		case  6: month="July";break;
		case  7: month="August";break;
		case  8: month="September";break;
		case  9: month="October";break;
		case 10: month="November";break;
		case 11: month="December";break;
	}

	var time = new String(now.getUTCHours());
	if (time.length < 2){ time = "0"+ time};
		
	var minute = new String(now.getMinutes());
	if (minute.length < 2) {minute = "0"+ minute};
	
	time = time  + ":" + minute + " (GMT)"; 
	
	return day + ", " + date + " " + month + " " + now.getFullYear() + " " + time;
}


var isTab="1";
function showTab(_tabID)
{
	if (isTab!='')
	{
		eval("document.all.Tab"+isTab+".style.display='none'");
		eval("document.all.Tab"+_tabID+".style.display=''");
		eval("document.all.col"+isTab+".className='productTab'");
		eval("document.all.col"+_tabID+".className='productTabSelected'");
		if (_tabID=='1')
		{
			eval("document.all.tab_next"+isTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next_"+isTab+".innerHTML=''");
			eval("document.all.tab_next_.innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
		}
		else
		{
			eval("document.all.tab_next_.innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next_"+isTab+".innerHTML=''");
			eval("document.all.tab_next"+isTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
		}
		
		isTab = _tabID;
	}
}

var isPTab="1";
function showPTab(_tabID, SourceID)
{
	try
	{
		if (isPTab!='')
		{
			eval("document.all.pTab"+isPTab+".style.display='none'");
			eval("document.all.pTab"+_tabID+".style.display=''");
			eval("document.all.pcol"+isPTab+".className='productTab'");
			eval("document.all.pcol"+_tabID+".className='productTabSelected'");
			if (_tabID=='1')
			{
				eval("document.all.ptab_next"+isPTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
				eval("document.all.ptab_next_"+isPTab+".innerHTML=''");
				eval("document.all.ptab_next_.innerHTML='<img src=/images/default/slashOn.gif>'");
				eval("document.all.ptab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
				eval("document.all.ptab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			}
			else
			{
				eval("document.all.ptab_next_.innerHTML='<img src=/images/default/slashOff.gif>'");
				eval("document.all.ptab_next_"+isPTab+".innerHTML=''");
				eval("document.all.ptab_next"+isPTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
				eval("document.all.ptab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
				eval("document.all.ptab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			}
			
			isPTab = _tabID;
			if (SourceID!='')
			{
				switchpanel(SourceID, 'Ajax'+_tabID);
			}
		}
	}
	catch(error)
	{
		document.title = 'Exception: ' + error.name + error.message;
	}
}

function showArticleTab(_tabID)
{
	try
	{
	if (isTab!='')
	{
		eval("document.all.Tab"+isTab+".style.display='none'");
		eval("document.all.Tab"+_tabID+".style.display=''");
		eval("document.all.col"+isTab+".className='ArticleTab'");
		eval("document.all.col"+_tabID+".className='ArticleTabSelected'");
		if (_tabID=='1')
		{
			eval("document.all.tab_next"+isTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next_"+isTab+".innerHTML=''");
			eval("document.all.tab_next_.innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
		}
		else
		{
			eval("document.all.tab_next_.innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next_"+isTab+".innerHTML=''");
			eval("document.all.tab_next"+isTab+".innerHTML='<img src=/images/default/slashOff.gif>'");
			eval("document.all.tab_next"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
			eval("document.all.tab_next_"+_tabID+".innerHTML='<img src=/images/default/slashOn.gif>'");
		}
		
		isTab = _tabID;
	}
	}
	catch(error)
	{
		document.title = error.message;
	}
}


var subCategoryId = '';
function doSelectDevice(id, scroll)
{
	try
	{
		if (subCategoryId) eval("document.all.subcategory"+subCategoryId+".style.visibility='hidden'");
		eval("document.all.subcategory"+id+".style.visibility='visible'");
		if (scroll) eval("document.all.subcategory"+id+".style.overflowY='scroll'");
		subCategoryId = id;
	}
	catch(error)
	{
		okie=false;
	}
}
function doHideDevice()
{
	try
	{
		if (subCategoryId) eval("document.all.subcategory"+subCategoryId+".style.visibility='hidden'");
	}
	catch(error)
	{
		return false;
	}
}

var specid='';
function setCatalogue(id, catid, value)
{
	try
	{
	if (specid) eval("document.all.spec"+specid+".style.display='none'");
	eval("document.all.spec"+id+".style.display=''");
	eval("document.all.notfound.innerHTML=''");
	eval("document.all.SearchCatalogue.innerHTML='"+value+"'");
	document.frmSearch.sCategory.checked=true;
	document.frmSearch.sCategoryID.value=catid;
	specid = id;
	doHideDevice();
	}
	catch(error)
	{
		return false;
	}
}

function setSpecification(id, value)
{
	try
	{
	document.frmSearch.sSpecification.checked=true;
	eval("document.all.SearchSpec.innerHTML='"+value+"'");
	document.frmSearch.sSpecificationID.value=id;
	doHideDevice();
	}
	catch(error)
	{
		return false;
	}
}
var CatalogueID='';
function showCatalogueLevel2(id)
{
	if (CatalogueID!='')
	{
		eval("document.all."+CatalogueID+".style.display='none'");
	}
	eval("document.all."+id+".style.display=''");
	CatalogueID = id;
}
var ProductID = ''
function showPOverView(id)
{
	if (ProductID!='')
	{
		eval("document.all."+ProductID+".style.visibility='hidden'");
	}
	eval("document.all."+id+".style.visibility='visible'");
	ProductID = id;
}
function  hidePoverview()
{
	if (ProductID!='')
	{
		eval("document.all."+ProductID+".style.visibility='hidden'");
	}
}

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

//Fade for Thumbnail
doFadeObjects = new Object();

doFadeTimers = new Object();



function doFade(object, destOp, rate, delta){

if (!document.all)

return

    if (object != "[object]"){

        setTimeout("doFade("+object+","+destOp+","+rate+","+delta+")",0);

        return;

    }



    clearTimeout(doFadeTimers[object.sourceIndex]);



    diff = destOp-object.filters.alpha.opacity;

    direction = 1;

    if (object.filters.alpha.opacity > destOp){

        direction = -1;

    }

    delta=Math.min(direction*diff,delta);

    object.filters.alpha.opacity+=direction*delta;



    if (object.filters.alpha.opacity != destOp){

        doFadeObjects[object.sourceIndex]=object;

        doFadeTimers[object.sourceIndex]=setTimeout("doFade(doFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);

    }

}


