var isCO = 'false';
var Constants = {
 isIE : navigator.appName.toLowerCase().indexOf("explorer") > -1,
 isMoz : !this.isIE,
 mode : "prod"
};
//Gives 100% height to the inner_content
function setContentHeight(){
 var windowHeight = getWindowHeight();
 var contentHeight = getInnerContent().offsetHeight;
 if (contentHeight < windowHeight){
 getInnerContent().style.height = windowHeight - 180 + "px";
 }
}

function getWindowHeight(){
 windowHeight = (document.all) ? document.documentElement.offsetHeight-4 : document.documentElement.scrollHeight;
 return windowHeight;
}

function getInnerContent(){
 try{
 return document.getElementById("inner_content");
 }
 catch(err){
 var divs = document.getElementsByTagName("div");
 for (i=0; i<divs.length; i++){
 if (divs[i].className=="inner_content")
 return divs[i];
 }
 }
}
 
//Clears predefined text from textfield
function clearText(element, value){
 if (element.value==value){//If the value of the textfield equals the predefined text
 element.value="";//Clear the textfield
 }
} 
 
//Fills predefined text into textfield
function fillText(element, value){
 if (element.value==""){//If the value of the textfield is empty
 element.value=value;//Fill the textfield
 }
}
 
// getting text from node depends on browser
function getTextFromNode(node)
{
 if(Constants.isIE)
 {
 return node.text;
 }
 else if (Constants.isMoz)
 {
 return node.childNodes[0].nodeValue;
 }
}
 
function isNullOrUndefined(obj)
{
 try
 {
 return ((obj==null) || (obj==undefined) || (typeof(obj)=="undefined"));
 }
 catch(e)
 {
 return true;
 } 
}
 
function notNullOrUndefined(obj)
{
 return !isNullOrUndefined(obj);
}
 
function nvl(strObj, alternate)
{
 if (isNullOrUndefined(strObj))
 {
 return alternate;
 }
 else
 {
 return strObj;
 }
}
/* mock up functions */
/* Generel Loading Functions */
function drawEllipsis() {
 var ellipsisObj = document.getElementsByName('ellipsis');
 for (var i=0; i<ellipsisObj.length; i++) {
 handleEllipsis(ellipsisObj[i]);
 }
}
 
function drawButtons() {
 var buttonObj = document.getElementsByName('button');
 for (var i=0; i<buttonObj.length; i++) {
 buttonObj[i].onmouseover = function() { 
 this.style.backgroundImage = (document.all) ? this.currentStyle.backgroundImage.replace('.gif', '_over.gif') : window.getComputedStyle(this, null).backgroundImage.replace('.gif', '_over.gif');
 };
 
 buttonObj[i].onmouseout = function() {
 this.style.backgroundImage = (document.all) ? this.currentStyle.backgroundImage.replace('_over.gif', '.gif') : window.getComputedStyle(this, null).backgroundImage.replace('_over.gif', '.gif');
 };
 
 buttonObj[i].onmousedown = function() {
 this.style.backgroundImage = (document.all) ? this.currentStyle.backgroundImage.replace('_over.gif', '_press.gif') : window.getComputedStyle(this, null).backgroundImage.replace('_over.gif', '_press.gif');
 };
 
 buttonObj[i].onmouseup = function() {
 this.style.backgroundImage = (document.all) ? this.currentStyle.backgroundImage.replace('_press.gif', '_over.gif') : window.getComputedStyle(this, null).backgroundImage.replace('_press.gif', '_over.gif');
 };
 }
}
function hidePopups() {
 var popupsObj = document.getElementById('popups');
 for (var i=0; i<popupsObj.childNodes.length; i++) {
 if (popupsObj.childNodes[i].tagName == "DIV") {
 popupsObj.childNodes[i].style.display = 'none';
 } 
 }
}
 
function toggleSeeAllLink(elementCount){
 var seeAllLink = document.getElementById("seeAllLink"+elementCount);
 if (seeAllLink.innerHTML == '...')
 {
 seeAllLink.innerHTML = "See more...";
 }
 else
 {
 seeAllLink.innerHTML = "...";
 }
}
 
