// HTML Title
document.title = '우리농식품사랑 캠페인';

// flashWrite(파일경로, 가로, 세로, 아이디, 배경색, 변수, 윈도우모드)
function flashWrite(url,w,h,id,bg,vars,win){

// 플래시 코드 정의
var flashStr=
"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
"<param name='allowScriptAccess' value='always' />"+
"<param name='movie' value=' "+url+"' />"+
"<param name='FlashVars' value='"+vars+"' />"+
"<param name='wmode' value='"+win+"' />"+
"<param name='menu' value='false' />"+
"<param name='quality' value='high' />"+
"<param name='bgcolor' value='"+bg+"' />"+
"<embed src=' "+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
"</object>";

// 플래시 코드 출력
//alert(flashStr);
document.write(flashStr);

}

// 오픈 팝업 스크립트 //
function goPopup(url, name, _width, _height, _scrollbar){
	var screenX;
	var screenY;

	if(navigator.appName == "Microsoft Internet Explorer") {
		screenX = window.screen.availWidth;
		screenY = window.screen.availHeight;
	}
	else {
		screenX = window.outerWidth;
		screenY = window.outerHeight;
	}

	var h, w;
	w = (screenX - _width)/2;
	h = (screenY - _height)/2;

	var newWin = window.open(url, name, 'left=' + w + ' top=' + h + ' width=' +_width + ' height=' + _height + ' scrollbars=' + _scrollbar + 'resize=no,toolbar=no,status=no,menu=no');

	newWin.focus();

	return newWin;
}

//self.close하고 부모창 이동
function sendit(url){
	opener.location.href = url;
	window.close();
}





//-- mouse menu disable
//document.oncontextmenu=new Function("return false");
//document.onselectstart=new Function("return false");
//document.ondragstart=new Function("return false");

setBrowser = function (){//IE=0,FF=1,OPERA=2,etc=0;
	var wna = window.navigator.userAgent;
	if(wna.indexOf('MSIE')!=-1){
		this.browser=0;
	}else if(wna.indexOf('Firefox')!=-1){
		this.browser=1;
	}else  if(wna.indexOf('Opera')!=-1){
		this.browser=2;
	}else if(document.all){//etc = 0;
		this.browser=0;
	}else{
		this.browser=null;
	}
	return this.browser;
}
var app = setBrowser();
//-- is be check

function getEid(n,f) {
	try{
		if(f){			
			var isObj = parent.main.document.getElementById(n);
		}else{
			var isObj = document.getElementById(n);
		}

		if(document.getElementById(n) != null){
			return isObj;
		}else{
			return null;
		}		
	}catch(err){
		return null;
	}
}
//-- s:quick menu
var qObj="quick", docW = -72, qGap1=34, qGap2=95, chkQuick=false, addGap=33, scrollid, endPoint, quickspd = 10, addPoint = 140;
//var qObj="quick", docW = -65, qGap1=34, qGap2=95, chkQuick=false, addGap=33, scrollid, endPoint, quickspd = 10, addPoint = 140;
//var qObj="quick", docW = 870, qGap1=34, qGap2=105, chkQuick=false, addGap=10, scrollid, endPoint, quickspd = 10, addPoint = 140;
function scrollmenu() { //scroll function
	if(getEid(qObj) != null) {
		//alert(document.getElementById(qObj).style.top);
		var topscroll = parseInt(document.getElementById(qObj).style.top, 10);
		var topmove = (endPoint - topscroll)/quickspd;
		//alert(topmove);
		if (topmove < 1 && topmove > 0) topmove = 1;
		//alert("topscroll : " + topscroll);
		document.getElementById(qObj).style.position = "absolute";
		document.getElementById(qObj).style.Zindex = "100";
		document.getElementById(qObj).style.top = topscroll + topmove + 'px';		
		//window.status = "tm: " + topmove + " endPoint(" + endPoint + ") - topscroll(" + topscroll + ") == 0 && "+ "endPoint(" + endPoint + ") -  scrollTop(" + document.body.scrollTop + ") == addPoint(" + addPoint+")";
		//alert(endPoint+"::::"+topscroll+":::"+topmove);
		if ((endPoint - topscroll) == 0) {			
			clearInterval(scrollid);			
		}else{
			InitializeStaticMenu();
		}

	}
}

function initQuick(){
	if(getEid(qObj) != null){
		var obj=getEid(qObj).style;
		obj.position = "absolute";
		obj.left = "950px";
		obj.top = "140px";
		obj.width = "75px";
		obj.height = "330px";
		obj.Zindex = "100";
	}
}

function InitializeStaticMenu() { //set end point
	if(!chkQuick) {
		chkQuick = true;
		initQuick();
		posX();
	}
	if(scrollid) clearInterval(scrollid);	
	if(!document.body.scrollTop) {
		endPoint = document.documentElement.scrollTop + addPoint;
	} else {
		endPoint = document.body.scrollTop + addPoint;		
	}

	var bottomHeight = document.getElementById("wrap").offsetHeight;
	//var getSH = document.documentElement.scrollHeight;
	//alert(" 스크롤높이 : " + bottomHeight);
	var maxTop = bottomHeight - (addPoint + addGap) - 200;
	//var maxTop = getSH;
	if(endPoint > maxTop){		
		endPoint = maxTop;
	}
	
	scrollid = setInterval(scrollmenu, 10);

}

function posX(){
	var xpos;
	var getSpace = document.documentElement.scrollWidth - docW;

	//좌측위치 고정..
	/*
	if(getSpace >=0){
		xpos = docW + (getSpace/2) + qGap1;
	}else{
		xpos = docW + qGap1 + qGap2;
	}
	*/
	xpos = 950;
	//alert(xpos);
	document.getElementById(qObj).style.left = parseInt(xpos) + 'px';
}
window.onload = function(){
	initQuick();
}

window.onscroll = InitializeStaticMenu;
/*
window.onresize = function(){
	InitializeStaticMenu();
	posX();
}
*/

function evtPop(){
	window.open('/evt/renew/','evtPop','top=20,left=100,menubar=yes,toolbar=no,location=yes,scrollbars=no,resizable=no');
}