var ECLIPSE_FRAME_NAME = "ContentViewFrame";

var eclipseBuild = false;



var liveDocsBaseUrl = "http://livedocs.adobe.com/flex/3";

var liveDocsBookName = "langref";

//Start: Bug#1325173
function alternate(id){
 	 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");
   var r1 = rows.length-1;  
    
    var scheme = "odd";
    var k = 0*1;
    
   for(i = 1; i < rows.length; i++){ 
           
 //manipulate rows
 
 if(scheme=="odd"){
       if((k*1)<(i*1) && i < rows.length - 3){
       rows[i].className = "even";
       k=1*i;
       if((i+1)<=rows.length && i < rows.length - 3){
       	   k=1*(i+1);
       	rows[k].className = "even";
       	scheme="even";
       }
       
       }
  }else{
  	  if((k*1)<(i*1) && i < rows.length - 3){
  	  rows[i].className = "odd";
  	  k=1*i;
  	  if(i!=1&&(i+1)<=rows.length && i < rows.length - 3){
  	  	  k=1*(i+1);
       	rows[k].className = "odd";
       	scheme="odd";
      }
      
      }
  }
 
 }
 }
}
//End: Bug#1325173

//Start: Bug#2347121
function ionReadyLoad(label,loc){
		var badge = new ionBadge();
		badge.url = window.location.toString();
		badge.locale = +loc;
		badge.container = document.getElementById("badgeContainer");
		badge.anchor = document.getElementById("badgeAnchor");
		badge.siteArea = "devcenter";
		badge.productLabel = +label;
		badge.commenting = true;
		badge.rating = true;
		badge.ratingType = "thumbs";
		badge.system = "adc";
		badge.timeOutDelay = 10000;
		badge.maxCommentLength = 100;
		
		badge.load();

	}
//End: Bug#2347121




//Start: Bug#1899661

function noFrms(){ 

        var doc = parent.frames["classFrame"].location.href.substring(window.location.href.lastIndexOf("/")+1); 

        if(doc=="search.html"){ 

          var curLoc=window.top.location.href.split("?"); 

          var openFile; 

          if(curLoc[1]!=null){ 

            curLoc = curLoc[1].split("#"); 

            var search = curLoc[1];

            curLoc = curLoc[0].split("&amp;");       

            openFile = window.top.location.href.substring(0,window.top.location.href.lastIndexOf("?")+1); 

            openFile = openFile.substring(0,openFile.lastIndexOf("/")+1)+"search.html#"+search;

          }

          else{ 

            curLoc[0]="overview.html"; 

            openFile = window.top.location.href.substring(0,window.top.location.href.lastIndexOf("/")+1)+curLoc[0];

          } 

          top.location=openFile; 

        }else{

          top.location=top.classFrame.location;

        }

      } 

function searchfunctionsubmit(baseref){

       var searchStr=document.getElementById('search-livedocs').value;

       window.location=baseRef+"search.html"+"###"+searchStr;

        }



function submitStandAloneSearchValue(){

	var searchStr=document.getElementById('search-livedocs').value;

          loadClassFrame("search.html?search=" +searchStr);

          document.getElementById('subTitle').childNodes.item(0).data = "Search Results";

          return false; 

}



function submitValue(title,url,label,site) {

var title=title;

var searchStr=document.getElementById('search-livedocs').value;

title = encodeURIComponent(encodeURIComponent(title));

	  var ptn = /\./;

	  if (ptn.test(title)) {

	  	title = title.replace(ptn, "%252E"); 

	  }  

        if(document.getElementById('checkBoxId').checked){

        top.location.href="http://"+url+"?q=" + searchStr

+"&loc=en_US"

+"&hl=en_US"

+"&lbl="+label

+"&go=Search"

+"&self=1"

+"&site="+site;

} 

        else{ 

top.location.href="http://"+url+"?q=" + searchStr

+"&loc=en_US"

+"&hl=en_US"

+"&lbl="+label

+"&go=Search"

+"&self=1";

} 

          document.getElementById('subTitle').childNodes.item(0).data = "";

          return false; 

}



function addIonComments(label)

