/*
* @ÁÂ¿ìÃø floating ¸Å´º Ãâ·Â
* @author pss
* @version 0.1
*/
document.writeln("<div id='float_leftBanner' style='position: absolute; MARGIN-LEFT: 5px; left: 120px; top:200px; z-index:1; visibility:show'></div>");
document.writeln("<div id='float_rightBanner' style='position: absolute; MARGIN-LEFT: 5px; left: 120px; top:200px; z-index:1; visibility:show'></div>");    

var topMarginHeight	= 80;      //¹è³ÊÀÇ »ó´Ü¿©¹é
var pageWidth		= 700;      //ÆäÀÌÁö ÀüÃ¼ »çÀÌÁî

var showLeftBannerDiv = document.getElementById('float_leftBanner');
var showRightBannerDiv = document.getElementById('float_rightBanner');



/*
* °¢ ºê¶ó¿ìÁî¿¡ µû¶ó ½ºÅ©·Ñ°ª È£Ãâ
*/
var getNowScroll = function(){
    var now = {}; now.Y=0;now.X=0;
    if( typeof( window.pageYOffset ) == 'number' ) {
	  //Netscape compliant
	  now.Y = window.pageYOffset;
	  now.X = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	  //DOM compliant
	  now.Y = document.body.scrollTop;
	  now.X = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	  //IE6 standards compliant mode
	  now.Y = document.documentElement.scrollTop;
	  now.X = document.documentElement.scrollLeft;
	}	
    return now;
}

/*
* °¢ ºê¶ó¿ìÁî¿¡ µû¶ó °¡·Î»çÀÌÁî È£Ãâ
*/
var getClientWidth = function(){
    
    var myCW = {};myCW.W=0;myCW.H=0;
    
    if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myCW.W = window.innerWidth;
	    myCW.H = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myCW.W = document.documentElement.clientWidth;
		myCW.H = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myCW.W = document.body.clientWidth;
		myCW.H = document.body.clientHeight;
	}
	
	return myCW;
}
  
/*
* ÆÄ¶ó¸ÞÅÍ°¡Á®¿À±â
*/
function getParams() {
	var idx = document.location.href.indexOf('?');
	 
	var params = new Array();
	var blank_str = ' ';
	
	if (idx != -1) {
		var pairs = document.location.href.substring(idx+1, document.location.href.length).split('&');				
		for (var i=0; i<pairs.length; i++) {
	
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
			
			restr = nameVal[1].split('+');
			
			var restr2 = "";
			var blank_str = " ";
			 	for (var j=0; j<restr.length; j++) {
			 		
			 		if(restr.length == j+1){
			 			
			 			blank_str =  "";
			 		}
			 		
			 		restr2 = restr2 + restr[j]+blank_str ;
			 		
			 	}	
			params[nameVal[0]] = restr2;
		}
	}
	
	return params;    	
	
}


function moveLeftMenu() {

	nowScroll = getNowScroll();
	nowClient = getClientWidth();
	
	var setDebug        = true;    //µð¹ö±ë¸ðµå
	var appVer=navigator.appVersion.substring(25,22);
    
    if(showLeftBannerDiv.offsetHeight < nowClient.H){
        if (document.getElementById) {
            showLeftBannerDiv.style.top = parseInt(nowScroll.Y) + topMarginHeight;		 	
		} else if (document.layers) {
		    showLeftBannerDiv.style.top = parseInt(nowScroll.Y) + topMarginHeight;		 	
		}	  
	}
	
	if(nowClient.W > pageWidth){//»çÀÌÆ®°¡ ºê¶ó¿ìÀúº¸´Ù ÀÛÀ»¶§(Á¤»óÀÏ¶§)
        showLeftBannerDiv.style.display="block";
        showLeftBannerDiv.style.left = (nowClient.W - pageWidth) /2 - 130;			
    }else{
        showLeftBannerDiv.style.display="none";            
        showLeftBannerDiv.style.left = pageWidth;        
    }
    
}

function moveRightMenu() {

	nowScroll = getNowScroll();
	nowClient = getClientWidth();
	
	var setDebug        = true;    //µð¹ö±ë¸ðµå
	var appVer=navigator.appVersion.substring(25,22);
    
    if(showRightBannerDiv.offsetHeight < nowClient.H){
       
        if (document.getElementById) {
            showRightBannerDiv.style.top = parseInt(nowScroll.Y) + topMarginHeight;		 	
		} else if (document.layers) {
		    showRightBannerDiv.style.top = parseInt(nowScroll.Y) + topMarginHeight;
		}	  
	}
	
	if(nowClient.W > pageWidth){
	    showRightBannerDiv.style.left = (nowClient.W + pageWidth)/2;    	
	}else{    	
	    showRightBannerDiv.style.left = pageWidth;
	}
	
}


/*
*
*/
function callMenuBannerData(setAlign,contents_id){

    var params = getParams();	
    var setPrefixFile = "";
    
    if(params['id'] == undefined){
        setPrefixFile = contents_id;
    }else{
        setPrefixFile = params['id'];
    }
    if(document.location.host == 'www.gohackers.com' || document.location.host == 'gohackers.com'
    || document.location.host == 'www.hackerstoefl.com' || document.location.host == 'hackerstoefl.com'
    ){
    
    	//var requestURL = "http://"+document.location.host+"/_include/menu_include/id_"+setPrefixFile+"_"+setAlign+".html";	
    	var requestURL = "http://"+document.location.host+"/_include/quickbannerReader.php?id="+setPrefixFile+"&align="+setAlign;
    	var param = {};
    	var reqRet = new Ajax ( requestURL ,{
    	    'method' : "POST",
    		'charset' : "euc-kr",
            'params'  : param,
    		onLoad  : function(req) {
    		    //ÆäÀÌÁö°¡ ÀÖ´Â°Í¸¸ È£ÃâÇÔ
    		    if(req.status != 404){
    		        document.getElementById("float_"+setAlign+"Banner").innerHTML = req.responseText;    		    
    		    }		    
    		}
    	});
    }
}

function setMenuBannerInit(contents_id) {
	
		
	setInterval("moveLeftMenu();",20);
	setInterval("moveRightMenu();",20);
	
	callMenuBannerData("left",contents_id);
	callMenuBannerData("right",contents_id);
}

if(contentId == undefined){
    //
    var contentId ="";
}


var oldLoadHandlerGoTop = window.onload;

window.onload = new Function("{if (oldLoadHandlerGoTop != null) oldLoadHandlerGoTop(); setMenuBannerInit(contentId);}");

