///////////////////////////////////////////////////////////////////////////////
// Scripts for C14L.com
// Written and (c) 2005 by Christian Steimel
///////////////////////////////////////////////////////////////////////////////

function setCookie(cookieName, cookieValue, nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
}

///////////////////////////////////////////////////////////////////////////////

function toggleDisplay(id) {
	if(document.getElementById(id).style.display=='block') {
		document.getElementById(id).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'block';
	}
}

///////////////////////////////////////////////////////////////////////////////

function showFoto(url, width, height, caption) {
	startwidth = 20; startheight = 20;
	f = window.open('','FotoWin','top='+((screen.height-startheight)/2)+',left='+((screen.width-startwidth)/2)+',width='+startwidth+',height='+startheight+',location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
	f.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ');
	f.document.write('"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">');
	f.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">');
	f.document.write('<head>');
	f.document.write('<title>Image View - C14L.com</title><script type="text/javascript">');
	f.document.write('function closeFoto(width, height){');
	f.document.write('width=width+10; height=height+60;');
	f.document.write('for(cy=height;cy>10;(cy=cy-30)){self.resizeTo(width,cy);self.moveTo((screen.width-width)/2,(screen.height-cy)/2);}');
	f.document.write('for(cx=width;cx>10;(cx=cx-30)){self.resizeTo(cx,10);self.moveTo((screen.width-cx)/2,(screen.height-10)/2);}');
	f.document.write('self.close();}');
	f.document.write('</script></head><body style="margin:0px;padding:0px;background:#CCC;">');
	// Add caption:
	if(caption) { 
		f.document.write('<div style="position:absolute;top:20px;left:20px;width:'+(width-60)+'px;');
		f.document.write('background:#EEE;border:1px solid #999;padding:10px;');
		f.document.write('font-size:11px; font-weight:normal; font-family:Arial,Helvetica,serif;');
		f.document.write('color: #000;" onclick="closeFoto(' + width + ', ' + height + ')">' + caption + '</div>');
	}
	// Add image:
	f.document.write('<a href="javascript:void(0)" onclick="closeFoto(' + width + ', ' + height + ')">');
	f.document.write('<img style="border:0px;margin:0px;padding:0px;width:'+width+'px;height:'+height+'px;" ');
	f.document.write('src="'+url+'" alt="" title="Click to close the image."></a>');
	f.document.write('</body></html>');
	// Do animation:
	width = width + 10; height = height + 60;
	for(cx=startwidth; cx<width; (cx=cx+30)) {
		f.resizeTo(cx, startheight);
		f.moveTo((screen.width-cx)/2, (screen.height-startheight)/2);
	}
	for(cy=startheight;cy<height;(cy=cy+30)) { 
		f.resizeTo(width, cy); 
		f.moveTo((screen.width-width)/2, (screen.height-cy)/2);
	}
	// Just to be sure ;]
	f.resizeTo(width, height); 
	f.moveTo((screen.width - width)/2, (screen.height - height)/2);
}

///////////////////////////////////////////////////////////////////////////////

function turnOffSite() { // Just for fun...
	if(navigator.userAgent.indexOf("Gecko") < 0) {
		// For not Gecko browsers (IE6, etc), the overlay should be 
		// streched to match at least the document's body height.
		document.getElementById('overlay').style.height = '1500px';
	}
	// Now show the overlay shade
	document.getElementById('overlay').style.display = 'block';
	// Confirm the 'switch off':
	if(!confirm('¿ Estás seguro que quieres apagar este sitio web ahora ?')) {
		document.getElementById('overlay').style.display = 'none';
		return true;
	}
	// Ok, switch if off.
	document.getElementById('overlay').style.display = 'none';
	document.getElementById('main').style.display = 'none';
	document.getElementsByTagName('body')[0].style.background = '#0000CC';
	setTimeout("turnOffSite2()", 1500);
}

function turnOffSite2() { // Just for fun...
	document.getElementsByTagName('body')[0].style.background = '#000000';
}

///////////////////////////////////////////////////////////////////////////////

function editProfileDisplayByProfileId(p) {
  // HIDE ALL PROFILE DIVS EXCEPT THIS ONE
  for(i=1;i<=6;i++) document.getElementById('profile-wrapper'+i).style.display='none';
  document.getElementById('profile-wrapper'+p).style.display='block';
}

///////////////////////////////////////////////////////////////////////////////
