// open popup : User Click
function openPopup(url, winW, winH, scroll, winName)
{
	var setup = "width="+ winW +",height="+winH+",toolbar=no,location=no,status=no,menubar=no,top=10,left=50,scrollbars=" + scroll +",resizable=no";
	if (!winName) winName = "";
	window.open(url, winName, setup);
}

// open popup : Auto Popup
function openDenyPopup(url, winW, winH, scroll, winName)
{
	var setup = "width=" + winW + ",height=" + winH + ",toolbar=no,location=no,status=no,menubar=no,top=20,left=20,scrollbars=" + scroll +",resizable=no";
	if (!winName) winName = "";
	var win = window.open(url, winName, setup);
	if (win == null) alert("Please allow windows pop up.");
	else win.focus();
}

//open full screen
function openFullScreen(url){
	var setup = "fullscreen=1,scrollbars=0";
	var win = window.open(url,"popup",setup);
}

// image rollover rollout
function rollover(obj) 
{
    var obj = document.getElementById(obj);
    if (obj != null) {
	var imgSrc = obj.src;
	obj.src = imgSrc.replace("off", "on");
    }
}
function rollout(obj) 
{
    var obj = document.getElementById(obj);
    if ( obj != null) {
	var imgSrc = obj.src;
	obj.src = imgSrc.replace("on", "off");
    }
}

/* Image rollover without ID */
function imgover(img) {
	var image=img.src;
	
	if (image.indexOf('on.gif') < 0) {
		currentUrl=image.substr(0,image.indexOf('off.gif'));
		img.src=currentUrl + "on.gif";
	}
	else {
		currentUrl=image.substr(0,image.indexOf('on.gif'));
		img.src=currentUrl + "off.gif";
	}
} 


//show Flash Object ; 1
function showFlashObject(objID, objSource, objWidth, objHeight, objQuality, objWmode, objBgcolor){
	//page url
	var pageUrl=self.window.location.href;
	//default value setting
	if (objID=="") objID="ShockwaveFlash1";
	if (objWidth=="") objWidth="0";
	if (objHeight=="") objHeight="0";
	if (objQuality=="") objQuality="high";

	document.writeln('<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="'+objWidth+'" height="'+objHeight+'" id="'+objID+'" align="middle">');
	document.writeln('<param name="movie" value="'+objSource+'" />');
	document.writeln('<param name="allowScriptAccess" value="always" />');
	document.writeln('<param name="menu" value="false" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="bgcolor" value="'+objBgcolor+'" />');
	document.writeln('<param name="wmode" value="'+objWmode+'" />');
	document.writeln('<embed src="'+objSource+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+objBgcolor+'" wmode="'+objWmode+'" width="'+objWidth+'" height="'+objHeight+'" name="'+objID+'" id="'+objID+'" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
}

function getStyleAtt(obj, stylePrp)
{
    var att = "";
	if (obj.currentStyle)
	{
		stylePrp = stylePrp.replace(/\-(\w)/g, function(k,z){return z.toUpperCase();});
		att = obj.currentStyle[stylePrp];
	}
	else if (document.defaultView && document.defaultView.getComputedStyle)
	{
		att = document.defaultView.getComputedStyle(obj, "").getPropertyValue(stylePrp);
	}
	return att;
}

//show Flash, Media Object setting
var paramInfo = new Array;
function initParam()
{
	var oldSize = paramInfo.length;
	for (var i=0; i<oldSize; i++) {
		paramInfo.length--;
	}	
}
function setParam(paramName, paramValue)
{
	var idx = paramInfo.length;
	paramInfo[idx] = [];
	paramInfo[idx][0] = paramName;  
	paramInfo[idx][1]= paramValue;
}

function playFlash(objID, objSource, objWidth, objHeight, objStyle, cabVersion, embedAttr)
{
	document.write('<OBJECT id="' + objID + '" name="' + objID + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');

	if (cabVersion != '') {
		document.write('codebase="' + self.window.document.protocol + '"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + cabVersion + '" ');
	}
	document.write('WIDTH="' + objWidth + '" HEIGHT="' + objHeight + '" ' + objStyle + '>');

	for (var i=0; i<paramInfo.length; i++) {
		document.write('<PARAM NAME="' + paramInfo[i][0] + '" VALUE="'+ paramInfo[i][1] +'">');		
	}	
	
	document.write('<embed src="' + objSource + '" width="' + objWidth + '" height="' + objHeight + '" ' + embedAttr + '>');
	document.write('</OBJECT>');
}

//show Media Object
function playMedia(objID, objSource, objWidth, objHeight, objStyle)
{
	document.write('<OBJECT id="' + objID + '" name="' + objID + '" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ');
	document.write('WIDTH="' + objWidth + '" HEIGHT="' + objHeight + '" ' + objStyle + '>');
	for (var i=0; i<paramInfo.length; i++) {
		document.write('<PARAM NAME="' + paramInfo[i][0] + '" VALUE="'+ paramInfo[i][1] +'">');
	}
	document.write('</OBJECT>');
}

// main
function showLayer(obj, imgObj)
{
	var el = document.getElementById(obj);
	var el2 = document.getElementById(imgObj);
	var imgSrc = el2.src;
	if (getStyleAtt(el, "display") == "block" || getStyleAtt(el, "display") == "") {
		el.style.display = "none";
		imgSrc = imgSrc.replace("ic_minus", "ic_plus");
		el2.src = imgSrc;
	}
	else {
		el.style.display = "block";
		imgSrc = imgSrc.replace("ic_plus", "ic_minus");
		el2.src = imgSrc;
	}
}


function charLink(idx) {
	//document.location.href = "characters" + idx +".html";
	document.location.href = "http://cabal.ogplanet.com/info.og?op=c" + idx + "_1";
}

var faq_idx_tmp = 0;
function faqView(idx) {
	if (faq_idx_tmp != 0) document.getElementById("q"+faq_idx_tmp).style.display = "none";
	document.getElementById("q"+idx).style.display = "block";
	faq_idx_tmp = idx;
}