var aSpanishMonths = new Array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
var GMT_OFFSET = -7;

function printDateTime()
{
	var oTmp = FIND('datetimespan');

	if(oTmp)
		oTmp.innerHTML = getDateTime();

	setTimeout(printDateTime, 30000);
}

function getDateTime()
{
	var oDate = new Date();
	//oDate.setTime(oDate.getTime() + (GMT_OFFSET * 60 * 60000));
	var iHour = oDate.getHours();//oDate.getUTCHours();
	var iMinutes = oDate.getMinutes();//oDate.getUTCMinutes();
	var sAMPM = 'am';

	if(!iHour)
		iHour = 12;
	else if(iHour >= 12)
	{
		sAMPM = 'pm';

		if(iHour > 12)
			iHour -= 12;
	}

	if(iMinutes < 10)
		iMinutes = '0' + iMinutes
	
	return	aSpanishMonths[oDate.getUTCMonth()].substr(0, 3) + ' ' +
			oDate.getUTCDate() + ' ' +
			iHour + ':' + iMinutes + ' ' +
			//oDate.getUTCSeconds() + ' ' +
			sAMPM;
}

//FLASH FUNCTIONS
var bo_ns_id = 0;

function startIeFix()
{  
	if(isIE())
	{    
		document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');  
	}
}

function endIeFix()
{  
	if(isIE())
	{    
		document.write('</div>');    
		var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
		var theCode = theObject.innerHTML;    
		theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"));
		document.write(theCode);  
	}
}

function isIE()
{	// only for Win IE 6+  
	// But not in Windows 98, Me, NT 4.0, 2000  
	var strBrwsr = navigator.userAgent.toLowerCase();  
	if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0)
	{    
		if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6)
		{      
			return false;    
		}    

		if(	strBrwsr.indexOf("win98") > -1 ||       
			strBrwsr.indexOf("win 9x 4.90") > -1 ||       
			strBrwsr.indexOf("winnt4.0") > -1 ||       
			strBrwsr.indexOf("windows nt 5.0") > -1)    
		{      
			return false;    
		}    
		
		return true;  
	}
	else
	{    
		return false;  
	}
}

//POPUP
function popUp(URL, width, height, scrollbars)
{
	if(scrollbars == undefined)
		scrollbars = '1';

	window.open(URL, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=' + scrollbars + ',width=' + width + ',height=' + height);

	return false;
}

function showPhoto(sImageID)
{
	popUp('photo.php?id=' + sImageID, 900, 800);
}

function showVideo(sVideoID)
{
	popUp('video.php?id=' + sVideoID, 900, 800);
}

var mainMarqueeStopped = false;

function startMainMarquee()
{
	FIND('mainMarquee').start();
	mainMarqueeStopped = false;
}

function stopMainMarquee()
{
	FIND('mainMarquee').stop();
	mainMarqueeStopped = true;
}

//HOME PAGE
function homePage()
{
	var aURL = new Array();
	var aURLAux = new Array();
	var sHomePage = '';

	aURL = document.URL.split("/");

	if(aURL.length >= 3)
	{
		aURLAux = aURL[2].split("?");

		if(aURLAux.length >= 1)
			sHomePage = aURL[0] + '//' + aURLAux[0];
	}

	if(!sHomePage)
		sHomePage = 'http://www.kbnt17.com';

	if(!hp.isHomePage(sHomePage))
	{
		document.write(
				'<table id="tuhomepage">' +
				'<tr>' +
				'<td width="5"></td>' +
				'<td valign="middle">' +
				'<img src="img/loguito-uni.jpg" border="0"/>' +
				'</td>' +
				'<td valign="middle">' +
				'<a href="javascript:void(null)" ' +
				'onClick="this.style.behavior=\'url(#default#homepage)\';' +
				'this.setHomePage(\'' + sHomePage + '\');">' +
				'Haz KBNT 17 tu homepage' +
				'</a>' +
				'</td>' +
				'</table>');
	}
}

//COOKIE FUNCTIONS
function createCookie(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;
}

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 '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function setSearchEngine(BASE_URL,form)
{
	if(form.sitesearch[0].checked) //If site search checked
		form.action=BASE_URL + "search.php"
	else
		form.action=BASE_URL + "result.php"	
	return true;
}

/* Added by Andres */

function openPopUp (URL){
   window.open(URL,"stream","width=697,height=458,scrollbars=NO,Resizable=NO,top=50,left=50");

}