function handleEllipsis(ellipsisObj) {
 return;
 var objWidth = (document.all) ? parseInt(ellipsisObj.currentStyle.width) : parseInt(window.getComputedStyle(ellipsisObj, null).width);
 var objHeight = (document.all) ? parseInt(ellipsisObj.currentStyle.height) : parseInt(window.getComputedStyle(ellipsisObj, null).height);
 
 if (ellipsisObj.className.indexOf("2line") != -1 ||
 ellipsisObj.className.indexOf("3line") != -1) {
 var condition = ellipsisObj.scrollWidth > objWidth || ellipsisObj.scrollHeight > objHeight;
 } else {
 var condition = ellipsisObj.scrollWidth > objWidth;
 }
 if (condition) {
 var left = ellipsisObj.offsetWidth-10+'px';
 
 var ellipsisTypes = new Array();
 ellipsisTypes['nowPlaying'] = 'left:'+left+'; background-color:#C1DAFD;';
 ellipsisTypes['related'] = 'left:'+left+'; background-color:#F5F4F0;';
 ellipsisTypes['related2Lines'] = 'left:'+left+'; background-color:#F5F4F0; padding-top:16px;';
 ellipsisTypes['thumbnail'] = 'left:'+left+'; background-color:#FFFFFF; padding-top:4px;';
 ellipsisTypes['credits'] = 'left:'+left+'; background-color:#FFFFFF;';
 ellipsisTypes['blowupTitle'] = 'left:'+left+'; background-color:#BAD6FD;';
 ellipsisTypes['blowup2Lines'] = 'left:'+left+'; background-color:#FFFFFF; padding-top:16px;';
 ellipsisTypes['blowup'] = 'left:'+left+'; background-color:#FFFFFF;';
 ellipsisTypes['blowupHits'] = 'left:'+left+'; background-color:#FFFFFF;';
 ellipsisTypes['commentTitle'] = 'left:'+left+'; background-color:#EBE7DF;';
 ellipsisTypes['flagTitle'] = 'left:'+left+'; background-color:#F2F1EC; padding-top:1px;';
 ellipsisTypes['winners'] = 'left:'+left+'; background-color:#FFF8DE;';
 ellipsisTypes['leftSlider'] = 'left:'+left+'; background-color:#E9F2FE; padding-top:14px;';
 
 ellipsisTypes['default'] = 'left:'+left+'; background-color:#FFFFFF;';
 
 // Show Ellipsis Dots
 var div = document.createElement("div");
 div.className = "ellipsis_dots";
 div.innerHTML = "...";
 
 div.style.cssText = (ellipsisObj.attributes["ellipsisType"] == undefined) ? ellipsisTypes['default'] : ellipsisTypes[ellipsisObj.attributes["ellipsisType"].value];
 ellipsisObj.className += ' ellipsis';
 ellipsisObj.appendChild(div);
 
 // Show Ellipsis Baloon
 ellipsisObj.onmouseover = function() {
 if (this.textContent) {
 var titleText = this.textContent.substring(0, this.textContent.length-3);
 } else {
 var titleText = this.innerText.substring(0, this.innerText.length-3);
 }
 this.title = titleText;
 };
 
 ellipsisObj.onmouseout = function() {
 };
 }
}
 
//Clears predefined text from textfield
function clearText(element, value){
 if (element.value==value){//If the value of the textfield equals the predefined text
 element.value="";//Clear the textfield
 }
}
 
//Fills predefined text into textfield
function fillText(element, value){
 if (element.value==""){//If the value of the textfield is empty
 element.value=value;//Fill the textfield
 }
}
 
//Rename a sets name
function renameSet(setTopID, action){//gets the wrapping box's ID and the action requested ("start"/"end")
 var setTop = document.getElementById(setTopID);//gets the wrapping element
 
 //takes all the A elements and sets them into variables
 var setTopAnchors = setTop.getElementsByTagName("A");
 for (i=0; i<setTopAnchors.length; i++){
 if (setTopAnchors[i].className=="lnk_animation_name"){
 var lnk_animation_name = setTopAnchors[i];
 var em = lnk_animation_name.getElementsByTagName("EM")[0];
 }
 if (setTopAnchors[i].className=="lnk_rename")
 var lnk_rename = setTopAnchors[i];
 if (setTopAnchors[i].className=="lnk_delete")
 var lnk_delete = setTopAnchors[i];
 }
 
 //takes all the INPUT elements and sets them into variables
 var setTopInputs = setTop.getElementsByTagName("INPUT");
 for (i=0; i<setTopInputs.length; i++){
 if (setTopInputs[i].className=="input_animation_name")
 var input_animation_name = setTopInputs[i];
 }
 
 if (action=="start"){//("Rename" was pressed)
 
 setTop.className = returnAttr(setTop.className, "normal", "edit");//Changes "min_box_top normal" to "min_box_top edit"
 input_animation_name.focus();//focus's on it
 }
 else{ //action=="end" ("Save was pressed")
 setTop.className = returnAttr(setTop.className, "normal", "edit");//Changes "min_box_top edit" to "min_box_top normal"
 lnk_animation_name.innerHTML = input_animation_name.value;//Sets the value of the title to whatever was inserted in the textfield
 // update the db
 updateText = input_animation_name.value;
 // take the first 20 letters
 updateText = updateText.substring(0,20);
 // save the new name in the db
 updateSetID = setTop.id.split("_")[4];
 var urlUpdate = appPathScript+ "/Pages/Application/Animations/QuickServices.aspx";
 
 params = "action=updatesetname&setID="+updateSetID+
 "&setName="+updateText+"&setType="+mode;
 AJAX.asyncWithCallback(urlUpdate, params, "", true, false) ;
 } 
}
 
