// <![CDATA[
var isMSIE=(document.all)?true:false;
var isJS12=(window.screen)?true:false;
var isDOM = ((document.getElementById) ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = ((document.layers) ? true : false);
var isNS = navigator.appName == "Netscape";


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//°ø·æ Ã¥ º¸±â ·¹ÀÌ¾î
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showHideLayers(objL, v) { //v3.0
if ((obj=document.getElementById(objL))!=null) {
    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v='hide')?'none':v; }
    obj.display=v; }
}

function callError(msg, url, linenumber){
	alert(msg+"\n"+ url +"\n"+ linenumber)
	//if ( typeof(top.hidBottom) != "undefined" ) top.hidBottom.document.location.href = "/ScriptError.asp?msg=" +escape(msg) + "&url=" + escape(url) +"&linenumber="+linenumber;
	return true;
}
//window.onerror=callError;

function getPayHistory() {
	window.open( strHost + "/Member/GetPayHistory.asp","PayHistory","width=630, height=560");
}

var winX, winY
function screenCenter(objX, objY){
	if (parseInt(navigator.appVersion) >= 4) {
		winX = ((screen.availWidth*.5)-(objX*.5));
		winY = ((screen.availHeight*.5)-(objY*.5));
	}
}

function MiniPop(num) {
	popupwinX = "280";
	popupwinY = "260";

	if(num==1) imgName = "FindAccount.gif";
	else imgName = "NoEmail.gif";

	SimpleImgPop("/image/"+ imgName, 280,  260 );
}

function SimpleImgPop(imgSrc, imgWidth, imgHeight, isPrint){
	screenCenter(Number(imgWidth),Number(imgHeight));
	var p = window.open("","","width="+ imgWidth +", height="+ imgHeight +", left= "+ winX +",top="+ winY);
	var d = p.document.open();

	d.write("<html><meta http-equiv='imagetoolbar' content='no'><body leftmargin='0' topmargin='0'><img src='"+ imgSrc +"' width='"+ imgWidth +"' height='"+ imgHeight +"' style='cursor:hand' onclick='window.close();'></body></html>");
	d.close();
	if( typeof(isPrint) != 'undefined' ) p.print();
}

function MainPop(popupwinX,popupwinY,strSrc) {
	screenCenter(Number(popupwinX),Number(popupwinY));
	window.open(strSrc,"MainPop","width="+ popupwinX +", height="+ popupwinY +", left="+ winX +" ,top="+ winY);
}

function getCookie( 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 "";
}

var setCookie = function(name, value, expiredays) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays);
	todayDate.setHours(0,0,0);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function addFavorite() {
//	top.bottom.location.href = "addLoginLog.asp?pageCode=AddFavor";
	window.external.AddFavorite('http://www.genikids.com/','¶È¶ÈÇÑ¾ÆÀÌ¸¸µé±â Áö´ÏÅ°Áî :::: www.genikids.com')
}

function checkReturn(objForm, e) {
	if ( e.keyCode == 13 ) {
		formCheck();
	}
}

function getScreenHeightResolution(){
	var strReturn = "100%";
	var isJS12=(window.screen)?true:false;
	if(isJS12){
		var SCRate = screen.width / screen.height;
		if( SCRate >= 1.6 ){
			//strReturn = String(Math.floor(screen.height * 1.3));
			strReturn = "81%";
		}
	}
	return strReturn;
}

function reSize(objSel)
{
	var objFrame = objSel;
	var objBody = objFrame.document.body;
	objFrame.style.height = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
//	alert(objBody.offsetHeight +'-'+ objBody.clientHeight+'+'+objBody.scrollHeight);
}

function PrintJSSWF(strURL, strwidth, strheight){
	document.open();
	//document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '">\r' );
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/JScript/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '">\r' );
	document.write( '<param name="movie" value="'+ strURL + '">\r' );
	document.write( '<param name="quality" value="high">\r' );
	document.write( '<param name="wmode" value="transparent">\r' );
//	document.write( '<param name="menu" value="false">\r' );
	document.write( '<param name="allowScriptAccess" value="always">\r' );
	document.write( '<param name="scale" value="exactfit">\r' );
	document.write( '<embed src="'+ strURL + '" quality="high" allowScriptAccess="always" allowFullScreen="false" scale="showall" devicefont="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ strwidth + '" height="'+ strheight + '"wmode="transparent">\r' );
	document.write( '</embed>' );
	document.write( '</object>' );
	document.close();
}

