var zoomRate = 20;
var maxRate = 200;
var minRate = 100;

function f_setInit(){
	if(GetCookie2("zoomVal") != null && GetCookie2("zoomVal") != "")
	{
		document.body.style.zoom = GetCookie2("zoomVal");
		setCookie("zoomVal",document.body.style.zoom, 1);
	}
	else
	{
		document.body.style.zoom = '100%';		
		setCookie2("zoomVal",document.body.style.zoom, 1);
	}
}


function zoomInOut(contentid, how)
{  
	if (((how == "in") && (parseInt(document.body.style.zoom) >= maxRate)) || ((how == "out") && (parseInt(document.body.style.zoom) <= minRate)) )
	{	
		return;
	}
	if (how == "in"){
		document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+'%';
	}
	else
	{	
		document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+'%';
		
	}	
	setCookie2("zoomVal",document.body.style.zoom, 1);
}


function GetCookie2( name )
	{
	    var nameOfCookie = name + "=";
	    var x = 0;
	    while ( x <= document.cookie.length )
	    {
	            var y = (x+nameOfCookie.length);
	            if ( document.cookie.substring( x, y ) == nameOfCookie )
	            {
	                    if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
	                            endOfCookie = document.cookie.length;
	                    return unescape( document.cookie.substring( y, endOfCookie ) );
	            }
	            x = document.cookie.indexOf( " ", x ) + 1;

	            if ( x == 0 )  break;
	    }
	    return "";
	}


function setCookie2( key, value, term ){
	var expire = new Date();
	expire.setDate( expire.getDate() + term );
//	document.cookie = key + "=" + escape( value ) + "; path=/; expires="+expire.toGMTString().substring(0,17)+"15:00:00"+expire.toGMTString().substring(25)+";";
	document.cookie = key + "=" + escape( value ) + "; path=/; expires=" + expire.toGMTString() + ";";
}

function setCookie(strName, strValue, intDate)
{
    var strExpires = "";
    if(intDate!=null && !isNaN(intDate))
    {
        var dtmToday = new Date();
        dtmToday.setDate(dtmToday.getDate() + parseInt(intDate));
        strExpires = ";expires=" + dtmToday.toUTCString();
    }
    document.cookie = strName + "=" + escape(strValue) + strExpires + ";path=/; domain=.homeplusb2b.com";
}




function contentPrint() {
	var windowLeft = (screen.width-640)/2;
	var windowTop = (screen.height-480)/2;

	var printURL = "../inc/print.jsp";
			
	window.open(printURL,"content",'width=768, height=650, menubar=no, scrollbars=yes,status=no,resizable=yes,top=' + windowTop + ',left=' + windowLeft + '');
}

function contentPrint_main() {
	var windowLeft = (screen.width-640)/2;
	var windowTop = (screen.height-480)/2;

	var printURL = "./inc/print.jsp";
			
	window.open(printURL,"content",'width=768, height=650, menubar=no, scrollbars=yes,status=no,resizable=yes,top=' + windowTop + ',left=' + windowLeft + '');
}


// left menu on/off
function menu_control(depth){
	var depthLen = depth.length;	
	if(depthLen <= 2){
	  // 1depth
	  eval("document.getElementById('menu"+depth+"').className='b'");	 
	}
	else{
		// 1depth
		eval("document.getElementById('menu"+depth.substr(0,2)+"').className='b'");
		// 2depth
		eval("document.getElementById('menu"+depth+"').className='on'");	 
	}
}

function rollingBanner(cnt){		 
 var listCnt = cnt;		// banner count
 var movingCnt = 1;	// scrolling height
 var banHeight = 47;	// banner height
 var banSpeed = 50; // scroll speed
 
 var arr_ban = new Array();

 if(listCnt > 2){	// banner is more then 2
	 for(i=0; i<listCnt; i++){
	   arr_ban[i] = document.getElementById("ban"+i);
	 }
	 
	 for(i=0; i<listCnt; i++){
	 	if(i==0){
	 	  if(arr_ban[i].style.top == -parseInt(banHeight)+"px"){	// When the first banner in a hidden area
	 		  arr_ban[i].style.top = (parseInt(arr_ban[listCnt-1].style.top.replace("px","")) + parseInt(banHeight) ) + "px" ;				  
	 	  }else{
	 	  	arr_ban[i].style.top = (parseInt(arr_ban[i].style.top.replace("px","")) - parseInt(movingCnt)) + "px" ;			  	
	 	  }
	   }else{
	 		if(arr_ban[i].style.top == -parseInt(banHeight)+"px"){					
	 		  arr_ban[i].style.top = (parseInt(arr_ban[i-1].style.top.replace("px","")) + parseInt(banHeight)) + "px" ;				  
	 	  }else{
	 		  arr_ban[i].style.top = (parseInt(arr_ban[i].style.top.replace("px","")) - parseInt(movingCnt)) +"px" ;		  				  
	 	  }
	 	}
	 }
	 
	 window.setTimeout("rollingBanner("+listCnt+");",banSpeed);
 }
}	