// JavaScript Document
/* ::: Alias para jQuery ::: */
var $jQ = jQuery.noConflict();
$jQ(document).ready(InitUMBase);

/*inicializacion*/
function InitUMBase()
{
	PaintAlterntingRows($jQ(".TblBiOcre1"), ["RowOcre0", "RowOcre1"], ["Titulo", "Recuadro", "Mensaje", "TitInt", "TitObt", "TitCre", "TitGen1", "TitGen2", "TitGen3"]);
	PaintAlterntingRows($jQ(".TblBiOcre4"), ["RowOcre1", "RowOcre0"], ["TitGen1", "TitGen2", "TitGen3"]);
	PaintAlterntingRows($jQ(".TblBiAzul1, .TblBiAzul1-1"), ["RowAzul0", "RowAzul1"], ["TitGen1", "TitGen2", "TitGen3", "RowOcre1"]);
	PaintAlterntingRows($jQ(".TblBiGris1, .TblBiGris1-1, .TblTriGris1-1"), ["RowGris0", "RowGris1"], ["TitGen1", "TitGen2", "TitGen3", "Mensaje"]);
	InitPlan();
	InitCalAcad();
}

function PaintAlterntingRows(tableArray, styleNamesArray, exceptionsArray)
{
	var styleCount = styleNamesArray.length;
	var styleRotator = 0;
	$jQ(tableArray).each
	(
		function(i)
		{
			$jQ("tr", this).each
			(
				function(i)
				{
					var trExcepted = false;
					if(exceptionsArray != null || exceptionsArray != undefined)
					{
						for(var ex = 0; ex < exceptionsArray.length; ex++)
						{
							if($jQ(this).hasClass(exceptionsArray[ex]))
							{
								trExcepted = true;
								break;
							}
						}	
					}
					if(!trExcepted)
					{
						$jQ(this).attr("class", styleNamesArray[styleRotator]);
						styleRotator++;
						styleRotator = (styleRotator + 1) > styleCount ? 0 : styleRotator;						
					}
				}
			); 	
		}
	);
}



function InitPlan()
{
	if($jQ("td[@rel=corre]").length > 0)
	{
		//escondo la columna de exámenes
		$jQ("td[@rel=corre], th[@rel=corre]").css('display', 'none');
		$jQ("colgroup").each
		(
			function(i)
			{
				$jQ($jQ("col", this)[5]).css('display', 'none');
			}
		);
		$jQ("td[@rel=cod], th[@rel=cod]").attr("class", "PadLeft4");
		
		//seteo el evento change del select
		$jQ("#selVerCorrelativas").change
		(
			function()
			{
				switch($jQ("#selVerCorrelativas")[0].value)
				{
					case "0":
						$jQ("td[@rel=corrc], th[@rel=corrc]").hide();
						$jQ("td[@rel=corre], th[@rel=corre]").show();
					break;
					case "1":
						$jQ("td[@rel=corrc], th[@rel=corrc]").show()
						$jQ("td[@rel=corre], th[@rel=corre]").hide();
					break;
					default:break;
				}
			}
		 );	
	}
}

function InitCalAcad()
{
	$jQ(".TblBiAzul1 tr").each
	(
	 	function(i)
		{
			$jQ("td:first", this).css("font-weight", "bold");	
		}
	);
}

function url()
{
    var url = location.href;
	if (url.indexOf("ReturnURL") > 0)
	{
		location.href = url.substring(url.indexOf("ReturnURL") + 10);
	}
	else
	{
		self.history.back();
	}
}

function lanzaWin800x600(url)
{
    window.open(url,'win','width=800,height=600,toolbar=no,status=no,scroolbar=no,top=0,left=0,resizable=no');
}
function lanzaWinFree(url)
{
    window.open(url,'win','');
}