//Hace los include de los JS de cada uno de los Modulos
includeJavaScript("source/javascript/homeMovies.js");
includeJavaScript("source/javascript/highlights.js");
includeJavaScript("source/javascript/promotionsElements.js");


var http_host = 'http://www.uav.org.ar/';
var vbChecked = false;
var is_nav;
var is_ie;
var winW, winH;
var vsErrorColor = '#CC3300';
setNavInfo ();

function setNavInfo () {
	var agt = navigator.userAgent.toLowerCase();
	is_nav = (agt.indexOf('mozilla') != -1);
	is_ie = (agt.indexOf('msie') != -1);
}

function includeJavaScript(jsFile)
{
	// se Parte </scr' + 'ipt>' en dos porque si estuviera todo junto IE 7 interpreta que es el final del script,
	// aunque este dentro de un String
	document.write('<script type="text/javascript" src="'
				   + jsFile + '"></scr' + 'ipt>'); 
}

function setWindowSizes ()
{
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
}

function changeCol(viId){
	var voTr = eval("document.getElementById(\"trRow" + viId + "\")");
	if(document.getElementById('checkId' + viId).checked == true){
		voTr.style.backgroundColor = '#FFCC99';
	}
	else{
		voTr.style.backgroundColor = '';
	}
	return true;
}

function changeColMOver(viId){
	var voTr = eval("document.getElementById(\"trRow" + viId + "\")");
	if(document.getElementById('checkId' + viId)){
		if(document.getElementById('checkId' + viId).checked == false){
			voTr.style.backgroundColor = '#BFF7D2';
		}
	}
	else{
		voTr.style.backgroundColor = '#BFF7D2';
	}
	return true;
}

function changeColMOut(viId){
	var voTr = eval("document.getElementById(\"trRow" + viId + "\")");
	if(document.getElementById('checkId' + viId)){
		if(document.getElementById('checkId' + viId).checked == false){
			voTr.style.backgroundColor = '';
		}
	}
	else{
		voTr.style.backgroundColor = '';
	}
	return true;
}

function checkUncheckAllChecks(voElement){
	var theForm = voElement.form, z = 0;

	while (theForm[z]) {
		//PONER SUBSTR
		if (theForm[z].type == 'checkbox' && theForm[z].name == 'checkId[]'){
			theForm[z].checked = !vbChecked;
			if (!vbChecked == true){
				document.getElementById('trRow' + theForm[z].value).style.backgroundColor = '#FFCC99';
			} else {
				document.getElementById('trRow' + theForm[z].value).style.backgroundColor = '';
			}
		}
		z++;
	}

	if (vbChecked == false){
		document.all.chkCheckAll.checked = true;
		document.all.btnSelectAll.value = 'Deseleccionar Todos';
	} else {
		document.all.chkCheckAll.checked = false;
		document.all.btnSelectAll.value = 'Seleccionar Todos';
	}

	vbChecked = !vbChecked;
	return true;
}

function askForReturn (vsURL){
	var vbAnswer = confirm("No quedan registros en el resultado de la búsqueda \n\n \t Desea ver TODOS los registros existentes?");
	if (vbAnswer == true) document.location = vsURL;
}