function PrintJSSWFID(strURL, strwidth, strheight, strID){
	document.open();
	//document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID +'">\r' );
	if(isMSIE){document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/JScript/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID +'">\r' );
	document.write( '<param name="movie" value="'+ strURL + '">\r' );
	strURL.indexOf("13592.swf") > 0 ?  document.write( '<param name="quality" value="medium">\r' ) : document.write( '<param name="quality" value="high">\r' );
	if(strID != "GAMESWF") document.write( '<param name="wmode" value="transparent">\r' );
//	document.write( '<param name="menu" value="false">\r' );
	document.write( '<param name="allowScriptAccess" value="always">\r' );
	document.write( '<param name="scale" value="exactfit">\r' );
	document.write( '</object>' );
	}else{
	document.write( '<embed src="'+ strURL + '" quality="high" allowScriptAccess="always" allowFullScreen="false" scale="showall" devicefont="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID + '"wmode="transparent">\r</embed>' );
	//document.write( '<embed src="'+ strURL + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID + '"wmode="transparent">\r</embed>' );
	}
	document.close();
}

function PrintObj(id) {
	document.open();
	document.write(id.innerHTML); delete(id);
	document.close();
}

var categoryChange = function(tab, sel, len) {		//tab:±¸ºÐÀÚ sel:¼±ÅÃµÈÀÎµ¦½º len:°³¼ö
	for ( i=0 ; i < len ; i++ )
		sel == i ? document.getElementById(tab + i).style.display = '' : document.getElementById(tab + i).style.display = 'none';
}

var createParam = function(strName , strVar, objO){
	var p = document.createElement( "PARAM" );
	p.setAttribute("name", strName);
	p.setAttribute("value", strVar);
	objO.appendChild(p);
}

var createSWF = function (divID, swfID, strMovieSrc, divLeft, divTop, intWidth, intHeight, strVars){
	var oSWF;
	isMSIE ? oSWF = document.createElement( "OBJECT" ) : oSWF = document.createElement( "EMBED" );
	if ( isMSIE ) {
		createParam("movie", strMovieSrc, oSWF);
	 	createParam("allowScriptAccess", "always", oSWF);
	 	createParam("scale","exactfit", oSWF);
	 	createParam("wmode","transparent", oSWF);

		oSWF.setAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
		oSWF.setAttribute("codebase", "/JScript/swflash.cab#version=9,0,28,0");
		oSWF.setAttribute("type","application/x-shockwave-flash");
		oSWF.setAttribute("allowScriptAccess","always");
		//oSWF.setAttribute("quality","high");
	 	oSWF.setAttribute("scale","exactfit");
	 	oSWF.setAttribute("movie", strMovieSrc);


	 	if(strVars != undefined ) oSWF.setAttribute("flashVars", strVars);

		/*
		var oParam = document.createElement("param");
		oParam.setAttribute("name", "movie");
		oParam.setAttribute("value", strMovieSrc);

		var oParam1 = document.createElement("param");
		oParam1.setAttribute("name","quality");
		oParam1.setAttribute("value","high");

		var oParam2=document.createElement("param");
		oParam2.setAttribute("name","allowScriptAccess");
		oParam2.setAttribute("value","sameDomain");

		var oParam3=document.createElement("param");
		oParam3.setAttribute("name","scale");
		oParam3.setAttribute("value","exactfit");

		var oParam4=document.createElement("param");
		oParam4.setAttribute("name","allowScriptAccess");
		oParam4.setAttribute("value","always");
		oSWF.appendChild(oParam);
		oSWF.appendChild(oParam1);
		oSWF.appendChild(oParam2);
		oSWF.appendChild(oParam3);
		oSWF.appendChild(oParam4);
		*/
	}else{
		oSWF.setAttribute("type", "application/x-shockwave-flash");
		oSWF.setAttribute("pluginspage", "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash");
		oSWF.setAttribute("src", strMovieSrc);
		oSWF.setAttribute("quality", "high");
		oSWF.setAttribute("align", "center");
		oSWF.setAttribute("scale", "showall");
		oSWF.setAttribute("quality", "high");
		oSWF.setAttribute("allowScriptAccess", "always");
		if(strVars != undefined ) oSWF.setAttribute("flashVars", strVars);
	}
	oSWF.setAttribute("id", swfID);
	oSWF.setAttribute("width", intWidth);
	oSWF.setAttribute("height", intHeight);
	oSWF.setAttribute("wmode", "transparent");

	createDIV(divID, divLeft, divTop, intWidth, intHeight).appendChild( oSWF );
	//return oSWF ;
}

