
function iniciarMenu(sm) {
     if (sm=='') {
         mostrar();
     } else {
         var submenu=document.getElementById(sm);
         if (submenu) {
             ul=submenu.getElementsByTagName('ul');
             mostrar(ul[0]);
         } else {
             mostrar();
         }
     }
}

function mostrar(id) {
        var menu_id=document.getElementById('menu-admin');
        lis=menu_id.getElementsByTagName('li');
        for (var i=0;i<lis.length;i++) {
            ul=lis[i].getElementsByTagName('ul');
            if (ul[0]) {
                ul[0].style.display='none';
                if (!lis[i].submenu) {
                   lis[i].submenu=ul[0];
                   lis[i].onclick=function () {
                        mostrar(this.submenu);
                   }
                }
       	    }
        }
        if (id) {
           if (id.style.display=='none') {id.style.display='block'} else {id.style.display='none'}
        };
}

function relTags() {

	if (document.getElementsByTagName) {
	
		var anchors = document.getElementsByTagName( "a" );
		
		for (var loop = 0; loop < anchors.length; loop++) {
			
			var anchor = anchors[loop];
			if (anchor.getAttribute("href")) {
                            funcion=anchor.getAttribute("rel");
                            if (funcion.charAt(0) == ":") {
                                palabras=funcion.split("|");
                                if (palabras[0]==':nw') {
                                    //anchor.onclick=function nw() {nw('ftp/camps/2004-marca-la-diferencia.jpg','','width=428,height=540');};
                                    var url = palabras[1] ? palabras[1] : '';
                                    var datos = palabras[2];
                                    eval("anchor.onclick = function(){" +
                                         "var win = window.open('" + url + "'," + 
                                         "'', '" + datos + "');" + 
                                         "win.focus();" +
                                         "return false;}");
                                    anchor.href='#';
                                } else if (palabras[0]==':bl') {
                                    anchor.target='_blank';
                                }
				//anchor.target = "_blank";
                            }
			}
		}
	}
}



// COUNTS AND LIMITS THE TEXT AREA

function limit(what,chars,counter) {

	var d=document;

	if (what.value.length > chars) {
		what.value=what.value.substr(0,chars);
		alert('You are only allowed to post '+chars+' chars in the field');
	}

	counting = (chars - what.value.length);
	c = document.getElementById(counter);
	c.innerHTML = counting;
}

// FLASH DETECT

var detectableWithVB 	= false;
var pluginFound 		= false;
var flashVersion 		= 0;
var passedFlashCheck 	= false;
var passedVersionCheck	= false;
var proceedToFlashPage 	= false;

	function getFlashStatus() {
	    pluginFound = detectPlugin('Shockwave','Flash'); 
	    if(!pluginFound && detectableWithVB) {
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
	    }
	    return pluginFound;
	}
	function detectPlugin() {
	    var daPlugins = detectPlugin.arguments;
	    var pluginFound = false;
	    if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
		    var numFound = 0;
		    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
			if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
			    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
			    numFound++;
			}   
		    }
		    if(numFound == daPlugins.length) {
			pluginFound = true;
			break;
		    }
		}
	    }
	    return pluginFound;
	}
		if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
		    document.writeln('<script language="VBscript">');
		    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
		    document.writeln('detectableWithVB = False');
		    document.writeln('If ScriptEngineMajorVersion >= 2 then');
		    document.writeln('  detectableWithVB = True');
		    document.writeln('End If');
		    document.writeln('\'this next function will detect most plugins');
		    document.writeln('Function detectActiveXControl(activeXControlName)');
		    document.writeln('  on error resume next');
		    document.writeln('  detectActiveXControl = False');
		    document.writeln('  If detectableWithVB Then');
		    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
		    document.writeln('  End If');
		    document.writeln('End Function');
		    document.writeln('</scr' + 'ipt>');
		}

//////////////////////////////////////////////////////////////////////
// Flash Version Detector  v1.1.5									//
// http://www.dithered.com/javascript/flash_detect/index.html		//
// code by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)	//
// with VBScript code from Alastair Hamilton						//
//////////////////////////////////////////////////////////////////////

	function getFlashVersion() {
		var agent = navigator.userAgent.toLowerCase(); 
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			var flashPlugin = navigator.plugins['Shockwave Flash'];
			if (typeof flashPlugin == 'object') { 
				if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
				else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
				else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
				else flashVersion = 0;
			}
		}
		else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		   document.write('<scr' + 'ipt language="VBScript"\> \n');
			document.write('on error resume next \n');
			document.write('dim obFlash \n');
			document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
			document.write('if IsObject(obFlash) then \n');
			document.write('flashVersion = 7 \n');
			document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
			document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
			document.write('flashVersion = 6 \n');
			document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
			document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
			document.write('flashVersion = 5 \n');
			document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
			document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
			document.write('flashVersion = 0 \n');
			document.write('end if');
			document.write('</scr' + 'ipt\> \n');
	  	}
		else {
			flashVersion = 0;
		}
		return flashVersion;
	}
	passedFlashCheck 	= getFlashStatus();
	passedVersionCheck	= getFlashVersion();

	function FlashDetect(whichVersion) {
		if (passedFlashCheck == true && passedVersionCheck >= whichVersion) {
			proceedToFlashPage = true;
		} else {
			proceedToFlashPage = false;
		}
		return proceedToFlashPage;
	}
	


function ponerFlash(imagen,ancho,alto) {
	if (FlashDetect(6)) {
                width='';
                if (ancho!='') {
                      width=' width='+ancho;
                }
                height='';
                if (alto!='') {
                      height=' height='+alto;
                }
		document.write('<div style="padding-bottom: 1em;text-align:center;">');
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '+width+' '+height+' id="flashlateral" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="'+imagen+'" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#ffffff" />');
		document.write('<embed src="'+imagen+'" quality="high" bgcolor="#ffffff" '+width+' '+height+' name="flashlateral" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
		document.write('</div>');
	} else {
		document.write('');
	}
}

function nw(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// ON LOAD

window.onload = function() {

relTags();

}