// JavaScript Document

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_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_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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 WinOpenFront(openurl,winw,winh){//JavaScript1.1 or later
	var paradetail = 'resizable=1,scrollbars=0,menubar=0,directories=0,status=0,location=0,width=' + winw +',height=' + winh;
	var theWindow = window.open(openurl,'subwindow',paradetail);
	if ((navigator.appName.charAt(0) =="N" && navigator.appVersion.charAt(0)>=3) || (navigator.appName.charAt(0) =="M" && navigator.appVersion.charAt(0)>=4))
	theWindow.focus();
	return;
}
function WinOpenFront2(openurl,winw,winh){//JavaScript1.1 or later
	var paradetail = 'resizable=1,scrollbars=1,menubar=0,directories=0,status=0,location=0,width=' + winw +',height=' + winh;
	var theWindow = window.open(openurl,'subwindow',paradetail);
	if ((navigator.appName.charAt(0) =="N" && navigator.appVersion.charAt(0)>=3) || (navigator.appName.charAt(0) =="M" && navigator.appVersion.charAt(0)>=4))
	theWindow.focus();
	return;
}
function WinOpenfc100(){
window.open('/intl/ex_fc100/tvcm.html','windowfc100','resizable=1,scrollbars=0,menubar=0,directories=0,status=0,location=0,width=500,height=290');
}
function popupWin(url, winName, type, w, h){
	var checkWin=(navigator.appVersion.indexOf("Win")!=-1)? true : false;
	var checkIE=(navigator.appVersion.indexOf("MSIE")!=-1)? true : false;
	if(type == 'fullscreen'){
		if(checkWin&&checkIE){
			var theWidth = screen.width;
			var theHeight = screen.height;
			var popWin = window.open(url,winName,'width='+theWidth+',height='+ theHeight +',left=0,top=0,toolbar=no,directories=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no,statusbar = yes');
		}else{
			var theWidth = screen.availWidth;
			var theHeight = screen.availHeight;
			var popWin = window.open(url,winName,'width='+theWidth+',height='+ theHeight +',left=0,screenX=0,top=0,screenY=0,toolbar=no,directories=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no,statusbar = yes');
			popWin.moveTo(0,0);
			popWin.resizeTo(theWidth,theHeight);
		}
		popWin.focus();
	}else{
		var theWidth = w;
		var theHeight = h;
		if(checkWin&&checkIE){
			var xPoin = screen.width/2 - theWidth/2;
			var yPoin = screen.height/2 - theHeight/2;
			var popWin = window.open(url,winName,'width='+theWidth+',height='+ theHeight +',left='+ xPoin +',top='+ yPoin +',toolbar=no,directories=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=0');
		}else{
			var xPoin = screen.availWidth/2 - theWidth/2;
			var yPoin = screen.availHeight/2 - theHeight/2;
			var popWin = window.open(url,winName,'width='+theWidth+',height='+ theHeight +',left='+ xPoin +',top='+ yPoin +',toolbar=no,directories=no,location=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no');
			popWin.moveTo(xPoin,yPoin);
		}
		popWin.focus();
	}
}


/*  ================================Smart Scroll================================  */

/*  ================================================================================
Set Up Object
================================================================================  */
bAgent = navigator.userAgent;
bName = navigator.appName;
bPlugins = navigator.plugins;

w = window;
s = w.screen;
d = document;

usrUrl = location.href;