//Replaces an elements attribute with another
function returnAttr(attribute, value1, value2){
 if (attribute.indexOf(value1)!=-1)//If the attribute value already has value1 in it
 return attribute.replace(value1, value2);//exchange them
 else//If the attribute value does not have value1 in it (meaning it has value2)
 return attribute.replace(value2, value1);//exchange them
}
 
//Toggles btn_expand_all's label ("Expand all"/"Collapse all") 
function toggleExpandAllButton(wrapperID){
 var wrapper = document.getElementById(wrapperID);//sets the element
 var divs = wrapper.getElementsByTagName("DIV");//Takes all the DIV elements 
 var minimizedFlag = false;
 for (i=0; i<divs.length; i++){//Runs through them
 if (divs[i].className.indexOf("minimized")!=-1){//If the element class name has "minimized" in it
 minimizedFlag = true;
 }
 }
 var hrefs = wrapper.getElementsByTagName("A");
 for (i=0; i<hrefs.length; i++){//Runs through them
 if (hrefs[i].className=="btn_expand_all"){
 var btn_expand_all = hrefs[i];
 }
 }
 if (minimizedFlag != true)
 btn_expand_all.innerHTML = "Collapse all";
 else
 btn_expand_all.innerHTML = "Expand all";
}
 
//Expands/collapse all sets within an element
function toggleAllSets(wrapperID , btn){
 btn = document.getElementById(btn);
 var wrapper = document.getElementById(wrapperID);//sets the element
 var divs = wrapper.getElementsByTagName("DIV");//Takes all the DIV elements
 for (i=0; i<divs.length; i++){//Runs through them
 if (divs[i].className.indexOf(returnAction(btn))!=-1){//If the element class name has "minimized" in it
 elementCount = divs[i].id.split("_")[3];//Takes the number at the end of its ID (e.g. mini_box_3)
 var insideDivs = divs[i].getElementsByTagName("DIV");//Takes all it's divs
 for (j=0; j<insideDivs.length; j++){//Runs through them
 if (insideDivs[j].className=="minimizable_box_bottom"){//If the element class name is "minimizable_box_bottom"
 effect("toggle", wrapperID, elementCount);//Expand it
 } 
 }
 }
 }
}
 
//Meant to serve toggleAllSets function
//Depending on the btn_expand_all label ("Expand all"/"Collapse all") it returns a string ("expanded"/"minimized")
function returnAction(button){
 if (button.innerHTML == "Collapse all")
 {
 return "expanded";
 }
 else
 {
 return "minimized";
 }
}
 
