// update hint box value
function display_hint( p_hint_text ) {
	document.getElementById( 'hint_box' ).innerHTML	= '<strong>Status</strong>: ' + p_hint_text;
}

// clear interval (if one has been set) & update hint box value using helper function
function reset_hint() {
	window.clearInterval( document.getElementById( 'hint_box' ).interval );
	display_hint( 'Ready...' );
}

// clear interval (if one has been set) & update hint box value using helper function
function show_hint( p_hint_text ) {
	window.clearInterval( document.getElementById( 'hint_box' ).interval );
	display_hint( p_hint_text );
}

// set new interval
function set_timeout() {
	document.getElementById( 'hint_box' ).interval = window.setInterval( 'reset_hint()', 2000 );
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

function show_alumno() {
	showHideLayers('datosalumno','','show','mrcol','','hide');

}

function hide_alumno() {
	showHideLayers('datosalumno','','hide');
}

function RemoveContent(d) {
document.getElementById(d).style.display = "none";
}

function InsertContent(d) {
document.getElementById(d).style.display = '';
}

function Limpia_Campos() {
	document.getElementById("comenombre").value = '';
	document.getElementById("comeemail").value = '';
	document.getElementById("cometelnum").value = '';
	document.getElementById("comematricula").value = '';
	document.getElementById("comecarrera").value = '';
	document.getElementById("comesemestre").value = '';
	document.getElementById("comegrupo").value = '';
	document.getElementById("esalumno").checked = false;
	
	
}

function show_divs(padre,opcion) {
/*Limpia_Campos();*/
if(padre==1) {
	if(opcion==0) {
		showHideLayers('divasunto','','hide','divtema','','hide','mrcol','','hide','datosgenerales','','hide','datosalumno','','hide');
		}
		else {showHideLayers('divasunto','','show','divtema','','hide','mrcol','','hide','datosgenerales','','hide');}
	}
if(padre=="asunto") {
	if(opcion==0) {showHideLayers('divtema','','hide','mrcol','','hide','datosgenerales','','hide','datosalumno','','hide');}
	if(opcion==1) {showHideLayers('divtema','','hide','mrcol','','hide','datosgenerales','','show','datosalumno','','hide');}
	if(opcion==2) {showHideLayers('divtema','','show','datosgenerales','','hide','datosalumno','','hide','mrcol','','hide');}
	if(opcion==3) {showHideLayers('divtema','','show','datosgenerales','','hide','datosalumno','','hide','mrcol','','hide');}
	if(opcion==4) {showHideLayers('divtema','','show','datosgenerales','','hide','datosalumno','','hide','mrcol','','hide');}
	if(opcion==5) {showHideLayers('divtema','','show','datosgenerales','','hide','datosalumno','','hide','mrcol','','hide');}
	if(opcion==6) {showHideLayers('divtema','','hide','mrcol','','hide','datosgenerales','','show','datosalumno','','hide');}
	}
if(padre=="tema") {
	if(opcion==0) {showHideLayers('mrcol','','hide','datosgenerales','','hide','datosalumno','','hide');}
	else {showHideLayers('mrcol','','hide','datosgenerales','','show','datosalumno','','hide');}
}
	
}
// call to external Javascript/PHP file and pass Parent ID
function update_child( p_parent_option, lengua ) {
	// create new script element and set its relative URL (including ID argument)
	script = document.createElement( 'script' );
	script.src = 'components/com_buzon/external.php?parent_id=' + p_parent_option.value + '&lenguaje=' + lengua;
	
	// attach (load) script element to document head
	document.getElementsByTagName( 'head' )[0].appendChild( script );
}
