/** VARS
*
*
*/
var urlPathSeperator = (document.location.pathname.indexOf("\\")!=-1) ? "\\" : "/";
var sTabId_1="";
var sTabId_2="";
var isTabUseLevel2 = true;
var sTabCookieName = "mome_tab_"+document.location.hostname+document.location.pathname.substr(document.location.pathname.lastIndexOf(urlPathSeperator)+1);
var mome_isSwfInstall = 0;

/** ACTIONS
*
*
*/
mome_addDomEvent(window, "load", mome_tab_init);



/** FUNCTIONS - SHORTCUTS
*
*
*/
function mome_addDomEvent(obj, evType, fn){
 if (obj.addEventListener){
 	obj.addEventListener(evType, fn, false);
 	return true;
 } else if (obj.attachEvent){
 	var r = obj.attachEvent("on"+evType, fn);
 	return r;
 } else {
	return false;
 }
};

function mome_modifyProp(objName,theProp,theValue) {
 	var obj = document.getElementById(objName);
 	if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
		if (theValue === true || theValue === false){
		 eval("obj."+theProp+"="+theValue);
		}else {
		 eval("obj."+theProp+"='"+theValue+"'");
		}
	}
};



/** FUNCTIONS - TABS
*
*
*/
function mome_tab_init() {
	if (document.location.href.indexOf("tab=")!=-1){
		sTabId_1 = mome_tab_chkCookie(1);
		mome_tab_setDisplay(sTabId_1, 1, false);
		//alert("mome_tab_init(): " +sTabId_1);
		if (isTabUseLevel2){
			/// do something
		}
	}
};

function mome_tab_setDisplay(_sId, _nLevel, _isOld){
	mome_modifyProp("tab" + _nLevel + "-" + _sId, "className", ((!_isOld)?"on":"off") );
	//alert("mome_tab_setDisplay(): tab" + _nLevel + "-" + _sId);
    mome_modifyProp("tab" + _nLevel + "-" + _sId + "-content", "style.display", ((!_isOld)?"block":"none") );
};

function mome_tab_toggle(_o, _nLevel) {
	_o = (typeof(_o)=="object") ?  _o : document.getElementById(_o);
	var _sId =  _o.id.toString().substr(5); /// get number out of string "tabX" example: tab9 = will give 9
    _nLevel = (_nLevel == null || _nLevel == undefined) ? "1" : _nLevel;
	
	
    var _refLastTabId = eval("sTabId_" + _nLevel);
    if (_sId == _refLastTabId) {
        return;
    } else {
		mome_cookie_set((_nLevel+sTabCookieName),_sId,"1");
        mome_tab_setDisplay(_sId, _nLevel, false);
		mome_tab_setDisplay(_refLastTabId, _nLevel, true);
        if (_nLevel == "1") {
            sTabId_1 = _sId;
        } else {
            sTabId_2 = _sId;
        }
        return false;
    }
};

function mome_tab_chkDirectLink_BK(){
	_hash = document.location.hash.substr(1);
	if (_hash!="" && _hash!=undefined && _hash!=null){
		if (_hash.indexOf("tab=")!=-1){
			_hash= _hash.split("tab=")[1];
			if(_hash.indexOf("&")!=-1) _hash =  _hash.split("&")[0];
		}
		return _hash;
	}else{
		return null;
	}
};
function mome_tab_chkDirectLink(){
	_q = document.location.search.substring(1);
	if (_q!="" && _q!=undefined && _q!=null){
		if (_q.indexOf("tab=")!=-1){
			_q = _q.split("tab=")[1];
			if(_q.indexOf("#")!=-1) _q =  _q.split("#")[0];
			if(_q.indexOf("&")!=-1) _q =  _q.split("&")[0];
		}
		//alert(_q);
		return _q;
	}else{
		//alert("null");
		return null;
	}
};

function mome_tab_chkCookie(_nLevel) {
	var _cookieName = _nLevel + sTabCookieName;
	var _cookie = mome_tab_chkDirectLink();
	if (_cookie==null) {
		_cookie = mome_cookie_get(_cookieName);
		if (_cookie==null) {
			mome_cookie_set(_cookieName, "1", 1);
			_cookie="1";
		}
	}else{
		mome_cookie_set(_cookieName, _cookie, 1);
	}
	//alert(_cookie);
	return _cookie;
};