//Creates an effect. Taken from script.aculo.us
function effect(effect, wrapperId, elementCount, noExpandAll){
 switch (effect){//toggle/blindDown/Appear...
 case "toggle":
 switch (wrapperId){
 case "categories_box":
 var mini_box = 'mini_movies_box_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 var mini_box_bottom = 'mini_movies_box_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box_top = 'mini_movies_box_top_'+elementCount;
 mini_box_top = document.getElementById(mini_box_top);//Sets the wrapper element in order to give it a border
 
 //Blinds up/down then toggles className 
 new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() 
 {
 mini_box.className = returnAttr(mini_box.className, "minimized", "expanded");
 }
 }
 );
 break; 
 case "movies_box1":
 var mini_box = 'mini_movies_box_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 var mini_box_bottom = 'mini_movies_box_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box_top = 'mini_movies_box_top_'+elementCount; mini_box_top = document.getElementById(mini_box_top);//Sets the wrapper element in order to give it a border
 
 //Blinds up/down then toggles className
 new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() {mini_box.className = returnAttr(mini_box.className, "minimized", "expanded");toggleExpandAllButton(wrapperId)}});
 break;
 case "favorites_box1":
 var mini_box = 'mini_favorites_box_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 var mini_box_bottom = 'mini_favorites_box_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box_top = 'mini_favorites_box_top_'+elementCount; mini_box_top = document.getElementById(mini_box_top);//Sets the wrapper element in order to give it a border
 
 //Blinds up/down then toggles className
 new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() {mini_box.className = returnAttr(mini_box.className, "minimized", "expanded");toggleExpandAllButton(wrapperId)}});
 break;
 case "box3":
 var mini_box_bottom = 'mini_box3_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box = 'mini_box3_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 //Hides the red tooltip or else it stays in place and looks unproffesional
 try{
 hideTooltip();
 }
 catch(err){}
 new Effect.toggle(mini_box_bottom,'blind');
 mini_box.className = returnAttr(mini_box.className, "minimized", "expanded");
 break;
 case "box3 contest":
 var mini_box_bottom = 'mini_box3_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box = 'mini_box3_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 
 new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() {mini_box.className = returnAttr(mini_box.className, "minimized", "expanded")}});
 break;
 case "box4":
 var mini_box_bottom = 'mini_box4_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box = 'mini_box4_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 hideTooltip();//Hides the red tooltip or else it stays in place and looks unproffesional
 
					new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() {mini_box.className = returnAttr(mini_box.className, "minimized", "expanded")}});
 break;
 case "box31":
 var mini_box_bottom = 'mini_box31_bottom_'+elementCount;//Sets the ID of the "mini_box_bottom" that the effect will work on
 var mini_box = 'mini_box31_'+elementCount; mini_box = document.getElementById(mini_box);//Sets the wrapper element in order to switch its class name
 hideTooltip();//Hides the red tooltip or else it stays in place and looks unproffesional
 
 //Blinds up/down then toggles className
 new Effect.toggle(mini_box_bottom, 'blind', {duration:0.2, afterFinish: function() {mini_box.className = returnAttr(mini_box.className, "minimized", "expanded")}});
 break;
 
 }
 break;
 }
}
 
/*trying to replace function effect() with a generic function, without switch:case*/
function effect_generic(effect, box_to_effect, effect_button_parent){
 switch (effect){//toggle/blindDown/Appear...
 case "toggle":
 //Blinds up/down then toggles className
 new Effect.toggle(box_to_effect, 'blind', {duration:0.2, afterFinish: function() {effect_button_parent.className = returnAttr(effect_button_parent.className, "minimized", "expanded")}});
 
 break;
 }
}
/* TOOLTIP **************************************************************************/
/************************************************************************************/
 
/**/function enableTooltip(wrapperID){
/**/ var links,i,h;
/**/ if(!document.getElementById || !document.getElementsByTagName) return;
/**/ h=document.createElement("span");
/**/ h.id="btc";
/**/ h.setAttribute("id","btc");
/**/ h.style.position="absolute";
/**/ h.style.zIndex=100;
/**/ document.getElementsByTagName("body")[0].appendChild(h);
/**/ if(wrapperID==null) links=document.getElementsByTagName("a");
/**/ else links=document.getElementById(wrapperID).getElementsByTagName("a");
/**/ for(i=0;i<links.length;i++){
/**/ if (links[i].className=="lnk_tooltip")
/**/ Prepare(links[i]);
/**/ }
/**/}
/**/ 
/**/function Prepare(el){
/**/ var tooltip,b,s,l,close,clearer;
/**/ el.removeAttribute("href");
/**/ tooltip=CreateEl("span","tooltip");
/**/ s=CreateEl("SPAN","tooltip_top");
/**/ tooltip.appendChild(s);
/**/ l=CreateEl("SPAN","tooltip_content");
/**/ l.innerHTML="The movie has been uploaded to our servers and is being encoded. This may take a while.<br /> In the meantime you can watch other movies or do whatever you want to.";
/**/ tooltip.appendChild(l);
/**/ b=CreateEl("SPAN","tooltip_bottom");
/**/ tooltip.appendChild(b);
/**/
/**/ el.tooltip=tooltip;
/**/ el.onclick=showTooltip;
/**/ tooltip.onclick=hideTooltip;
/**/}
/**/
/**/function showTooltip(e){
/**/ var toolTipsArray = document.getElementsByTagName("span");
/**/ for(i=0;i<toolTipsArray.length;i++){
/**/ if (toolTipsArray[i].id=="btc"){
/**/ if(toolTipsArray[i].childNodes.length>0) toolTipsArray[i].removeChild(toolTipsArray[i].firstChild);
/**/ }
/**/ }
/**/ document.getElementById("btc").appendChild(this.tooltip);
/**/ Locate(e);
/**/}
/**/
/**/function hideTooltip(e){
/**/ var d=document.getElementById("btc");
/**/ if(d.childNodes.length>0) d.removeChild(d.firstChild); 
/**/}
/**/
/**/function CreateEl(t,c){
/**/ var x=document.createElement(t);
/**/ x.className=c;
/**/ x.style.display="block";
/**/ return(x);
/**/}
/**/function Locate(e){
/**/ var posx=0,posy=0;
/**/ if(e==null) e=window.event;
/**/ if(e.pageX || e.pageY){
/**/ posx=e.pageX; posy=e.pageY;
/**/ }
/**/ else if(e.clientX || e.clientY){
/**/ if(document.documentElement.scrollTop){
/**/ posx=e.clientX+document.documentElement.scrollLeft;
/**/ posy=e.clientY+document.documentElement.scrollTop;
/**/ }
/**/ else{
/**/ posx=e.clientX+document.body.scrollLeft;
/**/ posy=e.clientY+document.body.scrollTop;
/**/ }
/**/ }
/**/ document.getElementById("btc").style.top=(posy-100)+"px";
/**/ document.getElementById("btc").style.left=(posx+10)+"px";
/**/}
/**/
/* TOOLTIP END **************************************************************************/
/************************************************************************************/
 