{

	var loc = getLangName();

	function getLangName() {		

	var lang = "en-us";		

	var metaElements = document.all ?

	

	document.all.tags('meta') :

	document.getElementsByTagName ?

	document.getElementsByTagName ('meta') : new Array();

	

	var metaLangVals = new Array();

	var i = 0;

	

	for (var m = 0; m < metaElements.length; m++) {	    

	if (metaElements[m].name == "lang") {	      

	lang = metaElements[m].content;	      

	break;	    

	}		

	}		

	var ptn = /(..)-(..)/;		

	if (ptn.test(lang)) {			

	var countryCode = lang.replace(ptn, "$1");			

	var languageCode = lang.replace(ptn, "$2");			

	lang = countryCode + "_" + languageCode.toUpperCase();		

	}	  

	return lang;	}		



	var commentsContainer = "ionComHere";	



	ionComAddLoadEvent(function() {		



	var thisURL = encodeURIComponent(window.location);		

	var resource = thisURL.replace(new RegExp(/%23(.*)/),"");		

	ionComments.setup(resource, loc, commentsContainer, { siteArea: 'help', productLabel: +label });	})	

}



//End: Bug#1899661



//Bug #1851041 shinde Date:18072008

function gotoHome(linkURL) 

{

	var windowURL= window.location.href;

	var value = windowURL.replace(/title-bar\.html.*/,linkURL );

 	if (value != null) { 

		parent.top.location = value;

	}

}



function findObject(objId) {



    if (document.getElementById)

        return document.getElementById(objId);



    if (document.all)

        return document.all[objId];

}



function isEclipse() {

    return eclipseBuild;

//  return (window.name == ECLIPSE_FRAME_NAME) || (parent.name == ECLIPSE_FRAME_NAME) || (parent.parent.name == ECLIPSE_FRAME_NAME);

}





function configPage() {

    setRowColorsInitial(true, "Property");

    setRowColorsInitial(true, "Method");

    setRowColorsInitial(true, "ProtectedMethod");   

    setRowColorsInitial(true, "Event");

    setRowColorsInitial(true, "Style");

    

    /* Start: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc */

    setRowColorsInitial(true, "SkinPart");

    setRowColorsInitial(true, "SkinState");

    /* End: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc */

    setRowColorsInitial(true, "Constant");

    if (isEclipse()) {

        if (window.name != "classFrame")

        {

            var localRef = window.location.href.indexOf('?') != -1 ? window.location.href.substring(0, window.location.href.indexOf('?')) : window.location.href;

            localRef = localRef.substring(localRef.indexOf("langref/") + 8);

            if (window.location.search != "")

                localRef += ("#" + window.location.search.substring(1));



            window.location.replace(baseRef + "index.html?" + localRef);

            return;

        }

        else

        {

            setStyle(".eclipseBody", "display", "block");

//          var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;

//          if (isIE == false && window.location.hash != "")

            if (window.location.hash != "")

                window.location.hash=window.location.hash.substring(1);

        }

    }

    else if (window == top) { // no frames

        findObject("titleTable").style.display = "";

    }

    else { // frames

        findObject("titleTable").style.display = "none";

    }

    showTitle(asdocTitle);

}



function loadFrames(classFrameURL, classListFrameURL) {

    var classListFrame = findObject("classListFrame");

    if(classListFrame != null && classListFrameContent!='')

        classListFrame.document.location.href=classListFrameContent;



    if (isEclipse()) {

        var contentViewFrame = findObject(ECLIPSE_FRAME_NAME);

        if (contentViewFrame != null && classFrameURL != '')

            contentViewFrame.document.location.href=classFrameURL;

    }

    else {

        var classFrame = findObject("classFrame");

        if(classFrame != null && classFrameContent!='')

            classFrame.document.location.href=classFrameContent;

    }

}



function showTitle(title) {

    if (!isEclipse())

        top.document.title = title;

}



function loadClassFrame(classFrameURL) {

    if (parent.frames["classFrame"] != null) {

        parent.frames["classFrame"].location = classFrameURL;

    }

    else if (parent.frames["packageFrame"] != null) {

        if (parent.frames["packageFrame"].frames["classFrame"] != null) {

            parent.frames["packageFrame"].frames["classFrame"].location = classFrameURL;

        }

    }

}



function loadClassListFrame(classListFrameURL) {

    if (parent.frames["classListFrame"] != null) {

        parent.frames["classListFrame"].location = classListFrameURL;

    }

    else if (parent.frames["packageFrame"] != null) {

        if (parent.frames["packageFrame"].frames["classListFrame"] != null) {

            parent.frames["packageFrame"].frames["classListFrame"].location = classListFrameURL;

        }

    }

}



function gotoLiveDocs(primaryURL, secondaryURL, locale) {

        if (locale == "en-us" || locale == "en_us" || locale == "en_US") {

             locale = "";

        } 

        else {

              locale = "_" + locale.substring(3);

        }



    var url = liveDocsBaseUrl + locale + "/" + liveDocsBookName + "/index.html?" + primaryURL;

    if (secondaryURL != null && secondaryURL != "")

        url += ("&" + secondaryURL);



    window.open(url, "mm_livedocs", "menubar=1,toolbar=1,status=1,scrollbars=1,resizable=yes");

}



