// G_URL 변수는 common.js에서 선언

//var G_URL = 'http://smile.littlefox.co.kr:8088';
//var G_URL = 'http://littlefox.nefficient.co.kr/littlefox/nwa/smile';

function getFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}


function checkFlashVersion() {
	/*
	var version = getFlashVersion().split(',').shift();
	if(version < 10){
	  alert("Lower than 10");
	}else{
	  alert("10 or higher");
	}
	*/
	var currVerArr = getFlashVersion().split(',');
	var needVerArr = (G_FLASH_VERSION).split(',');

	var currVarAll = currVerArr[0] + ',' + currVerArr[1] + ',' + currVerArr[2];
	var needVerAll = needVerArr[0] + ',' + needVerArr[1] + ',' + needVerArr[2];

	if (currVarAll < needVerAll) alert('Install Flash Player curr:' + currVarAll + ' / need:' + needVerAll);
}


// by pink, 2010.03.19
// by pink, 2010.06.18, embed 없이 파이어폭스에서 가능하도록 수정.
function playflash_ext(filenm, widthSWF, heightSWF, vData) {
	if (navigator.appName == 'Microsoft Internet Explorer') {
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+G_FLASH_VERSION+'" width="' + widthSWF + '" height="' + heightSWF + '">');
		document.writeln('<param name="movie" value="' + G_URL + filenm + '" />');
	}
	else {
		document.writeln('<object type="application/x-shockwave-flash" data="' + G_URL + filenm + '" width="' + widthSWF + '" height="' + heightSWF + '">');
	}
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff" />');
	document.writeln('<param name="scale" value="exactFit" />');
	document.writeln('<param name="flashvars" value="'+vData+'" />');
	// document.writeln('<param name="allowscriptaccess" value="always" />');
	// document.writeln('<param name="allowscriptaccess" value="never" /> ');
	// allowscriptaccess="never"
	// document.writeln('<embed src="' + G_URL + filenm + '" width="' + widthSWF + '" height="' + heightSWF + '" flashvars="'+vData+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" wmode="transparent" allowscriptaccess="always"></embed>');
	document.writeln('</object>');
	//alert(navigator.appName);
}

// 처음오셨나요
function LittlefoxIntro() {
	//	playflash_ext('/static/swf/littlefox_intro.swf', 800, 600);
	filenm		= '/nwa/smile/swf/littlefox_intro.swf';
	widthSWF	= 800;
	heightSWF	= 600;
	document.writeln('<object type="application/x-shockwave-flash" data="' + G_CDN_HOME_URL + filenm + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+G_FLASH_VERSION+'" width="' + widthSWF + '" height="' + heightSWF + '">');
	document.writeln('<param name="movie" value="' + G_CDN_HOME_URL + filenm + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" /> ');
	document.writeln('<param name="bgcolor" value="#ffffff" />');
	document.writeln('<param name="scale" value="exactFit" />');
	document.writeln('<param name="allowscriptaccess" value="always" />');
	// document.writeln('<embed src="' + G_CDN_HOME_URL + filenm + '" width="' + widthSWF + '" height="' + heightSWF + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" wmode="transparent" allowscriptaccess="always"></embed>');
	document.writeln('</object>');

	return;
}

// 동화메인
function flashCDN(filenm, widthSWF, heightSWF, vData)
{
	if (navigator.appName == 'Microsoft Internet Explorer') {
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+G_FLASH_VERSION+'" width="' + widthSWF + '" height="' + heightSWF + '">');
		document.writeln('<param name="movie" value="' + G_SWF_URL + filenm + '" />');
	}
	else {
		document.writeln('<object type="application/x-shockwave-flash" data="' + G_SWF_URL + filenm + '" width="' + widthSWF + '" height="' + heightSWF + '">');
	}
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" /> ');
	document.writeln('<param name="bgcolor" value="#ffffff" />');
	document.writeln('<param name="scale" value="exactFit" />');
	document.writeln('<param name="flashvars" value="'+vData+'" />');
	// document.writeln('<param name="allowscriptaccess" value="always" />');
	// document.writeln('<param name="allowscriptaccess" value="never" /> ');
	// allowscriptaccess="never"
	// document.writeln('<embed src="' + G_SWF_URL + filenm + '" width="' + widthSWF + '" height="' + heightSWF + '" flashvars="'+vData+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" wmode="transparent" allowscriptaccess="always"></embed>');
	document.writeln('</object>');
	return;
}

// littlefox logo
// D:\workspace\www\htdocs\static\swf\logo_main.swf
function FoxLogo() {
	playflash_ext('/static/swf/logo_main.swf', 180, 70, 'xmlPath=' + G_URL);
	return;
}

// TOP메뉴
function MainMenu(num) {
	playflash_ext('/static/swf/navi.swf?movie='+num, 750, 80);
	return;
}

// 메인: News
function NewList() {
	playflash_ext('/static/main/main_news.swf', 500, 130, 'xmlPath=/static/main/headline.xml');
	return;
}

// 메인: 이달의컨텐츠
function MonthFree(valXML,valYM) {
	playflash_ext('/static/main/main_view.swf', 133, 96, 'xmlPath=/static/main/' + valYM + '/month_' + valXML + '.xml');
	return;
}

// 프린터블북 메인
function ready() {
	playflash_ext('/static/swf/ready.swf', 376, 163);
	return;
}

// 프린터블북 샘플
function PrintableFree(valXML,valType) {
	if (valType == 'H') {
		sizeW = 430;
		sizeH = 640;
	}
	else {
		sizeW = 600;
		sizeH = 460;
	}
	playflash_ext('/static/printable_free/printable_free.swf', sizeW, sizeH, 'basePath=' + G_URL + '&xmlPath=/static/printable_free/' + valXML + '.xml');
	return;
}

// 컨텐츠 플래이 버튼
function con_play(fcid,contyn,free) {
	playflash_ext('/static/swf/btnPlay.swf', 133, 96, 'isFree='+free+'&contyn='+contyn+'&fcid='+fcid);
}