function deleteSet(setID)
{
 alert("Not Implemented");
}
 
function showPopup(content)
{
 showPopupExt(content,"2");
}
 
function showPopupSubmitMovie(content)
{
 showPopupExt(content,"1");
}
/* BLOCKER and POPUP */
/* this function is being invoked when the delete animation is called */

function toggleSWF(frame)
{
    var swfDiv = document.getElementById(frame);
    if(swfDiv.style.textIndent == "-9000px")
    {
	    swfDiv.style.textIndent = "0px";
    }
    else
    {
        swfDiv.style.textIndent = "0px";
    }
}
    
function showPopupExt(content,noScrollBar)
{
    try
    {
        if ($('ctl00_ContentPlaceHolder1_PlayerFrame') != null) { toggleSWF('ctl00_ContentPlaceHolder1_PlayerFrame'); }
        if ($('dvGigya') != null) { toggleSWF('dvGigya'); }
        if ($('thePlayerFrame') != null) { toggleSWF('thePlayerFrame'); }
        if ($('shapeshifterswf') != null) { toggleSWF('shapeshifterswf'); }
    }
    catch(err) {}
 
    if (noScrollBar == "1") { document.body.scroll = "no"; }
    containerHeight = (document.all) ? document.documentElement.offsetHeight-4 : document.documentElement.scrollHeight;

    bodyHeight = window.document.body.offsetHeight;

    currentHeight = 0;
 
    if (containerHeight < bodyHeight)
    {
        currentHeight = bodyHeight;
    }
    else 
    {
        currentHeight = containerHeight;
    }

    currentHeight = document.body.scrollHeight;// yosi-update

    document.getElementById("blocker").style.height = currentHeight + "px";
    //document.getElementById("blocker").style.height = "3000px";

     toggleBlocker("show", content); 
}
 
 
 
function createAniboomPopup(content){
 content = document.getElementById(content); 
 content.style.display = '';
 var width=content.style.width;
 width = width.replace("px","");
 width = width-0+10+10;//adding the 10px borders from both sides
 
 var clear=document.createElement("div");
 clear.className="clear";
 
 var pw = document.createElement("div");
 pw.setAttribute("id","popup_wrapper");
 document.getElementsByTagName("body")[0].appendChild(pw);
 
 var p=document.createElement("div");
 p.setAttribute("id","popup");
 p.style.width=width + "px";
 p.style.position="absolute";
 p.style.left="-"+(width/2)+"px";
 pw.appendChild(p);
 
 var pt=document.createElement("div");
 pt.className="popup_top";
 p.appendChild(pt);
 
 var ptlc=document.createElement("div");
 ptlc.className="top_left_corner";
 pt.appendChild(ptlc);
 var ptf=document.createElement("div");
 ptf.className="top_fill";
 ptf.style.width=(width-7-7) + "px";
 pt.appendChild(ptf);
 var ptrc=document.createElement("div");
 ptrc.className="top_right_corner";
 pt.appendChild(ptrc);
 pt.appendChild(clear);
 
 p.appendChild(content);
 content.style.width = width-10-10+"px";//borders are 10px each
 
 
 var pb=document.createElement("div");
 pb.className="popup_bottom";
 p.appendChild(pb);
 
 var pblc=document.createElement("div");
 pblc.className="bottom_left_corner";
 pb.appendChild(pblc);
 var pbf=document.createElement("div");
 pbf.className="bottom_fill";
 pbf.style.width=(width-18-18) + "px";
 pb.appendChild(pbf);
 var pbrc=document.createElement("div");
 pbrc.className="bottom_right_corner";
 pb.appendChild(pbrc);
 pb.appendChild(clear); 
 
 /************/
 var ps=document.createElement("div");
 ps.setAttribute("id","popup_shadow");
 ps.style.width=width + "px";
 ps.style.position="absolute";
 ps.style.left="-"+(width/2+7)+"px";
 pw.appendChild(ps);
 
 var pst=document.createElement("div");
 pst.className="popup_top";
 ps.appendChild(pst);
 
 var pstlc=document.createElement("div");
 pstlc.className="top_left_corner";
 pst.appendChild(pstlc);
 var pstf=document.createElement("div");
 pstf.className="top_fill";
 pstf.style.width=(width-7) + "px";
 pst.appendChild(pstf);
 pst.appendChild(clear);
 
 var pspc=document.createElement("div");
 pspc.className="popup_content";
 pspc.style.height = (content.offsetHeight+10)+"px";
 ps.appendChild(pspc);
 
 var psb=document.createElement("div");
 psb.className="popup_bottom";
 ps.appendChild(psb);
 
 var psblc=document.createElement("div");
 psblc.className="bottom_left_corner";
 psb.appendChild(psblc);
 var psbf=document.createElement("div");
 psbf.className="bottom_fill";
 psbf.style.width=(width-7-7) + "px";
 psb.appendChild(psbf);
 var psbrc=document.createElement("div");
 psbrc.className="bottom_right_corner";
 psb.appendChild(psbrc);
 psb.appendChild(clear); 
 
 p.style.top="-"+(p.offsetHeight/2)+"px"; 


 ps.style.top="-"+(ps.offsetHeight/2-7)+"px"; 
 togglePopup(pw, "show", 1);//the "1" is the contentID that ain't needed for the "show" action
 
}
 