function viewPicture (vsURL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(vsURL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=800,height=600,left = 0,top = 0');");
}


function checkColFRep (vsCol) {
	for (viC = 0; viC < vaFileRepeated.length; viC++){
		document.getElementById('rdoOp_' + vaFileRepeated[viC] + '_' + vsCol).checked = true;
	}
}

function onEnterSubmit(vsObject, viKeyCode){
	if (viKeyCode == 13) {
		document.getElementById(vsObject).click();
		return false;
	}
}

function showUploadDiv (){
	document.all.startUpload.style.top = document.body.scrollTop + 150;
	document.all.startUpload.style.visibility = 'visible';
}

function stopUpload() {
	if (is_ie) {
		document.execCommand("Stop");
	} else if (is_nav) {
		window.stop();
	}
	document.all.startUpload.style.visibility = 'hidden';
}

function openPopUp (vsURL, vbLocal, viWidth, viHeight, viTop, viLeft) {
	day = new Date();
	id = day.getTime();

	if (viTop == 'center') {
		viTop		= (screen.height - viHeight - 60) / 2;
	}
	if (viLeft == 'center') {
		viLeft		= (screen.width - viWidth) / 2;
	}
	if (viWidth == 'fullwindow') {
		if (is_ie) {
			viWidth = 800;
			viHeight = 600;
			if (window.screen) { 
				viWidth = window.screen.availWidth - 10; 
				viHeight = window.screen.availHeight - 115; 
			} 
			eval("page" + id + " = window.open(vsURL, '" + id + "', 'toolbar=1, scrollbars=1, location=0, statusbar=1, addressbar=0, menubar=1, resizable=1, width = " + viWidth + ", height = " + viHeight + ", left = 0, top = 0');");
		} else if (is_nav) {
			eval("page" + id + " = window.open(vsURL, '" + id + "', 'fullscreen');");
		}
	} else {
		eval("page" + id + " = window.open(vsURL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=" + viWidth + ",height=" + viHeight + ",left = " + viLeft + ",top = " + viTop + "');");
	}
}

function viewPic (viId, viPicNum) {
	day = new Date();
	id = day.getTime();
	
	if (screen.width < 800) {
		viWidth		= 620;
		viHeight	= 430;
		viTop		= (screen.height - viHeight) / 2;
		viLeft		= (screen.width - viWidth) / 2;
	} else {
		viWidth		= 750;
		viHeight	= 535;
		viTop		= (screen.height - viHeight) / 2 - 25;
		viLeft		= (screen.width - viWidth) / 2;
	}
	vsURL = 'fotosVer.php?frmId=' + viId + '&picNum=' + viPicNum;
	eval("page" + id + " = window.open(vsURL, '" + id + "', 'toolbar=0, scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1, width=" + viWidth + ", height=" + viHeight + ", left = " + viLeft + ", top = " + viTop + "');");
}

function viewAdmPic (viId, viPicNum) {
	day = new Date();
	id = day.getTime();
	
	if (screen.width < 800) {
		viWidth		= 620;
		viHeight	= 430;
		viTop		= (screen.height - viHeight) / 2;
		viLeft		= (screen.width - viWidth) / 2;
	} else {
		viWidth		= 750;
		viHeight	= 535;
		viTop		= (screen.height - viHeight) / 2 - 25;
		viLeft		= (screen.width - viWidth) / 2;
	}
	vsURL = 'picsAdmView.php?frmId=' + viId + '&picNum=' + viPicNum;
	eval("page" + id + " = window.open(vsURL, '" + id + "', 'toolbar=0, scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1, width=" + viWidth + ", height=" + viHeight + ", left = " + viLeft + ", top = " + viTop + "');");
}


function printWindow() {
	viVer = parseInt(navigator.appVersion);
	if (viVer >= 4) window.print();
}

function showTravelWay(viId) {
	switch (viId) {
		case 'bus':
			openPopUp('bus.php', true, 400, 250, 'center', 'center');
		break;
		case 'car':
			openPopUp('http://www.cybermapa.com/default.asp?sec=res_dir&opcion=%5bACTION%3dOPCION%5d%5bPAIS%3d%5d%5bPROVINCIA%3dCAPITAL%20FEDERAL%5d%5bCIUDAD%3dCAPITAL%20FEDERAL%5d%5bLOCALIDAD%3dCIUDAD%20AUTONOMA%20BUENOS%20AIRES%5d%5bCALLE1%3dANDONAEGUI%5d%5bCALLE2%3d%5d%5bALTURA%3d2054%5d%5bPOSX%3d%2d58%2e486439%5d%5bPOSY%3d%2d34%2e579543%5d%5bZOOM%3d3%5d%5bUSUARIO%3d1000%5d%5bUSERIP%3d209%2e13%2e227%2e152%5d%5bLAYERS%3d%5d', true, 'fullwindow', 'fullwindow', 'center', 'center');
		break;
		case 'subway':
			openPopUp('subte.php', true, 400, 520, 'center', 'center');
		break;
	}
}

function showTravelWay_Eng(viId) {
	switch (viId) {
		case 'bus':
			openPopUp('bus_eng.php', true, 400, 250, 'center', 'center');
		break;
		case 'car':
			openPopUp('http://www.cybermapa.com/default.asp?sec=res_dir&opcion=%5bACTION%3dOPCION%5d%5bPAIS%3d%5d%5bPROVINCIA%3dCAPITAL%20FEDERAL%5d%5bCIUDAD%3dCAPITAL%20FEDERAL%5d%5bLOCALIDAD%3dCIUDAD%20AUTONOMA%20BUENOS%20AIRES%5d%5bCALLE1%3dANDONAEGUI%5d%5bCALLE2%3d%5d%5bALTURA%3d2054%5d%5bPOSX%3d%2d58%2e486439%5d%5bPOSY%3d%2d34%2e579543%5d%5bZOOM%3d3%5d%5bUSUARIO%3d1000%5d%5bUSERIP%3d209%2e13%2e227%2e152%5d%5bLAYERS%3d%5d', true, 'fullwindow', 'fullwindow', 'center', 'center');
		break;
		case 'subway':
			openPopUp('subway.php', true, 400, 520, 'center', 'center');
		break;
	}
}

function changeMnuImg(viId, vbOver) {
	switch (viId) {
		case 'noticias':
			if (vbOver) {
				document.getElementById('img_noticias').src = img_noticias.src;
			} else {
				document.getElementById('img_noticias').src = 'images/menu/mnu_noticias_Y.gif';
			}
		break;
		case 'car':
			openPopUp('http://www.cybermapa.com/default.asp?sec=res_dir&opcion=%5bACTION%3dOPCION%5d%5bPAIS%3d%5d%5bPROVINCIA%3dCAPITAL%20FEDERAL%5d%5bCIUDAD%3dCAPITAL%20FEDERAL%5d%5bLOCALIDAD%3dCIUDAD%20AUTONOMA%20BUENOS%20AIRES%5d%5bCALLE1%3dANDONAEGUI%5d%5bCALLE2%3d%5d%5bALTURA%3d2054%5d%5bPOSX%3d%2d58%2e486439%5d%5bPOSY%3d%2d34%2e579543%5d%5bZOOM%3d3%5d%5bUSUARIO%3d1000%5d%5bUSERIP%3d209%2e13%2e227%2e152%5d%5bLAYERS%3d%5d', true, 'fullwindow', 'fullwindow', 'center', 'center');
		break;
		case 'subway':
			openPopUp('subte.php', true, 400, 520, 'center', 'center');
		break;
	}
}

function saveFile (vsFileName) {
	window.document.execCommand('SaveAs', true, vsFileName);
}


function printWindow() {
  if (window.print)
    window.print()
  else
    alert("Disculpe, su navegador no soporta esta opción.");
}

function enableFile (voCheck, vsId) {
	if (voCheck.checked) {
		document.getElementById(vsId).disabled = false;
	} else {
		document.getElementById(vsId).disabled = true;
	}
}

function sendByMail (viFrmId, viPicNum) {
	openPopUp ('sendPicByMail.php?frmId=' + viFrmId + '&picNum=' + viPicNum, true, 450, 450, 'center', 'center');
	//http://alimentosparalavida.com.ar/fotosVer.php?frmId=' . $_GET['frmId'] . '&picNum=
}

function refreshLocalityCombo (viProvinceId)
{

	
	//ESTO ES PARA VACIAR EL COMBO - PRIMERO LO VACIA, DESPUES CARGA EL IFRAME
	/*
	for (viI = document.getElementById('cboLocality').options.length; viI > 0; viI--)
	{ 
		document.getElementById('cboLocality').options[viI] = null;
	}
	*/
	
	
	//ESTO ES PARA CARGAR EL IFRAME
	document.getElementById('iframeLocality').src = 'queryLocalityCombo.php?frmProvinceId=' + viProvinceId;
	
	//alert('CAntidad de elementos'  + document.iframeLocality.cboLocalityQuery.options.length);

	//ESTO ES PARA CARGAR EL COMBO
	/*
	for (viI = document.iframeLocality.cboLocalityQuery.options.length; viI > 0; viI--)
	{ 
		document.getElementById('cboLocality').options[viI] = document.iframeLocality.cboLocalityQuery.options[viI];
	}
	*/
	
	/*
	document.getElementById('iframeLocality').style.visibility = 'hidden';
	*/

	//document.getElementById('cboLocality').empty();
	/*
	if (viProvinceId == '2')
	{
		document.getElementById('iframeLocality').style.visibility = 'hidden';
		document.getElementById('iframeLocality').src = 'queryLocalityCombo.php?frmProvinceId=' + viProvinceId;
		
	}
	else
	{
		document.getElementById('iframeLocality').style.visibility = 'hidden';
		document.getElementById('iframeLocality').src = 'queryLocalityCombo.php?frmProvinceId=' + viProvinceId;
	}
	*/

}

function loadLocalityCombo ()
{
	//alert ('HOLA');

	/*
	alert (document.getElementById('cboLocalityQuery').options.length);
	alert ('HOLA');
	//alert ('COMBO PROVINCIAS:');
	alert ('COMBO PROVINCIAS:' + window.parent.document.getElementById('cboProvince').options.length);
	*/

	//alert (window.parent.document.getElementById('cboLocality').options.length);


	//alert (window.parent.document.getElementById('cboLocality').options.length);
	//alert (document.getElementById('cboLocalityQuery').options.length);

	//ESTO ES PARA CARGAR EL COMBO
	/*
	for (viI = 0; viI < document.getElementById('cboLocalityQuery').options.length; viI++)
	{ 
		//alert (document.getElementById('cboLocalityQuery').options[viI].value);
		window.parent.document.getElementById('cboLocality').options[viI] = document.getElementById('cboLocalityQuery').options[viI];
		alert ('Calor Ahora:');
	}
	*/
	
	//alert ('Sri Sri Radha Krishna');
	
	//window.parent.document.getElementById('cboLocality').innerHtml = document.getElementById('queryBody').innerHtml;
	alert ('INNER HTML: ' + window.parent.document.getElementById('cboLocality').innerHTML);
	alert ('INNER HTML: ' + document.getElementById('cboLocalityQuery').innerHTML);
	
	window.parent.document.getElementById('cboLocality').innerHTML = document.getElementById('cboLocalityQuery').innerHTML;


}

function addComboItem (vsComboName, vsTextName)
{ 
	if (document.getElementById(vsTextName).value != '')
	{
		var voOption = document.createElement("OPTION"); 
		voOption.text = document.getElementById(vsTextName).value;
		voOption.value = document.getElementById(vsTextName).value;
	
		document.getElementById(vsComboName).add(voOption); 
		document.getElementById(vsTextName).value = ''; 
	}
	else
	{
		alert ("ERROR, Por favor, ingrese un dato para agregar a la lista");
	}
}

function delComboItem (vsComboName)
{
	for (viC = document.getElementById(vsComboName).length - 1; viC >= 0 ; viC--)
	{
		if (document.getElementById(vsComboName).options[viC].selected == true && document.getElementById(vsComboName).options[viC].value != '')
		{
			document.getElementById(vsComboName).options[viC] = null;
		}
	}
}

function selectAllItemsInCombo (vsComboName)
{
	for (viC = 0; viC < document.getElementById(vsComboName).length; viC++)
	{
		document.getElementById(vsComboName).options[viC].selected = true;
	}
}

function unselectFirstItemsInCombo (vsComboName, viQuant)
{
	for (viC = 0; viC < viQuant; viC++)
	{
		document.getElementById(vsComboName).options[viC].selected = false;
	}
}
