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


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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}

// Toggle layers on and off
function flipLayer (layername) {
//turn the layer you want to show on
	if (document.getElementById(layername).style.display=='block') {
		document.getElementById(layername).style.display = 'none';
	} else {
		document.getElementById(layername).style.display = 'block';
	}
}

function hideLayers (whichlayers) {
//turn the layer you want to show on
	for (x in whichlayers) {
		document.getElementById(whichlayers[x]).style.display = 'none';
	}
}



// var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
// if (isIE && isWin) {
//	window.attachEvent("onload", correctPNG);
//}

function writeFlash(movieLocation,flashwidth,flashheight,name) {
	if (name) { myid=name; } else {myid="flashpresentation";}
	document.write('<object type="application/x-shockwave-flash" id="'+myid+'" width="'+flashwidth+'" height="'+flashheight+'" data="'+movieLocation+'"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+movieLocation+'" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /></object>');
}


function showImage(originalImage) {
	var highResImageURL=originalImage.getAttribute('src');
	var listid=0;

	var overlayLocation=document.getElementsByTagName('body')[0];
	var myoverlay=document.createElement('DIV');
	myoverlay.id="overlay";
	overlayLocation.appendChild(myoverlay);
	

	var insertLocation=myoverlay;
	var newimage=document.createElement('IMG');
	newimage.id="large";
	
	newimage.src= highResImageURL;

	var initialPosition = 0;
	var lastPosition = 0;

	newimage.onclick=function(){
		newimage.className="hideit";
		myoverlay.className='fadeout';
		window.setTimeout(function() {
			insertLocation.removeChild(newimage);
			window.setTimeout(function() {
				overlayLocation.removeChild(myoverlay);
			}, 500);
		}, 200);
	}
	window.setTimeout(function() {
		myoverlay.className='fadein';
		newimage.className="showit";
	}, 200);

	insertLocation.appendChild(newimage);
}

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;
		}
		var username=readCookie('username');
		var message = '';
		if(username) {
			message = 'Hola <a href="/admin/edit.php">' + username + '</a> | <a href="/comunidad/gente/mypage.php">El Corillo de Jos&eacute;</a> | <a href="/admin/logout.php">logout</a>';
		} else {
			message = '<a href="/admin/login.php">login</a> | <a href="/admin/register.php">Reg&iacute;strate</a>';
}


var currentaudiosrc='';
function doAudio(audioitem,audiosrc) {
	if (currentaudiosrc=='') {
		var audio=document.createElement('audio');
		document.body.appendChild(audio);
		audio.src=audiosrc;
		audio.play();
		currentaudiosrc=audiosrc;
		audioitem.id="playing";
		//Add an Event Listener
		audio.addEventListener('ended',function(e) {
			document.getElementById("playing").removeAttribute('id');
			currentaudiosrc=""; //reset the audiosrc
			document.body.removeChild(document.getElementsByTagName("audio")[0]);
		}, false);
		//Add an Event Listener
	} else {
	
		if (currentaudiosrc==audiosrc) { // Is this the current item?
			if (audioitem.id=='playing') {
				document.getElementsByTagName("audio")[0].pause();
				audioitem.id="paused";
			} else {
				document.getElementsByTagName("audio")[0].play();
				audioitem.id="playing";
			}
		} else { //if it's not the current item
			if (document.getElementById("paused")) { 
				document.getElementById("paused").removeAttribute('id');
			}
			if (document.getElementById("playing")) { 
				document.getElementById("playing").removeAttribute('id');
			}
			currentaudiosrc=""; //reset the audiosrc
			document.body.removeChild(document.getElementsByTagName("audio")[0]); //remove the audio object
			doAudio(audioitem,audiosrc); //recursively call this function
		}
		//Insert New Code Here
	}
}