function togglePopup(pw, action, contentID, hideBlocker){
 
 if (action=="show"){
 new Effect.Opacity(
 pw,
 {
 duration: 0.2,
 from:0.0,
 to:1.0
 }
 );
 }
 else{
 new Effect.Opacity(
 pw,
 {
 duration: 0.2,
 from:1.0,
 to:0.0,
 afterFinish : function(){ 
 var content = document.getElementById(contentID);
 content.style.display = 'none';
 document.getElementsByTagName("body")[0].appendChild(content); 
 var popup_wrapper = document.getElementById("popup_wrapper");
 document.getElementsByTagName("body")[0].removeChild(popup_wrapper); 
 if(isNullOrUndefined(hideBlocker) == true)
 toggleBlocker("hide"); 
 }
 }
 );
 }
}
 
function hidePopup(contentID, hideBlocker)
{ 
    if(isNullOrUndefined(hideBlocker) == true )
        document.body.scroll = "yes";
    var popup_wrapper = document.getElementById("popup_wrapper");
    togglePopup(popup_wrapper, "hide", contentID, hideBlocker);
    try
    {
        if ($('ctl00_ContentPlaceHolder1_PlayerFrame') != null) { toggleSWF('ctl00_ContentPlaceHolder1_PlayerFrame'); }
        if ($('dvGigya') != null) { toggleSWF('dvGigya'); }
        if ($('thePlayerFrame') != null) { toggleSWF('thePlayerFrame'); }
        if ($('shapeshifterswf') != null) { toggleSWF('shapeshifterswf'); }
    }
    catch(err) {} 
}

function toggleTab(currentTab, futureTab)
{
    if (futureTab!="statistics")
    {
       var inner_content = document.getElementById("inner_content");
       inner_content.className = returnAttr(inner_content.className, currentTab, futureTab);
    }
}
 
function toggleBlocker(action, content){
 var blocker = document.getElementById("blocker");
 if (action == "show"){
 blocker.style.display="block";
 new Effect.Opacity(
 blocker,
 {
 duration: 0.2,
 from:0.0,
 to:0.8,
 afterFinish : function(){
 createAniboomPopup(content);
 }
 }
 );
 }
 else{
 new Effect.Opacity(
 blocker,
 {
 duration: 0.2,
 from:0.8,
 to:0.0,
 afterFinish : function(){
 blocker.style.display="none";
 }
 }
 );
 }
}
 
