//Ä¿¸àÆ®¿ë
var target_div ="com_div_"
var target_tab ="com_tab_";
var target_tap_page_preview = "com_page_preview_";
var target_tap_page_next = "com_page_next_";
var searchFlag = false;

//var bookmark_commentCount = 0;

var isIE = document.all?true:false;
if(!isIE) {
	document.captureEvents(Event.CLICK);
	//document.addEventListener(Event.CLICK);
	//document.onmousemove = getMousePosition;		
	
}

document.onclick = mouseEvent;
document.onmousemove = getMousePosition;
_x =0;
_y =0;

rootX = 0;
rootY = 0;

useRootMenu = "";
useSubMenu  = "";
useMenuRoot = false;
useMenuSub  = false;

stepHeight = 15;

function goUrl(url){
	document.location.href ="http://gall.dcinside.com/list.php?id="+url;
}

function getMousePosition(e){
	try{
		/*var isIE = document.all?true:false;
		if(!isIE) {
			_x = e.pageX;
			_y = e.pageY;
		}else {
			_x = event.clientX+ document.body.scrollLeft - document.body.clientLeft;
			_y = event.clientY+ document.body.scrollTop - document.body.clientTop;
		}*/
		var mInfo = getMouseInfo(e);
		_x = mInfo.pageX;
		_y = mInfo.pageY;
	}catch(e){
		//alert(e);
	}
}	


function mouseEvent(e){
	try{
		/*
		if(!isIE) {
			_x = e.pageX;
			_y = e.pageY;
		}else {
			_x = event.clientX+ document.body.scrollLeft - document.body.clientLeft;
			_y = event.clientY+ document.body.scrollTop - document.body.clientTop;
		}
		*/
		//alert("x:"+_x);

		if(useMenuRoot == false && useMenuSub ==false){
			if(useRootMenu != ""){
				obj = document.getElementById(useRootMenu);
				obj.style.visibility='hidden';
			}
			if(useSubMenu != ""){
				obj = document.getElementById(useSubMenu);
				obj.style.visibility='hidden';
			}
		}else{
			useMenuRoot=false;
			useMenuSub=false;
		}
	}catch(e){
		//alert(e);
	}


}

function XMLHTTP() {
if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){return null;}}}else{return null;}
}


function getHtmlInfo()
{
	var obj = {
		clientHeight : 0, 
		clientWidth : 0,  
		scrollHeight : 0, 
		scrollWidth : 0,  
		scrollLeft : 0,   
		scrollTop : 0,    
		offsetHeight : 0, 
		offsetWidth : 0 ,
		screenX:0,
		screenY:0
	};


	if (document.documentElement){
		obj.clientHeight	= parseInt(document.documentElement.clientHeight);
		obj.clientWidth		= parseInt(document.documentElement.clientWidth);
		obj.scrollHeight	= parseInt(document.documentElement.scrollHeight);
		obj.scrollWidth		= parseInt(document.documentElement.scrollWidth);
		obj.scrollLeft		= parseInt(document.documentElement.scrollLeft);	
		obj.scrollTop		= parseInt(document.documentElement.scrollTop);
		if(document.body.offsetHeight) obj.offsetHeight	= parseInt(document.documentElement.offsetHeight);
		else obj.offsetHeight	= parseInt(document.documentElement.clientHeight);

		if(document.body.offsetWidth) obj.offsetWidth	= parseInt(document.documentElement.offsetWidth);
		else obj.offsetWidth	= parseInt(document.documentElement.clientWidth);

		obj.screenX			= parseInt(screen.width);
		obj.screenY			= parseInt(screen.height);
		//alert("HEIGHT : " + document.documentElement.clientHeight);
	} else if (document.body){
		obj.clientHeight	= parseInt(document.body.clientHeight);
		obj.clientWidth		= parseInt(document.body.clientWidth);
		obj.scrollHeight	= parseInt(document.body.scrollHeight);
		obj.scrollWidth		= parseInt(document.body.scrollWidth);
		obj.scrollLeft		= parseInt(document.body.scrollLeft);	
		obj.scrollTop		= parseInt(document.body.scrollTop);

		obj.offsetHeight	= parseInt(document.body.offsetHeight);
		obj.offsetWidth		= parseInt(document.body.offsetWidth);		
		obj.screenX			= parseInt(screen.width);
		obj.screenY			= parseInt(screen.height);

	}else{
		//[Netscape stuff]
	}

	return obj;
}



function getMouseInfo(e){
	var obj = {
		screenX :0,
		screenY :0,
		pageX : 0,
		pageY : 0
	}
	var evt = e ? e : window.event;
	var x = document.all ? event.clientX : document.layers ? evt.x : evt.clientX;
	var y = document.all ? event.clientY : document.layers ? evt.y : evt.clientY;

	var hInfo = getHtmlInfo(); //common

	obj.screenX = x;
	obj.screenY = y;
	obj.pageX = x + hInfo.scrollLeft;
	obj.pageY = y + hInfo.scrollTop;

	return obj;

}

function GEID(objName){
	return document.getElementById(objName);
}

var nameKeyword = "";
function goSearch(){
	//alert('a');
	document.getElementById("k_type").value="1000";
	document.getElementById("keyword").value=nameKeyword;
	document.getElementById("search").submit();
}