var createDIV = function(divID, divLeft, divTop, divWidth, divHeight){
	var oDiv = document.createElement( 'DIV' ) ;
	oDiv.id 				= divID;
	oDiv.style.overflow	= 'hidden';
	oDiv.style.position	= 'absolute';
	oDiv.style.top=divTop+"px";
	oDiv.style.left=divLeft;
	oDiv.style.width		= divWidth+"px";
	oDiv.style.height		= divHeight+"px";
	oDiv.style.visibility	= '';
	oDiv.style.zIndex 		= 300;
	//oDiv.style.border		= '1px blue solid';
	//oDiv.style.overflow = 'auto';
	oDiv.className		= "drag";

	document.body.appendChild( oDiv ) ;
	return oDiv ;
}

var removeObj = function(divObj) {
	document.body.removeChild(document.getElementById(divObj));
}

var removeObjOut = function(divObj) {
	document.body.removeChild(document.getElementById(divObj));
	top.hidBottom.document.location.href="/Member/LogOutStay.asp";
}

//chk if an object is an array or not.
var isArray = function (obj) {
//returns true is it is an array
	if(obj.constructor.toString().indexOf("function Array()") != -1)
		return true;
	else
		return false;
}

var ranRange = function(min, max){	//MJs. 2008.12.11
	var randomNum = Math.floor(Math.random()*(max - min+1))+ min;
	return randomNum;
}

function genikidsIntro(){
	window.open("http://www.genikids.com/HelpGuide/tour2.htm", "_blank", "width="+screen.availWidth+",height="+screen.availHeight+",status=no")
}
function HelpGuide(url) {
	//geniHelp = window.open("http://partner.genikids.com/help.asp?url="+url,"geniHelp","width=520, height=400, left=" + winX + ",top=" + winY);
	geniHelp = window.open("http://www.genikids.com/HelpGuide/help.asp?url="+url,"geniHelp","width=520, height=400, left=" + winX + ",top=" + winY);
	geniHelp.focus();
}

function clickHelp(url) {
	popupwinX = "520";
	popupwinY = "400";
	screenCenter(Number(popupwinX),Number(popupwinY));
	//geniHelp = window.open("http://partner.genikids.com/help.asp?url="+url,"geniHelp","width=520, height=400, left=" + winX + ",top=" + winY);
	geniHelp = window.open("http://www.genikids.com/HelpGuide/help.asp?url="+url,"geniHelp","width="+ popupwinX +", height="+ popupwinY +", left=" + winX + ",top=" + winY);
	geniHelp.focus();
}

function addEvent(obj, evType, fn) {                     //ºê¶ó¿ìÀúº° ÀÌº¥Æ®Ã³¸®
 if(obj.addEventListener) {
  obj.addEventListener(evtype, fn, true);
  return true;
 }else if(obj.attachEvent) {
  var r = obj.attachEvent("on" + evType, fn);
  return r;
 }else{
  return false;
 }
}

function hiddenLayer(){
	document.all['event55'].style.visibility = 'hidden';
}

function CharacterRoom(){
	window.open("http://naver.genikids.com/Script/CharacterRoom.asp?Character="+ranRange(1,2),"winCharacterRoom","width=800, height=600, left=" + winX + ",top=" + winY);
}

function ParentGuide(val){
	window.open("http://naver.genikids.com/ParentGuidePop.asp?val="+val,"_blank","width=550, height=500, left= "+ winX +",top="+ winY+",status=no");
}

function HelpGuide2(){
	window.open("http://www.genikids.com/Popup/FirstEntrance.asp?seq=1","_blank","width=800, height=600, left= "+ winX +",top="+ winY+",status=no");
}

function PrintStudyCorner(){
	window.open("http://www.genikids.com/ParentCorner/PC_main.asp?Cate=F", "_blank", "width="+screen.availWidth+",height="+screen.availHeight+",status=no")
}

function GenikidsReview(val){
	if(val == "1"){
		strTag = "»ó»ó";
	}else if(val == "2"){
		strTag = "¿µ¾î";
	}else if(val == "3"){
		strTag = "ÇÇµå¹é";
	}else if(val == "4"){
		strTag = "ÇÑ±ÛÀ»";
	}else if(val == "5"){
		strTag = "ÇÑÀÚ¸¦";
	}else if(val == "6"){
		strTag = "Ã¥";
	}else if(val == "7"){
		strTag = "¹éÇ÷±¸";
	}else if(val == "8"){
		strTag = "±èÄ¡";
	}else if(val == "9"){
		strTag = "È£±â½É";
	}else if(val == "10"){
		strTag = "¾ïÁö·Î";
	}else if(val == "11"){
		strTag = "Ã¢ÀÇ·Â";
	}else if(val == "12"){
		strTag = "¶È¶È";
	}else if(val == "13"){
		strTag = "ÁýÁß";
	}else{
		strTag = "¿Ü±¹";
	}
	window.open("http://www.genikids.com/ParentCorner/PC_main.asp?Cate=B&subCate=E&sort=B&search_cat=subject,contents&search_val="+strTag+"&isStudyAdvice=1","_blank","toolbar=yes,menubar=yes,location=yes,directories=yes,status=no,scrollbars=yes,resizable=yes, left= "+ winX +",top="+ winY);
}