/* Custom popup */
function showCustomPopupExt(popupId, popupTitle, popupText, buttonArr, popupWidth,noScroll){
 if (document.getElementById(popupId)){
 }
 var pc=document.createElement("div");
 pc.className="popup_content";
 pc.id=popupId;
 
 var h1=document.createElement("H1");
 pc.appendChild(h1);
 var bpc=document.createElement("A"); 
 h1.appendChild(bpc);
 bpc.className="btn_popup_close";
 bpc.setAttribute("href","javascript:hidePopup('"+popupId+"')");
 var title=document.createTextNode(popupTitle);
 h1.appendChild(title);
 var para= document.createElement("P");
 pc.appendChild(para);
 var pt=document.createElement("SPAN");
 para.appendChild(pt);
 var btns= document.createElement("P");
 pc.appendChild(btns);
 var btns= document.createElement("P");
 pc.appendChild(btns);
 btns.className="buttons";
 var sClear=document.createElement("SPAN");
 btns.appendChild(sClear);
 sClear.className="clear";
  
 document.body.appendChild(pc);
 pc.style.width=popupWidth+"px";
 title.nodeValue = popupTitle;
 pt.innerHTML = popupText;
 pt.style.width = "100%"; 
 for (i=0; i<buttonArr.length; i++){
 buttonType = buttonArr[i].split(",")[0];
 buttonFunc = buttonArr[i].split(",")[1];
 buttonArr[i] = document.createElement("A");
 btns.appendChild(buttonArr[i]);
 buttonArr[i].setAttribute("href","javascript:" + buttonFunc);
 buttonArr[i].className="btn_popup_" + buttonType;
 }
 
 showPopupExt(popupId,noScroll);
 
}
function showCustomPopup(popupId, popupTitle, popupText, buttonArr, popupWidth){
 showCustomPopupExt(popupId, popupTitle, popupText, buttonArr, popupWidth,"1");
 }
 
//Happens in #related_stretch_beige
//When clicking a link the below content changes and the selected link becomes non-active
function toggleLinkActivation(clickedLink){
 if (clickedLink.className.indexOf("selected")!=-1) return false; //If the link was clicked although it was selected - do nothing and get the hell out of the function
 
 var selectedLink;
 //Finds the currently selected link and turn it into a regular one 
 var anchors = document.getElementsByTagName("a");
 for (i=0; i<anchors.length; i++){
 if (anchors[i].className.indexOf("reg_link")!=-1){ //If the link has the class "reg_link" or "reg_link_small"
 if (anchors[i].className.indexOf("selected")!=-1){//If it's selected
 selectedLink = anchors[i];
 selectedLink.style.textDecoration="none"; //Fixes an underline bug in IE
 break;
 }
 }
 }
 
 var selectedLinkParent = selectedLink.parentNode;// Sets the parentNode and will be used if its "related_subcontent_text reg_text_small"
 
 
 
 selectedLink.className = returnAttr(selectedLink.className, " selected", "");//Deselect the previously selected tag link
 
 clickedLink.className = clickedLink.className + " selected";//Turn the newly selected link into a selected one
}
 
var times=10,interval, objId="ErrSpan";
var msgElement;
function startBlinking()
{
 interval = window.setInterval(blinkErrMsg,100);
}
 
function blinkErrMsg()
{
 if (times>0) 
 {
 --times;
 if (msgElement!=null)
 {
 
 var curStatus=msgElement.style.visibility; 
 msgElement.style.visibility=((curStatus=="visible") ? "hidden" : "visible"); 
 }
 }
 else
 { 
 times=10;
 window.clearInterval (interval);
 if (msgElement!=null)
 msgElement.style.visibility="visible"; 
 }
}
 
var lastOpenQ;
var lastOpenA;
function handlePageFaq(divObj) {
 var questionDIV = divObj;
 
 if (document.all) {
 var answerDIV = divObj.nextSibling;
 } else {
 var answerDIV = divObj.nextSibling.nextSibling;
 }
 
 if (answerDIV.style.display == 'none') {
 if(!isNullOrUndefined(lastOpenQ))
 {
 lastOpenQ.className = 'page_faq_question';
 lastOpenA.style.display = 'none';
 }
 questionDIV.className = 'page_faq_question_open';
 answerDIV.style.display = '';
 lastOpenQ = questionDIV;
 lastOpenA = answerDIV;
 } else {
 questionDIV.className = 'page_faq_question';
 answerDIV.style.display = 'none';
 }
}
 
function secs2hms(secs) {
 m = Number(secs / 60).toFixed(); 
 s = secs % 60;
 h = Number(m / 60).toFixed(); 
 m = m % 60;
 return fillZero(String(h), 2) + ":" + fillZero(String(m), 2) + ":" + fillZero(String(s), 2);
}
 
function fillZero(num, rLength)
{
 var s = "";
 for (i=0; i<rLength-num.length; i++)
 {
 s += "0" ;
 }
 
 return s + num;
}
 