function findTitleTableObject(id)

{

    if (isEclipse())

        return parent.titlebar.document.getElementById(id);

    else if (top.titlebar)

        return top.titlebar.document.getElementById(id);

    else

        return document.getElementById(id);

}



function titleBar_setSubTitle(title)

{

    if (isEclipse() || top.titlebar)

        findTitleTableObject("subTitle").childNodes.item(0).data = title;

}



function titleBar_setSubNav(showConstants,showProperties,showStyles,showSkinPart,showSkinState,showEffects,showEvents,showConstructor,showMethods,showExamples,

                showPackageConstants,showPackageProperties,showPackageFunctions,showInterfaces,showClasses,showPackageUse)

{

    if (isEclipse() || top.titlebar)

    {

        findTitleTableObject("propertiesLink").style.display = showProperties ? "inline" : "none";

        findTitleTableObject("propertiesBar").style.display = (showProperties && (showPackageProperties || showConstructor || showMethods || showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("packagePropertiesLink").style.display = showPackageProperties ? "inline" : "none";

        findTitleTableObject("packagePropertiesBar").style.display = (showPackageProperties && (showConstructor || showMethods || showPackageFunctions || showEvents || showStyles || showConstants || showEffects || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("constructorLink").style.display = showConstructor ? "inline" : "none";

        findTitleTableObject("constructorBar").style.display = (showConstructor && (showMethods || showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("methodsLink").style.display = showMethods ? "inline" : "none";

        findTitleTableObject("methodsBar").style.display = (showMethods && (showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("packageFunctionsLink").style.display = showPackageFunctions ? "inline" : "none";

        findTitleTableObject("packageFunctionsBar").style.display = (showPackageFunctions && (showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("eventsLink").style.display = showEvents ? "inline" : "none";

        findTitleTableObject("eventsBar").style.display = (showEvents && (showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("stylesLink").style.display = showStyles ? "inline" : "none";

        

        findTitleTableObject("stylesBar").style.display = (showStyles && (showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";

        

        /* Start: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc */

        findTitleTableObject("SkinPartLink").style.display = showSkinPart ? "inline" : "none";

        findTitleTableObject("SkinPartBar").style.display = (showSkinPart && (showSkinState || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";

        

        findTitleTableObject("SkinStateLink").style.display = showSkinState ? "inline" : "none";

		findTitleTableObject("SkinStateBar").style.display = (showSkinState && (showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";

        /* End: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc */

        

        findTitleTableObject("effectsLink").style.display = showEffects ? "inline" : "none";

        findTitleTableObject("effectsBar").style.display = (showEffects && (showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("constantsLink").style.display = showConstants ? "inline" : "none";

        findTitleTableObject("constantsBar").style.display = (showConstants && (showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("packageConstantsLink").style.display = showPackageConstants ? "inline" : "none";

        findTitleTableObject("packageConstantsBar").style.display = (showPackageConstants && (showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("interfacesLink").style.display = showInterfaces ? "inline" : "none";

        findTitleTableObject("interfacesBar").style.display = (showInterfaces && (showClasses || showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("classesLink").style.display = showClasses ? "inline" : "none";

        findTitleTableObject("classesBar").style.display = (showClasses && (showPackageUse || showExamples)) ? "inline" : "none";



        findTitleTableObject("packageUseLink").style.display = showPackageUse ? "inline" : "none";

        findTitleTableObject("packageUseBar").style.display = (showPackageUse && showExamples) ? "inline" : "none";



        findTitleTableObject("examplesLink").style.display = showExamples ? "inline" : "none";

    }

}



function titleBar_gotoClassFrameAnchor(anchor)

{

    if (isEclipse())

        parent.classFrame.location = parent.classFrame.location.toString().split('#')[0] + "#" + anchor;

    else

        top.classFrame.location = top.classFrame.location.toString().split('#')[0] + "#" + anchor;

}



function setMXMLOnly() 

{

    if (getCookie("showMXML") == "false")

    {

        toggleMXMLOnly();

    }

}



function toggleMXMLOnly() 

{

    var mxmlDiv = findObject("mxmlSyntax");

    var mxmlShowLink = findObject("showMxmlLink");

    var mxmlHideLink = findObject("hideMxmlLink");

    if (mxmlDiv && mxmlShowLink && mxmlHideLink)

    {

        if (mxmlDiv.style.display == "none")

        {

            mxmlDiv.style.display = "block";

            mxmlShowLink.style.display = "none";

            mxmlHideLink.style.display = "inline";

            setCookie("showMXML","true", new Date(3000,1,1,1,1), "/", document.location.domain);

        }

        else

        {

            mxmlDiv.style.display = "none";

            mxmlShowLink.style.display = "inline";

            mxmlHideLink.style.display = "none";

            setCookie("showMXML","false", new Date(3000,1,1,1,1), "/", document.location.domain);

        }

    }

}



function showHideInherited()

{   

    setInheritedVisible(getCookie("showInheritedConstant") == "true", "Constant");

    setInheritedVisible(getCookie("showInheritedProtectedConstant") == "true", "ProtectedConstant");

    setInheritedVisible(getCookie("showInheritedProperty") == "true", "Property");

    setInheritedVisible(getCookie("showInheritedProtectedProperty") == "true", "ProtectedProperty");

    setInheritedVisible(getCookie("showInheritedMethod") == "true", "Method");

    setInheritedVisible(getCookie("showInheritedProtectedMethod") == "true", "ProtectedMethod");

    setInheritedVisible(getCookie("showInheritedEvent") == "true", "Event");

    setInheritedVisible(getCookie("showInheritedStyle") == "true", "Style");

    

    /*Start: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc*/

    setInheritedVisible(getCookie("showInheritedSkinPart") == "true", "SkinPart");

    setInheritedVisible(getCookie("showInheritedSkinState") == "true", "SkinState");

    /*End: Bug#2269223 Shinde Date:10/03/09 Add Skin State & Skin Part to ASDoc*/



    setInheritedVisible(getCookie("showInheritedEffect") == "true", "Effect");

}





function setInheritedVisible(show, selectorText)

{

    if (document.styleSheets[0].cssRules != undefined)

    {

        var rules = document.styleSheets[0].cssRules;

        for (var i = 0; i < rules.length; i++)

        {

            if (rules[i].selectorText == ".hideInherited" + selectorText)

                rules[i].style.display = show ? "" : "none";

                

            if (rules[i].selectorText == ".showInherited" + selectorText)

                rules[i].style.display = show ? "none" : "";

        }

    }

    else

    {

        document.styleSheets[0].addRule(".hideInherited" + selectorText, show ? "display:inline" : "display:none");

        document.styleSheets[0].addRule(".showInherited" + selectorText, show ? "display:none" : "display:inline");

    }



    setCookie("showInherited" + selectorText, show ? "true" : "false", new Date(3000,1,1,1,1), "/", document.location.domain);

    setRowColors(show, selectorText);

}



function setRowColors(show, selectorText)

{

    var rowColor = "#F2F2F2";

    var table = findObject("summaryTable" + selectorText);



    if (table != null)

    {

        var rowNum = 0;

        for (var i = 1; i < table.rows.length; i++)

        {

            if (table.rows[i].className.indexOf("hideInherited") == -1 || show)

            {

                rowNum++;

                table.rows[i].bgColor = (rowNum % 2 == 0) ? rowColor : "#FFFFFF";

            }           

        }

    }

}



function setRowColorsInitial(show, selectorText)

{

    var rowColor = "#F2F2F2";

    var table = findObject("summaryTable" + selectorText);



    if (table != null)

    {

        var rowNum = 0;

        for (var i = 1; i < table.rows.length; i++)

        {

            if (table.rows[i].className.indexOf("hideInherited") == -1 && show)

            {

                rowNum++;

                table.rows[i].bgColor = (rowNum % 2 == 0) ? rowColor : "#FFFFFF";

            }           

        }

    }

}



function setStyle(selectorText, styleName, newValue)

{

    if (document.styleSheets[0].cssRules != undefined)

    {

        var rules = document.styleSheets[0].cssRules;

        for (var i = 0; i < rules.length; i++)

        {

            if (rules[i].selectorText == selectorText)

            {

                rules[i].style[styleName] = newValue;

                break;

            }

        }

    }

    else

    {

        document.styleSheets[0].addRule(selectorText, styleName + ":" + newValue);

    }

}



// ASDoc filtering
var asfilterjs = "ASFilter.js";
document.write('<script src="' + asfilterjs + '"type="text/javascript" language="Javascript" charset="UTF-8"></scr'+'ipt>');

// Adobe Help versions pod
var ahpodjs = "/en_US/shared/ahpods/AHPod.js";
document.write('<script src="' + ahpodjs + '"type="text/javascript" language="Javascript" charset="UTF-8"></scr'+'ipt>');
