var monBlock	= null;
var monImg		= null;
var monIdx		= 0;
var monContainer= null;
var monTimeout	= 7000;
var monEffect	= 2;
var monHref;
var monSrc;
var monCaption;

// Global variables
var isCSS 			= false;
var isW3C 			= false;
var isIE4 			= false;
var isNN4 			= false;
var isIE6 			= false;
var isGecko 		= false;
var isOpera 		= false;
var isDHTML 		= false;
var suppressMenus	= false;
var legacyMode		= false;
var timerID			= null;
var subtimerID		= null;

// initialize upon load to let all browsers establish content objects
function autoconfig()
{
    if( document && document.images )
    {
        isCSS		= (document.body && document.body.style) ? true : false;
        isW3C		= (isCSS && document.getElementById) ? true : false;
        isIE4		= (isCSS && document.all && readIEVer() >= 4.0) ? true : false;
        isNN4		= (document.layers) ? true : false;
        isGecko		= (isCSS && navigator && navigator.product && navigator.product == "Gecko");
        isOpera		= (isCSS && navigator.userAgent.indexOf( "Opera") != -1 );
	isIE6CSS	= (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	isIE6		= ( isIE6CSS && readIEVer() >= 6.0 );
        isDHTML		= isCSS && ( isIE4 || isGecko || isOpera );
    } 
    
}

function readIEVer()
{
	var agent	= navigator.userAgent;
	var offset	= agent.indexOf( "MSIE" );
	if( offset < 0 )
	{
		return 0;
	}

	return parseFloat( agent.substring( offset + 5, agent.indexOf( ";", offset ) ) );
}


function writeMH( phoneTitle, phoneMsg, phoneTariff, segmentTitle, hasLocale, logoLink, pnmsg )
{
	autoconfig();
}



function montage( href, src, caption, width, animate )
{
	alert('uno');
	if( monBlock )
	{
		return;
	}

	monHref		= href;
	monSrc		= src;
	monCaption	= caption;

	// this is the case for browsers that don't support filters...
	var cycle	= Math.floor( Math.random() * href.length );

	// go build all of the nested DIVs out
	monIdx		= cycle;
	
	var nextImage	= (monIdx + 1) % src.length;

	document.writeln( "<div id=\"container\" style=\"width:" + width +"px;height:149px\">" );

	for( i = 0; i < src.length; i++ )
	{
		// set up a placeholder
		document.write( "<div id=\"montage" + i + "\" style=\"display:none\">" );
		
		if( i == nextImage )
		{
			// only prefetch the first image we will display
			document.write( montagePicker( i ) );
		}
		
		document.write( "</div>" );
	}

	document.writeln( "</div>" );

	// pull the images out
	monBlock	= new Array( src.length );
	monImg		= new Array( src.length );

	for( i = 0; i < src.length; i++ )
	{
		monBlock[i]	= document.getElementById( "montage" + i );
		
		if( i == nextImage )
		{
			monImg[i] = document.getElementById( "monimg" + i );
		}
		else
		{
			monImg[i] = null;
		}
	}

	monContainer = document.getElementById("container");
	montageEffects();
}

function montageEffects()
{
	var nextImage	= (monIdx + 1) % monImg.length;
	
	// run the transition
	if( readIEVer() >= 4.0 && monEffect > 0 )
	{
		if( monEffect == 1 )
		{
			monContainer.style.filter = "blendTrans(duration=0.6)";
			monContainer.filters(0).apply();
 			montageSelect( nextImage );
			monContainer.filters(0).play();
		}
		else
		{
			monContainer.style.filter = "blendTrans(duration=1.5) revealTrans(duration=1.0,transition=7)";
			monContainer.filters(0).apply();
			monContainer.filters(1).apply();
 			montageSelect( nextImage );
			monContainer.filters(0).play();
			monContainer.filters(1).play();
		}
	}
	else
	{
		montageSelect( nextImage );
	}

	// asked to be called again a little later
	setTimeout( "montagePrep()", monTimeout - 1500 );
	setTimeout( "montageSwap()", monTimeout );
}

function montageSelect( nextImage )
{
	monBlock[monIdx].style.display = "none";
	monIdx = nextImage;
	monBlock[monIdx].style.display = "block";
}		

function montagePrep()
{
	// prefetch the next image if we don't already have it
	var nextImage	= (monIdx + 1) % monImg.length;
	if( !monImg[nextImage] )
	{
		monBlock[nextImage].innerHTML = montagePicker( nextImage );
		monImg[nextImage] = document.getElementById( "monimg" + nextImage );
	}
}

function montageSwap()
{
	if( monImg[monIdx].complete )
	{
		// move the image index along
		montageEffects();
	}
	else
	{
		// check again 3 seconds later
		setTimeout( "montageSwap()", 4000 );
	}
}

function montagePicker( cycle )
{
	var divHtml;
	var strmessage;
	strmessage = 'Aqui es como esto va a funcionar, Aida Sanchez';
	var secondjpg;
	secondjpg = monSrc[cycle].replace('.jpg','A.jpg');

	
	if( monHref[cycle] != null ) 
	{
		divHtml = "<A href=\"" + monHref[cycle] + "\"><IMG src=\"" + monSrc[cycle] + "\" alt=\"" + monCaption[cycle] + "\" BORDER=\"0\" ID=\"monimg" + cycle + "\" onclick=show_photo(this.src,'','');></a>";
	}
	else
	{
		divHtml = "<a onclick=show_photo('"+monSrc[cycle].replace('.jpg','A.jpg')+"','','');><IMG src=\"" + monSrc[cycle] + "\" ID=\"monimg" + cycle + "\"></a>";
	}	
	return divHtml;
}

function hasBroadband()
{
	if( readIEVer() < 5.0 )
	{
		return false;
	}
	
	try
	{
		document.body.addBehavior ("#default#clientCaps");
		return ( typeof(document.body.connectionType) != "undefined" && document.body.connectionType == "lan" );
	}
	catch( e )
	{
		return false;
	}
}
function ACall()
{
	alert('HI');
	}
function MonthSubmit(AForm, i)
{
	document.getElementById('imonth').value = i;
	document.getElementById(AForm).submit();
}

// -------------------------------------------------------------
// end of `.js
// -------------------------------------------------------------

function over_effect(e,state){
if (document.all)
source4=event.srcElement
else if (document.getElementById)
source4=e.target
if (source4.className=="menulines")
source4.style.borderStyle=state
else{
while(source4.tagName!="TABLE"){
source4=document.getElementById? source4.parentNode : source4.parentElement
if (source4.className=="menulines")
source4.style.borderStyle=state
}
}
}


function setimageExtend(obj, image, floatpercent)
{
	document.getElementById(obj).src = image; 
	if (floatpercent < 0)
	{		    
		document.getElementById(obj).width  = Math.round(document.getElementById(obj).width  / (1.0 + (floatpercent * -1))); 
	    document.getElementById(obj).height = Math.round(document.getElementById(obj).height / (1.0 + (floatpercent * -1))); 
	}else
	{
		document.getElementById(obj).width  =  Math.round(document.getElementById(obj).width  * (1 + floatpercent)); 
		document.getElementById(obj).height = Math.round(document.getElementById(obj).height * (1 + floatpercent)); 		
	}
}
function setimage(obj, image)
{
	document.getElementById(obj).src = image;
}









function show_photo( pFileName, pTitle, pCaption) {
 myImage = new Image();
 myImage.src = pFileName;
strheight = 0
 strwidth = 0
// alert(myImage.width);
// alert(myImage.height);
if (pFileName != "")
{
 if ((myImage.width > myImage.height)&&(myImage.width > 740))
 {
    intpercent = (myImage.width - 740)/myImage.width ;
//	alert('percent: '+ intpercent);
	strwidth = Math.round(myImage.width - (myImage.width * intpercent));
	strheight = Math.round(myImage.height - (myImage.height * intpercent));
 }
 else if  ((myImage.width < myImage.height)&&(myImage.height > 740))
 {
    intpercent = (myImage.height - 740)/ myImage.height;
	strwidth = Math.round(myImage.width - (myImage.width * intpercent));
	strheight = Math.round(myImage.height - (myImage.height * intpercent));
 }else
 {
 strwidth = myImage.width;
 strheight = myImage.height;
 }

 strwidth = strwidth + 100;
 strheight = strheight + 70;
}else
{
 strwidth = 500;
 strheight = 500;

} 
//  alert('wid: ' + strwidth);
// alert('hei: ' +  strheight);
 
 
 
// specify window parameters
  photoWin = window.open("", "photo"," width="+strwidth+", height="+strheight+", resizable=yes, screenX=40, screenY=40, left=50, top=40");

   strwidth = strwidth - 100;
 strheight = strheight - 70;

// pCaption = '';
// wrote content to window
  photoWin.document.write('<html><head><title>' + pTitle + '</title></head>'); 


  photoWin.document.write('<BODY BGCOLOR=#FFFFFF TEXT=#FFFFCC    LINK=#33CCFF VLINK=#FF6666>');
  photoWin.document.write('<center>');
//  photoWin.document.write('<font size=+3   face="arial,helvetica"><b>' +     pCaption + '</b></font><br>');
if (pFileName !="")
{
  photoWin.document.write('<img src="' +   pFileName + '" border="2"   width="'+strwidth+'" height="'+strheight+'">');
 } 

  photoWin.document.write('<font face=    "arial,helvetica">');
//  photoWin.document.write( '"' + pTitle + '" photo &copy; Lorrie Lava<br>');
//  photoWin.document.write('<a href="mailto:  lava@pele.bigu.edu"> lava@pele.bigu.edu</a><br>');
//  photoWin.document.write('<a href="http://www.sanjudas.edu.do/">Colegio San Judas Tadeo</a>');

photoWin.document.write('<a style="color:#000066">'+pCaption+'</a></font><br><br>');
photoWin.document.write('<a href="javascript:window.close();">Click para cerrar</a>');


 
 photoWin.document.write('<font face= "arial,helvetica"><p></p></font> </body></html>');
// photoWin.document.write('<table><tr><td bgcolor=#000000><a onclick='+window.close() +'>Cerrar</a></td></tr></table>');
  photoWin.document.close(); 
 
// If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}




 	function validateuser(obj1, obj2)
	{
		struser = document.getElementById(obj1).value
		strpass = document.getElementById(obj2).value
		if (struser=='')
		{		  
		  alert('Usuario en blanco.');
		  return false;
		}  else if(strpass==''){
		  alert('Password en blanco.');
		  return false;		
		}
		else
		{		  		 
		  i = 0; 
		  intlen = struser.length;
		  newuser = '';
		  while(i < intlen)
		  {
		     if ( (struser.charCodeAt(i)>=48) && (struser.charCodeAt(i)<=57) )
			 {			   
			   newuser = newuser + struser.charAt(i);
			 }
			 i++;  
          }		 
		  struuser = newuser;
		  breturn = true;
		  while((i < intlen) && (breturn==true))
		  {
		     if ( (struser.charCodeAt(i)<48) || (struser.charCodeAt(i)>57) )
			 {
			    if (struser.charCodeAt(i)!=45)
				{
				  ShowInvalidUser()
			      breturn = false;
				}
			 }
			 i = i + 1;
		  }//While End
	      var frm =document.getElementById('FrmLogin');
		  if (newuser.length == 8)		  
		      frm.action = 'index_sub.asp?option=10&menu=1'; //it's a Student
		  else
		      frm.action = 'index_sub.asp?option=11'; //it's a Personal
		  return breturn;
		}//else end
	}//Function end

//This is from Calendar
function Test(i)
{
 var y=document.getElementById('iyear');
 var x =y.selectedIndex;
 var frm =document.getElementById('FrmCalendar');
//	document.getElementById('AMonth').value = i;
frm.action="index_sub.asp?option=5&iYear="+y.options[x].value+'&AMonth='+i;
frm.submit();
}
function AT(i)
{
	alert(i);
}

function AMenuEstudiante(i)
{
var frm =document.getElementById('FrmMenuEstudiante');
frm.action="index_sub.asp?option=10&Menu="+i;
frm.submit();
}

function AMenuPersonal(i)
{
var frm =document.getElementById('frmMenuPersonal');
frm.action="index_sub.asp?option=11&Menu="+i;
frm.submit();
}


function Logout()
{
  document.getElementById('Logged') = '0';
  window.location.reload();
}

function ShowNomina()
{
  var ACombo = document.getElementById('cbauxiliar'); 
  var x = ACombo.selectedIndex;
  var frm = document.getElementById('frmNominaPersonal');
  frm.action = "index_sub.asp?option=11&Menu=2&AuxiliarID="+ACombo.options[x].value;
  frm.submit();
}

function ShowEvaluation()
{
  var AYear = document.getElementById('cbanolectivo'); 
  var x = AYear.selectedIndex;
  var frm = document.getElementById('formEvaluacion');
  frm.action = "index_sub.asp?option=10&Menu=2&anolectivo="+AYear.options[x].value;
  frm.submit();
}
function ShowEstadoCuenta()
{
  var AYear = document.getElementById('cbanolectivo'); 
  var x = AYear.selectedIndex;
  var frm = document.getElementById('formEvaluacion');
  frm.action = "index_sub.asp?option=10&Menu=4&anolectivo="+AYear.options[x].value;
  frm.submit();
}


function doBlink() {
	var blink = document.all.tags("BLINK")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",1000)
}

function printChildWindow(src) 
{
	if(src == '#')
	    alert('Por favor seleccione una de las opciones.');
	else if (src != '0')
		var newWindow = window.open(src, "Testing", "height=550,width=500,directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes");
}
function SaveRecord(obj, fieldname, Avalue)
{
    obj.elements(fieldname).value = Avalue;
}
function Selecciones(strencuestaid, strtype, MaxSelect)
{
var strlink, i, thelink, numselect;
strlink = '';
	numselect = 0;
  for (i=0;i<document.forms['formencuesta'].elements.length;i++) 
   {
  if ((document.forms['formencuesta'].elements[i].type == strtype))
{
	   if (document.forms['formencuesta'].elements[i].checked == true )
	   {
		if (strlink != '')
		   strlink = strlink + ',';
		strlink = strlink +  document.forms['formencuesta'].elements[i].id;
		numselect = numselect + 1;
		}
	}
	}

//  thelik = "printChildWindow('pool.asp?Survey=" +strencuestaid + "&selected=" + strlink + "')";
  thelink = "pool.asp?Survey=" +strencuestaid + "&selected=" + strlink + "";
    if (numselect == "0")	
	return "#";	
	
    if (MaxSelect != "0")
	{
		if (MaxSelect < numselect)
		{
		   alert('Sólo está permitido hasta ' + MaxSelect + ' opciones.');
		   return "0";
		 }
		else
		   return thelink;
	}
	else
	{
		return  thelink;
	}
}