function loadDefault(obj) { 
    obj.src = appPathAnimatorIcons+"/default.jpg"; 

}
function fixAnimationImg(obj)
{
    obj.src = appPathAnimationIcons + "default.jpg"; 

} 
function refreshSession(minutes)
{
 window.setInterval(refreshSessionOnce, minutes * 60 * 1000);
}
function refreshSessionOnce()
{
 var url = appPathScript + "/Pages/InfraPages/KeepSessionAlive.aspx";
 AJAX.asyncWithCallback(url, "", "", true, false) ;
}
function googlesyndication()
{
 document.getElementById('divTopBanners').style.display = "block"; 
}
 
function checkOnLoadLeftBorder(lContentId,rContentId,divId)
{

 var elLeftContent, elRightContent, elDivSpace;
 var heightLeft, heightRight, heightDiv, difference;
 
 elLeftContent = document.getElementById(lContentId);
 elRightContent = document.getElementById(rContentId);
 elDivSpace = document.getElementById(divId); 

 
 
 heightLeft = Element.getHeight(elLeftContent);
 
 heightRight = Element.getHeight(elRightContent);
 heightDiv = Element.getHeight(elDivSpace);
 heightDiff = heightLeft - heightRight + heightDiv;
 

 if (heightDiff >= 0)
 {
 elDivSpace.style.height = "" + heightDiff + "px";
 }
 else
 {
 elDivSpace.style.height = "" + 0 + "px";
 }
}
 
function checkLeftBorder(contentTabId,isOpen)
{
 
 var objContentTab, elLeftSide, elRightSide, 
 tabHeight, divHeight, heightDifference, hieghtRightSide, hieghtLeftSide; 
 
 objContentTab = document.getElementById(contentTabId); 
 tabHeight = Element.getHeight(objContentTab);
 
 elLeftSide = document.getElementById("leftContentId");
 elRightSide = document.getElementById("rightContentId"); 
 elDivSpace = document.getElementById("divSpaceID");
 
 divHeight = Element.getHeight( elDivSpace );
 heightRightSide = Element.getHeight( elRightSide ) - divHeight;
 
 heightLeftSide = Element.getHeight( elLeftSide ); 
 
 
 if (isOpen)
 {
 heightRightSide = heightRightSide - tabHeight; 
 }
 
 heightDifference = heightLeftSide - heightRightSide;
 
 
 if (heightDifference > 0)
 {
 divHeight = heightDifference;
 
 elDivSpace.style.height = "" + divHeight + "px";
 }
 else
 {
 elDivSpace.style.height = "0px";
 }
}
 
function checkRightBorder(contentTabId,isOpen)
{
 var objContentTab, elLeftSide, elRightSide, 
 tabHeight, divHeight, heightDifference, hieghtRightSide, heightLeftSide; 
 
 objContentTab = document.getElementById(contentTabId); 
 tabHeight = Element.getHeight(objContentTab);
 
 elLeftSide = document.getElementById("leftContentId");
 elRightSide = document.getElementById("rightContentId"); 
 elDivSpace = document.getElementById("divSpaceID");
 
 divHeight = Element.getHeight( elDivSpace );
 heightRightSide = Element.getHeight( elRightSide ) - divHeight;
 heightLeftSide = Element.getHeight( elLeftSide );
 
 if (isOpen)
 {
 heightLeftSide = heightLeftSide - tabHeight; 
 }
 
 heightDifference = heightRightSide - heightLeftSide;
 
 
 if (heightDifference > 0)
 {
 elDivSpace.style.height = "0px";
 }
 else
 {
 divHeight = 0 - heightDifference; 
 elDivSpace.style.height = "" + divHeight + "px";
 }
}
function removeNode(obj)
{
 if (obj.parentNode)
 obj.parentNode.removeChild(obj); 
}
function ChangePicture(IsOver, objTbl)
{
 var elContainer;
 var strClass;
 elContainer = objTbl.getElementsByTagName('td');
 
 if (IsOver)
 {
 for (var i=0; i < elContainer.length; i++ )
 { 
 elContainer[i].className += "_Over"; 
 }
 }
 else
 {
 for (var i=0; i < elContainer.length; i++ )
 {
 strClass = elContainer[i].className;
 elContainer[i].className = strClass.substring(0,strClass.length-5);
 }
 } 
}
//needed to check for page
function isNullOrUndefined(obj)
{
    try
    {
	    return ((obj==null) || (obj==undefined) || (typeof(obj)=="undefined"));
	}
	catch(e)
	{
	    return true;
	}    
}
// add/remove decoration when mouse is over/out of an element
function relatedTabMouseOut(relTabId)
    {
        $(relTabId).style.cursor="default";
        $(relTabId).style.textDecoration="none";
    }
    function relatedTabMouseOver(relTabId)
    {
        $(relTabId).style.cursor="pointer";
        $(relTabId).style.textDecoration="underline";
    }