﻿// JScript File
//YUI short names
var _YUE = YAHOO.util.Event;
var _YUD = YAHOO.util.Dom;

function OpenNewWindow(url,w,h){
	popup = window.open(url,"popup1","width=" +h +",height=" + w + ",top=30,left=30,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,screenX=200,screenY=200");
	// URL of popup window
	popup.location.href = url;
	if (popup.opener == null) popup.opener = window;
}

var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1),isChrome=((ua.indexOf("applewebkit") != -1) && (ua.indexOf("chrome") != -1));
function ShowDiv(El, attrib, hide){
	var ydom = YAHOO.util.Dom;
//	var ifr = document.getElementById('ifr' +El);
//	if(ifr == null){
//		ifr = document.createElement('iframe');
//		ifr.id = 'ifr' +El;
//		ifr.style.position = 'absolute';
//		ifr.src = '/common/dummy.html';
//		ifr.frameborder = '0';
//		ifr.style.visibility = "visible";
//		ydom.setX(ifr,ydom.getX(El));
//		ydom.setY(ifr,ydom.getY(El));
//		ydom.setStyle([ifr],'height',ydom.getStyle([El],'height'));
//	}
	
	if(!hide){  
		if(attrib == null){
			attrib = {
				width: { to: 250 }, 
				height: { to: 400 }
			};
		}			
		ydom.get(El).style.visibility = "visible";
		//var aniFrmSearch = new Y.Anim(ifr, attrib, 0.5, Y.Easing.backOut);
		//aniFrmSearch.animate();
		var aniDivSearch = new Y.Anim(El, attrib, 0.5, Y.Easing.backOut);
		aniDivSearch.animate();
	}
	else{
		if(attrib == null){
			attrib = {
				width: { to: 2 }, 
				height: { to: 2 }
			};
		}

		//var aniFrmSearch = new Y.Anim(ifr, attrib, 0.5, Y.Easing.backIn);
		//aniFrmSearch.animate();

		var aniDivSearch = new Y.Anim(El, attrib, 0.5, Y.Easing.backIn);
		aniDivSearch.animate();	
		
		ydom.get(El).style.visibility = "hidden";		
	}
}

//Create Cookie, if days is 0, cookie expired when browser closes, if negative, cookie is erased immediately
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function ToggleSeeThruItems(Visibility)
{
    try
    {
        var Count = 0;
        if(Visibility == "hidden")
        {
            for(i=0; i<this.Forms[0].elements.length; i++)
            {
                try
                {
                    if(this.Forms[0].elements[i].type.indexOf("select") >= 0 && this.Forms[0].elements[i].id.indexOf("InPageRegDiv") < 0 && this.Forms[0].elements[i].style.visibility != "hidden")
                    {
                        this.Forms[0].elements[i].style.visibility = Visibility;
                        this.Forms[0][Count] =  this.Forms[0].elements[i];
                        Count++;
                    }
                }
                catch(e)
                {} 
            }
        }
        else
        {
//            for(i=0;i<HiddenItem.length; i++)
//            {
//                HiddenItem[i].style.visibility = Visibility;
//            }
//            HiddenItem.length = 0;
        }
    }
    catch(ex)
    {
    } 
}
	  
function SwapBackground(obj,imgUrl){
    obj.style.backgroundImage = 'url(' +imgUrl +')';
}

function SwapImgSrc(obj,imgUrl){
    obj.src = imgUrl;
}

function GetBlackDivHeight()
{
    var InPageDivObj = document.getElementById("InPageDiv1");
    if(InPageDivObj.style.height < 100)
    {
        InPageDivObj.style.height = _YUD.getDocumentScrollTop() + _YUD.getViewportHeight();
        if(document.body.clientWidth < 800)
            InPageDivObj.style.width = 800 +'px';
        else
            InPageDivObj.style.width =  document.body.clientWidth +'px';
     }
}

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_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) { //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 ShowInPagePopup(Popup,bShow)
{		
    GetBlackDivHeight();
    var scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        //Netscape compliant
        scrOfY = window.pageYOffset;
    } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        //DOM compliant
        scrOfY = document.body.scrollTop;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
    {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
    }
    
    var oPopup = document.getElementById(Popup);
    oPopup.style.top = scrOfY + 100 +'px';
    oPopup.style.display = "none";
    if(!bShow){
		document.getElementById("InPageDiv1").style.display = "none";
        ToggleSeeThruItems("visible");
    }
    else
    {
		document.getElementById("InPageDiv1").style.display = "block";
		ToggleSeeThruItems("hidden");
        oPopup.style.display = "block";
    }              
}

function OnResize()
	{
	   var InPageDivObj = document.getElementById("InPageDiv1");
	   if(InPageDivObj != null){
	       if(document.body.clientWidth < 800)
	            InPageDivObj.style.width = 800;
	       else
	            InPageDivObj.style.width = document.body.clientWidth;
	   }
	}
	
function OnWinLoad()
{
    try
    {        
        GetBlackDivHeight();
    }catch(ex){}
}

function cancelBubbleEvent(ev)
{
    var e =window.event||ev;
    if (window.event)
    {
        keynum = window.event.keyCode;
        obj = window.event.srcElement;
    }
    else if (e.which)
    {
        keynum = e.which;
        obj = e.target;
    }
    if (keynum == 13)   //enter key
    {
        e.cancelBubble = true;
        return false;
    }
    return true;
}

function exeFunction(ev, sFunc)
{
    var keynum = 0;
    var obj;
    var e =window.event||ev;
    if (window.event)
    {
        keynum = window.event.keyCode;
        obj = window.event.srcElement;
    }
    else if (e.which)
    {
        keynum = e.which;
        obj = e.target;
    }
    if (keynum == 13)
    {
        document.forms[0].hidFunction.value = sFunc;
        e.cancelBubble = true;
        document.forms[0].submit();
        return false;
    }
    return true;
}  

function ResumeDemo(Demo,bResume){
	var swf = document.getElementById(Demo);
	if(bResume)
		swf.SetVariable('cpSkinLoader_mc.rdcmndResume',1);
	else
		swf.SetVariable('cpSkinLoader_mc.rdcmndPause',1);
}

function MoveBackground(el,xy){
	el.style.backgroundPosition = xy;
}

//--------------------------------------- functions that run now
if(isIE){
    window.attachEvent("onload",OnWinLoad);
    window.attachEvent("onresize",OnResize);
}else{
    window.addEventListener("onload",OnWinLoad,true);
    window.addEventListener("onresize",OnResize,true)
}