/** FUNCTIONS - COOKIES
*
*
*/
function mome_cookie_set(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 mome_cookie_get(name) {
 var nameEQ = name + "=";
 //alert(nameEQ);
 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 mome_cookie_delete(name) {
 mome_cookie_set(name,"",-1);
};

/** FUNCTIONS - SWF EMBED
*
*
*/
function mome_swf_write(_sRenderHtml) {
    document.write(_sRenderHtml);
};

function mome_swf_embed(_sDivId, _sSwfSrc, _sFlashVars, _sSwfId, _nW, _nH, _sSwfWmode) {
    _sSwfSrc = _sSwfSrc == null ? "" : _sSwfSrc;
    _sFlashVars = _sFlashVars == null ? "" : _sFlashVars;
    _sSwfId = _sSwfId == null ? "SwfEmbed" : _sSwfId;
    _nW = _nW == null ? 100 : _nW;
    _nH = _nH == null ? 100 : _nH;
    _sSwfWmode = _sSwfWmode == null ? "opaque" : _sSwfWmode;
    var _sRenderHtml = "";
    if (_sSwfSrc != "") {
        if (AC_FL_GetContent == 0) {
            alert("This page requires AC_RunActiveContent.js. In Flash, run Apply Active Content Update in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
        } else {
            _sRenderHtml += "<span style='display:none'>swf file</span>";
            _sRenderHtml += AC_FL_GetContent("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0", "width", _nW, "height", _nH, "src", _sSwfSrc, "movie", _sSwfSrc, "quality", "high", "pluginspage", "http://www.macromedia.com/go/getflashplayer", "align", "middle", "play", "true", "loop", "true", "scale", "showall", "wmode", _sSwfWmode, "devicefont", "false", "id", _sSwfId, "bgcolor", "#000000", "name", _sSwfId, "menu", "true", "allowScriptAccess", "always", "salign", "", "FlashVars", _sFlashVars);
            if (_sDivId != null) {
                document.getElementById(_sDivId).innerHTML = _sRenderHtml;
            } else {
                return _sRenderHtml;
            }
        }
    }
};

function mome_swf_validateEmbed(_sDivId, _sSwfSrc, _sFlashVars, _sSwfId, _nW, _nH, _sSwfWmode, _aFlashVersion) {
    _sSwfSrc = _sSwfSrc == null ? "" : _sSwfSrc;
    _sFlashVars = _sFlashVars == null ? "" : _sFlashVars;
    _sSwfId = _sSwfId == null ? "SwfEmbed" : _sSwfId;
    _nW = _nW == null ? 100 : _nW;
    _nH = _nH == null ? 100 : _nH;
    _sSwfWmode = _sSwfWmode == null ? "opaque" : _sSwfWmode;
   
    var reqMajVer = _aFlashVersion != null && _aFlashVersion != undefined ? _aFlashVersion[0] : 6;
    var reqMinVer = _aFlashVersion != null && _aFlashVersion != undefined ? _aFlashVersion[1] : 0;
    var reqRev = _aFlashVersion != null && _aFlashVersion != undefined ? _aFlashVersion[2] : 65;
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    var hasReqVer = DetectFlashVer(reqMajVer, reqMinVer, reqRev);
    var altContent = "<div  style=\"background-color:#fff;border:2px red solid;padding:3px;\"><p>The required plugin <b>Flash " + reqMajVer + "." + reqMinVer + "." + reqRev + "</b> is not installed on this system.<br/><a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank'>Click here to download it free</a>.</p><p><b>Note to Mac users:</b> You may need to restart your computer after download.</p></div>";
    if (!hasReqVer && hasProductInstall) {
        var MMPlayerType = isIE == true ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;
        if (!mome_isSwfInstall) {
            mome_isSwfInstall = true;
          //  if (isIE) {
                // mome_doEmbedSwf(_sDivId, "swf/playerProductInstall", "MMredirectURL=" + MMredirectURL + "&MMplayerType=" + MMPlayerType + "&MMdoctitle=" + MMdoctitle + "", "installFlashPlayer", _nW, _nH, _sSwfWmode);
           // } else {
                if (_sDivId != null) {
                    document.getElementById(_sDivId).innerHTML = altContent;
                } else {
                    return altContent;
                }
           // }
        }
    } else if (hasReqVer) {
        if (_sDivId != null) {
            mome_swf_embed(_sDivId, _sSwfSrc, _sFlashVars, _sSwfId, _nW, _nH, _sSwfWmode);
        } else {
            return mome_swf_embed(_sDivId, _sSwfSrc, _sFlashVars, _sSwfId, _nW, _nH, _sSwfWmode);
        }
    } else {
        if (_sDivId != null) {
            document.getElementById(_sDivId).innerHTML = altContent;
        } else {
            return altContent;
        }
    }
};



/** FUNCTIONS - COOKIES
*
*
*/

//------ Pop up window script--------//

<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function misc_toggleRefBox(_d){
	_d = "RefBox"+_d;
	var _v = (document.getElementById(_d).style.display == "block")  ? "none" : "block";
	mome_modifyProp(_d,'style.display',_v);
};
//-->