function onWeekContents(val){
	if( document.getElementById("weekpopDiv") != null )	removeObj("weekpopDiv");
	createSWF("weekpopDiv", "weekpopSwf","http://image.jr.naver.com/genikids/image/week_pop_fla0"+val+".swf?objID=weekpopDiv&val="+val, "30%", 120, 550, 400);
}

var OnAir = function(){
	//alert($("BroadcastScheduleTable").style.display);
	$("BroadcastScheduleTable").style.display == "none" ? $("BroadcastScheduleTable").style.display = "inline" : $("BroadcastScheduleTable").style.display = "none"  ;
}

var goGenikidsBroadcast = function( strD, strC ){
	//alert("strD:"+ strD +", strC:"+ strC);
	//strC == 1 ? goGeni = window.open("http://www.genikids.com/index.asp?Broadcast=on","","") : goGeni = window.open("http://www.genikids.com/FreeTakeCorner/FreeMain.asp?Broadcast=on","","");
	goGeni = window.open("http://www.genikids.com/FreeTakeCorner/FreeMain.asp?Broadcast=on","","");
	goGeni.focus();
}

var ducdam = function(){	//´ö´ãÀÌº¥Æ®
	var posX = ranRange(150,800);
	var posY = ranRange(80,500);
	var RanValue = ( Math.floor(Math.random()*10) % 2 ) + 1;
	var RanCharacter = ( Math.floor(Math.random()*10) % 7 ) + 1;
	if(RanCharacter == 5) RanCharacter = 1;
	if(RanCharacter == 7) RanCharacter = 2;
	if (RanValue == 1){	// && !(RanCharacter == 5 || RanCharacter == 7 )){
	//	createSWF('Ducdam', 'swfDucdam','http://img.genikids.com/Event/swf/OlympicMedalChar.swf?objID=Ducdam',680, 270, 90, 170);
	//	createSWF('Ducdam', 'swfDucdam','http://img.genikids.com/Event/swf/OlympicMedalEvent.swf?objID=Ducdam',370, 270, 90, 170);
		createSWF('Ducdam', 'swfDucdam','http://img.genikids.com/Event/swf/ducdam'+RanCharacter+'.swf?objID=Ducdam',posX, posY, 90,170);
	//	createSWF('Ducdam', 'swfDucdam','http://img.genikids.com/Event/swf/09ChildrensDay.swf?objID=Ducdam&ducdamDetail='+RanCharacter,posX, posY, 90,170);
	}
}

var ducdamDetail = function(character){	//´ö´ã»ó¼¼º¸±â
	if( LoginID != ""){
		var RanCharacter = ( Math.floor(Math.random()*10) % 7 );
		if( document.getElementById("Ducdam") != null )	removeObj("Ducdam");
		//createSWF('DucdamDetail', 'swfDucdamDetail','http://img.genikids.com/Event/swf/09ChildrensDay'+character+'.swf?objID=DucdamDetail', 230, 120, 550, 400);
		createSWF('DucdamDetail', 'swfDucdamDetail','http://img.genikids.com/Event/swf/ducdamdetail'+character+'.swf?objID=DucdamDetail', 230, 120, 550, 400);
		//createSWF('DucdamDetail', 'swfDucdamDetail','http://img.genikids.com/Event/swf/OlympicMedalEvent'+ RanCharacter +'.swf?objID=DucdamDetail', 230, 120, 600, 470);
	}else
		alert("·Î±×ÀÎÀ» ¸ÕÀúÇØÁÖ¼¼¿ä.");
}

var GameOpenFocus = function(gameId,menuBar,isEng){
	tempId2 = gameId;
	if(isEng=="1") tempId2 = tempId2+"&ContentsType=English&";
	if(document.all){
		secWin = window.open("/Script/NaverContentsFrame4.asp?url="+tempId2+"&memuBar="+menuBar,"GeniKids_Contents","fullscreen=1");
		secWin.focus();
	}else{
		window.open("/Script/NaverContentsFrame4.asp?url="+tempId2+"&memuBar="+menuBar,"GeniKids_Contents","width="+ screen.availWidth + ", height="+ screen.availHeight );
	}
}
var OpenWindow = function(ConID){ //v2.0
	var strConType;
	strConType = "GeniEnglish";
	GameOpenFocus(ConID);
}
// ]]>