function nameSearch(span){
	//alert(span);
	if(!nameKeyword) nameKeyword = span.title;
	popRootMenu('indi_nomember');
}

//iNum 070528 ÁÂÃø °Ö·¯¸® °Ë»ö¸Þ´º ´Ý±â¿ë
var listboxOpenState = false;
function closeListBox(){
	if(listboxOpenState) {
		box = document.getElementById("list");

		if( box=="[object]"){
			list_div = box.contentWindow.document.getElementById("list_div");
			box.style.display="none";
			listboxOpenState=false;
		}

		/*if( list_div=="[object]"){
			list_div.style.display="none";
			listboxOpenState=false;
		}*/
	}

}
function addEvent(object, type, handler, phase)
{
	if(phase==null) phase=false;
	if (object.addEventListener) {
		object.addEventListener(type, handler, phase);
	} else if (object.attachEvent) {
		object.attachEvent(['on',type].join(''),handler);
	} else {
		object[['on',type].join('')] = handler;
	}
}

function addEventV2( obj, type, fn ) {
  if ( obj.attachEvent ) {
	obj['e'+type+fn] = fn;
	obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
	obj.attachEvent( 'on'+type, obj[type+fn] );
  } else if(obj.addEventListener){
	obj.addEventListener( type, fn, false );
  }else{
	obj['e'+type+fn] = fn;
  }
}

function popRootMenu(menuname){
	try{

		//clickPos();
		useMenuRoot=true;
		useRootMenu=menuname;
		rootX=_x;
		rootY=_y;

		obj = document.getElementById(menuname);

		var hInfo = getHtmlInfo();
		obj.style.visibility='visible';
		obj.style.left = _x + "px";
		obj.style.top  = _y + "px";
		//alert("x:"+rootX+",y:"+rootY);
	}catch(e){
		//alert(e);	
	}

}

function menuOver(obj){
	obj.style.cursor='hand';
	obj.style.background='#dcdcdc';

}

function menuOut(obj){
	obj.style.background='#ffffff';
}



function searchLeft(){
	if(MDC == null) return;
	searchFlag = true;
	MDC.H_Move_Left(-150);
	GEID("favbt1").style.position = "absolute";
	GEID("favbt1").style.left = "150px";
}

function searchRight(){
	if(MDC == null) return;
	GEID("favbt1").style.position = "";
	GEID("favbt1").style.left = "";
	GEID("leftIframe").src = "leftIfrm.php";
    MDC.H_Move_Right(10);
}

function getReSize()
{

	 var objFrame = document.getElementById("leftIframe");
 	 objFrame.style.height=objFrame.contentWindow.document.body.scrollHeight;
} 



//iNum
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};



function objectlaunch(obcode)
{
	
   document.writeln(obcode);
}



function flash_mov(id, url, width, height, wmode) {
	var flashStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="player" align="middle">'
		+ '<param name="wmode" value="transparent" />'
		+ '<param name="allowScriptAccess" value="always" />'
		+ '<param name="allowFullScreen" value="true" />'
		+ '<param name="movie" value="'+url+'?pudtv" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="bgcolor" value="#0A0C0F" />'
		+ '<embed src="'+url+'"?pudtv quality="high" bgcolor="#0A0C0F" width="'+width+'" height="'+height+'" name="player" align="middle" allowScriptAccess="always" '
		+ ' allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '
		+ ' />'
		+ ' </object>';
	document.write(flashStr);
}


function trim(str){ 
	str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
	return str; //º¯È¯ÇÑ ½ºÆ®¸µÀ» ¸®ÅÏ.
} 


function insertFlash(swf, width, height, bgcolor, id, flashvars)
{
	var strFlashTag = new String();

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="noscale"/>';
		strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="always"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="noscale" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="always" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	document.write(strFlashTag);
}



function copyToClipboard(value)
{
    try{
		if (window.clipboardData.setData('Text', value)) alert("ÁÖ¼Ò°¡ º¹»çµÇ¾ú½À´Ï´Ù.\n Ctrl+V¸¦ ´­·¯ »ç¿ëÇÏ½Ê½Ã¿À.");
    }catch (e){

    }    
}

//ÃßÃµ
function fn_recommend(){
	alert("ÀÚ±â°¡ µî·ÏÇÑ ±Û¿¡´Â ÃßÃµÇÒ ¼ö ¾ø½À´Ï´Ù.");
}

//ÃßÃµ
function fn_submit(submit_yn,max,id,no){ 
	alert(submit_yn+'//'+max+'//'+id+'//'+no+'//');
	if(submit_yn == "false1"){
		alert('ÇÏ·ç¿¡ '+max+'¹ø¸¸ ÃßÃµÇÒ ¼ö ÀÖ½À´Ï´Ù.');
	}else if(submit_yn == "false2"){
		alert('ÇÏ·ç¿¡ ÇØ´ç±Û '+max+'¹ø¸¸ ÃßÃµÇÒ ¼ö ÀÖ½À´Ï´Ù.');
	}else if(submit_yn == "true"){
		document.location.href ="../recommend_event.php?id="+id+"&no="+no;
	}else{
		document.location.href ="../recommend_event.php?id="+id+"&no="+no;
	}
}