function sniffer(){
/* OS */
	this.Win = bAgent.indexOf("Win",0) != -1 ? 1 : 0;
	this.WinVista = bAgent.indexOf("Windows NT 6.0",0) != -1 ? 1 : 0;
	this.Mac = bAgent.indexOf("Mac",0) != -1 ? 1 : 0;
	this.MacOSX = ((bAgent.indexOf("Mozilla") != -1) && (bAgent.indexOf("Mac OS X") != -1)) ? 1 : 0;
	if(bPlugins){for(i = 0 ;i < bPlugins.length;i++){if(this.Mac && (bPlugins[i].filename.indexOf("QuickTime Plugin.plugin") != -1)){this.MacOSX = true;}}}

/* Browser */
	this.IE        = ((bAgent.indexOf("MSIE") != -1) && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.NS        = ((bName == "Netscape") && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.NC        = ((bName == "Netscape") && (bAgent.indexOf("Gecko") == -1) && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.Gecko     = (bAgent.indexOf("Gecko") != -1) ? 1 : 0;
	this.Moz       = ((bAgent.indexOf("Gecko") != -1) && (bAgent.indexOf("Safari",0) == -1)) ? 1 : 0;
	this.OPERA     = bAgent.indexOf("Opera",0) != -1 ? 1 : 0;
	this.Firefox   = (bAgent.indexOf("Firefox") != -1) ? 1 : 0;
	this.SAFARI    = bAgent.indexOf("Safari",0) != -1 ? 1 : 0;
	this.ICAB      = bAgent.indexOf("iCab",0) != -1 ? 1 : 0;

/* Object */
/* SAFARI,Firefox,NS6+,OPERA6=4, IE5+,OPERA5,7+=3, IE4=2, NS4=1, others=0 */
	this.checkObj      = d.all ? (d.getElementById ? 3 : 2) : (d.getElementById ? 4 : (d.layers ? 1 : 0));
	this.checkObj4     = (d.getElementById && !d.all) ? 1 : 0;
	this.checkObj3     = (d.getElementById && d.all) ? 1 : 0;
	this.checkObj2     = (d.all && !d.getElementById) ? 1 : 0;
	this.checkObj1     = d.layers ? 1 : 0;
	this.allObj        = ((this.checkObj == 3) || (this.checkObj == 4));

/* Compat Mode */
	this.modeStandard  = d.compatMode == "CSS1Compat" ? 1 : 0;
	this.modeQuirks    = d.compatMode == "BackCompat" ? 1 : 0;

/* Each Browser */
	this.IE5           = (this.Win && this.IE && (bAgent.indexOf('MSIE 5.',0) != -1));
	this.IE55          = (this.Win && this.IE && (bAgent.indexOf('MSIE 5.5.',0) != -1));
	this.IE55later     = (this.Win && this.IE && (w.createPopup != -1));
	this.IE6           = (this.Win && this.IE && (bAgent.indexOf('MSIE 6.',0) != -1));
	this.IE6below      = (this.IE5 && this.IE55 && this.IE6);
	this.IE7           = (this.Win && this.IE && (bAgent.indexOf('MSIE 7.',0) != -1));

	this.WinIEs        = (this.Win && this.IE && this.modeStandard);
	this.WinIEq        = (this.Win && this.IE && this.modeQuirks);

	this.MacFirefox    = (this.Mac && this.Firefox);
	this.MacOPERA      = (this.Mac && this.OPERA);

	return this;
}
var usr = new sniffer;


/*  ================================================================================
Get Attribute
================================================================================  */
function setObj(idName){
	return d.getElementById ? d.getElementById(idName) : d.all(idName);
}

function getScreenSize(type){
	if(type == "width"){
		if(usr.allObj){
			return(s.width);
		}
	}else if(type == "height"){
		if(usr.allObj){
			return(s.height);
		}
	}
}

function getBrowseSize(type){
	if(type == "width"){
		if(w.innerWidth){
			return(w.innerWidth);
		}else if(usr.modeStandard && d.documentElement.clientWidth){
			return(d.documentElement.clientWidth);
		}else{
			return(d.body.clientWidth);
		}
	}else if(type == "height"){
		if(w.innerHeight){
			return(w.innerHeight);
		}else if(usr.modeStandard && d.documentElement.clientHeight){
			return(d.documentElement.clientHeight);
		}else{
			return(d.body.clientHeight);
		}
	}
}

function getBodySize(type){
	if(type == "width"){
		if(usr.allObj){
			return(d.body.scrollWidth);
		}
	}else if(type == "height"){
		if(usr.allObj){
			return(d.body.scrollHeight);
		}
	}
}

function getDocumentSize(type){
	if(type == "width"){
		if(usr.allObj){
			return(d.getElementById('allDocument').offsetWidth);
		}
	}else if(type == "height"){
		if(usr.allObj){
			return(d.getElementById('allDocument').offsetHeight);
		}
	}
}

function getWindowOffset(type){
	if(type == "x"){
		if(usr.SAFARI){
			return(window.pageXOffset);
		}else if((usr.checkObj == 3) && (!usr.WinIEs)){
			return(d.body.scrollLeft);
		}else if((usr.checkObj == 4) || (usr.WinIEs)){
			return(d.body.parentNode.scrollLeft);
		}
	}else if(type == "y"){
		if(usr.SAFARI){
			return(window.pageYOffset);
		}else if((usr.checkObj == 3) && (!usr.WinIEs)){
			return(d.body.scrollTop);
		}else if((usr.checkObj == 4) || (usr.WinIEs)){
			return(d.body.parentNode.scrollTop);
		}
	}
}

function getScrollRange(type){
	if(type == "x"){
		if(usr.allObj){
			return (getDocumentSize('width') - getBrowseSize('width'));
		}
	}else if(type == "y"){
		if(usr.allObj){
			return (getDocumentSize('height') - getBrowseSize('height'));
		}
	}
}

function getElementPosition(type,idName){
	var obj = setObj(idName);
	var tagCoords = new Object();
	if(type == "left"){
		if(usr.allObj){
			tagCoords.x = obj.offsetLeft;
			while((obj = obj.offsetParent) != null){
				tagCoords.x += obj.offsetLeft;
			}
		}if((tagCoords.x * 0) == 0){
			return(tagCoords.x);
		}else{
			return(idName);
		}
	}else if(type == "top"){
		if(usr.allObj){
			tagCoords.y = obj.offsetTop;
			while((obj = obj.offsetParent) != null){
				tagCoords.y += obj.offsetTop;
			}
		}if((tagCoords.y * 0) == 0){
			if(usr.Mac && usr.SAFARI){		// temp
				return(tagCoords.y + 0);
			}else{
				return(tagCoords.y);
			}
		}else{
			return(idName);
		}
	}
}

function getElementSize(type,idName){
	if(type == "width"){
		if(usr.allObj){
			return(d.getElementById(idName).clientWidth);
		}
	}else if(type == "height"){
		if(usr.allObj){
			return(d.getElementById(idName).clientHeight);
		}
	}
}


/*  ================================================================================
Page Scroller
================================================================================  */
var pageScrollTimer;
function pageScroll(toX,toY,frms,frX,frY){
	if(pageScrollTimer)clearTimeout(pageScrollTimer);
	var spd = usr.Mac?14:16;
	var actX = getWindowOffset('x');
	var actY = getWindowOffset('y');
	if(!toX || toX < 0)toX = 0;
	if(!toY || toY < 0)toY = 0;
	//if(!frms)frms = (usr.Mac && (usr.OPERA || usr.NS6)) ? 3 : usr.NS6 ? 4 : usr.NS ? 7 : 5;
	if(!frms)frms = (usr.Win&&usr.SAFARI)?6:(usr.Mac&&(usr.OPERA||usr.NS6))?3:usr.NS6?4:usr.NS?7:5;
	if(!frX)frX = 0 + actX;
	if(!frY)frY = 0 + actY;

	frX += (toX - actX) / frms;
	if(frX < 0)frX = 0;
	frY += (toY - actY) / frms;
	if(frY < 0)frY = 0;
	var posX = Math.ceil(frX);
	var posY = Math.ceil(frY);
	w.scrollTo(posX, posY);
	if((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY-toY)) < 1)){
		clearTimeout(pageScrollTimer);
		w.scroll(toX,toY);
	}else if((posX != toX) || (posY != toY)){
		pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
	}else{
		clearTimeout(pageScrollTimer);
	}
}

function toAnchor(idName,longitudinalAdj,traverser){
	if(usr.allObj){
		if(!!idName){
			var anchorX = traverser ? getElementPosition('left',idName) : 0;
			var anchorY = longitudinalAdj ? getElementPosition('top',idName) - longitudinalAdj : getElementPosition('top',idName) - 0;
			var dMaxX = getScrollRange('x');
			var dMaxY = getScrollRange('y');
			if(((anchorX*0) == 0) || ((anchorY*0) == 0)){
				var setX = (anchorX < 1) ? 0 : (anchorX > dMaxX) ? dMaxX : anchorX;
				var setY = (anchorY < 1) ? 0 : (anchorY > dMaxY) ? dMaxY : anchorY;
				pageScroll(setX,setY);
			}else{
				location.hash = idName;
			}
		}else{
			pageScroll(0,0);
		}
	}else{
		!!idName ? location.hash = idName : location.hash = "top";
	}
}

var checkAnchor = usrUrl.indexOf("#",0);
var checkPageScroller = usrUrl.match("pSc");
function initializePage(){
	if(!!checkPageScroller){
		anchorId = usrUrl.substring(usrUrl.lastIndexOf("?pSc")+4,usrUrl.length);
		timerID=setTimeout("toAnchor(anchorId,13)",400);
	}
	if(!checkAnchor){
		window.scroll(0,0);
	}else return true;
}


/*  ================================================================================
Setup Attribute
================================================================================  */
function initializeScript(){
	screenSizeWidth     = getScreenSize('width');
	screenSizeHeight    = getScreenSize('height');
	browseSizeWidth     = getBrowseSize('width');
	browseSizeHeight    = getBrowseSize('height');
	bodySizeWidth       = getBodySize('width');
	bodySizeHeight      = getBodySize('height');
	documentSizeWidth   = getDocumentSize('width');
	documentSizeHeight  = getDocumentSize('height');
	windowOffsetX       = getWindowOffset('x');
	windowOffsetY       = getWindowOffset('y');
	scrollRangeX        = getScrollRange('x');
	scrollRangeY        = getScrollRange('y');
}

window.onload = function(e){
	if(usr.allObj)initializeScript();
}
window.onresize = function(e){
	if(usr.allObj)initializeScript();
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
