// Dimension of the div containing the message
	var secondaryDiv_x=500;
	var secondaryDiv_y=450;

	var window_x = 0;
	var window_y = 0;
	var document_x = 0;
	var document_y = 0;

	var idTimeout;

	var scrollTop;

    var getElementByIdPrefix = "";
    
	function hide_main(id) {

		if (navigator.appName == "Microsoft Internet Explorer"){
			scrollTop = document.documentElement.scrollTop;
		} else { 
			scrollTop = window.pageYOffset; 
		}
	
		getDimensions();
		
		//alert(scrollTop);
		//alert(window_y);
		
		
		// Get maximum x dimension
		if(window_x>document_x) {
			mainDiv_x=window_x;
		} else {
			mainDiv_x=document_x;
		}
	
		// Get maximum y dimension
		if(window_y>document_y) {
			mainDiv_y=window_y;
		} else {
			mainDiv_y=document_y;
		}
		
		// ################################################################
		// The DIV that will cover all the screen with opacity 50% (mainDiv)
		document.getElementById('mainDiv').style.width=(mainDiv_x)+"px";
		document.getElementById('mainDiv').style.height=(mainDiv_y)+"px";
		// Show the DIV
		document.getElementById('mainDiv').style.display='block';
		// Set DIV content
		innerHTML='<table border="0" width="100%" height="100%">';
		innerHTML+='<tr><td align="center" valign="center">&nbsp;<td><tr>';
		innerHTML+='</table>';
		document.getElementById('mainDiv').innerHTML=innerHTML;
		// Set DIV opacity
		document.getElementById('mainDiv').style.filter="alpha(opacity=50)";
		document.getElementById('mainDiv').style.opacity=".5";
		document.getElementById('mainDiv').style.MozOpacity=".5";
		
		// ################################################################
		// The DIV in the middle to display information (secondaryDiv)
		document.getElementById('secondaryDiv').style.width=(secondaryDiv_x)+"px";
		document.getElementById('secondaryDiv').style.height=(secondaryDiv_y)+"px";
		// Calculate position of secondaryDiv
		secondaryDiv_pos_x=(mainDiv_x/2)-(secondaryDiv_x/2);
		//secondaryDiv_pos_y=(mainDiv_y/2)-(secondaryDiv_y/2);
		secondaryDiv_pos_y=(window_y/2)-(secondaryDiv_y/2)+(scrollTop);
		
		// Set position
		document.getElementById('secondaryDiv').style.left=(secondaryDiv_pos_x)+"px";
		document.getElementById('secondaryDiv').style.top=(secondaryDiv_pos_y)+"px";
		// Show the DIV
		document.getElementById('secondaryDiv').style.display='block';
		// Set DIV content
		innerHTML='<table border="1" width="100%" height="100%">';
		innerHTML+='<tr><td align="center" valign="center"><iframe height="500" width="555" src="popquiz.aspx?idPopquiz='+id+'" frameborder="0" ></iframe></td></tr>';
		//innerHTML+='<tr><td style="height:15px">&nbsp;<input type="button" id="btClose" class="primButton" onclick="javascript:closeWindow()" value="» Cerrar"  /></td></tr>';
		innerHTML+='</table>';
		write_message(innerHTML);
		// Hide selects (for IE)
		hide_selects();
		hide_objects();
		
		// Calculate and set new position in 250ms
		idTimeout = setInterval("setPosition_y()", 250);
	
		return false
	}
	
	function hide_mainWindow(src) {
	
	    
	    alert(navigator.appName);
		if (navigator.appName == "Microsoft Internet Explorer"){
			scrollTop = document.documentElement.scrollTop;
		} else { 
			scrollTop = window.pageYOffset; 
		}
	    alert("hola tu2");
		getDimensions();
		alert("hola tu3");
		// Get maximum x dimension
		if(window_x>document_x) {
			mainDiv_x=window_x;
		} else {
			mainDiv_x=document_x;
		}
	    alert("hola tu4");
		// Get maximum y dimension
		if(window_y>document_y) {
			mainDiv_y=window_y;
		} else {
			mainDiv_y=document_y;
		}
		alert(document.getElementById('test_mainDiv'));
		// ################################################################
		// The DIV that will cover all the screen with opacity 50% (mainDiv)
		document.getElementById('mainDiv').style.width=(mainDiv_x)+"px";
		document.getElementById('mainDiv').style.height=(mainDiv_y)+"px";
		// Show the DIV
		document.getElementById('mainDiv').style.display='block';
		// Set DIV content
		innerHTML='<table border="0" width="100%" height="100%">';
		innerHTML+='<tr><td align="center" valign="center">&nbsp;<td><tr>';
		innerHTML+='</table>';
		document.getElementById('mainDiv').innerHTML=innerHTML;
		// Set DIV opacity
		document.getElementById('mainDiv').style.filter="alpha(opacity=50)";
		document.getElementById('mainDiv').style.opacity=".5";
		document.getElementById('mainDiv').style.MozOpacity=".5";
		alert("hola 4.1")
		alert(document.getElementById('secondaryDiv'));
		// ################################################################
		// The DIV in the middle to display information (secondaryDiv)
		document.getElementById('secondaryDiv').style.width=(secondaryDiv_x)+"px";
		document.getElementById('secondaryDiv').style.height=(secondaryDiv_y)+"px";
		// Calculate position of secondaryDiv
		secondaryDiv_pos_x=(mainDiv_x/2)-(secondaryDiv_x/2);
		secondaryDiv_pos_y=(window_y/2)-(secondaryDiv_y/2)+(scrollTop);
		
		// Set position
		document.getElementById('secondaryDiv').style.left=(secondaryDiv_pos_x)+"px";
		document.getElementById('secondaryDiv').style.top=(secondaryDiv_pos_y)+"px";
		// Show the DIV
		document.getElementById('secondaryDiv').style.display='block';
		 alert("hola tu5");
		// Set DIV content
		innerHTML='<table width="100%" height="100%">';
		innerHTML+='<tr><td align="center" valign="center"><iframe height="600" width="655" src="'+src+'" allowtransparency="false" frameborder="0"></iframe></td></tr>';
		innerHTML+='</table>';
		write_message(innerHTML);
		hide_selects();
		hide_objects();
		 alert("hola tu6");
		// Calculate and set new position in 250ms
		idTimeout = setInterval("setPosition_y()", 250);
	
		return false
	}

	function write_message(message) {
		document.getElementById('secondaryDiv').innerHTML=message;
	}

	function show_main() {
		// Reset timer for y position calculation
		clearTimeout(idTimeout);
	
		// Hide the DIVs
		document.getElementById('mainDiv').style.display='none';
		document.getElementById('secondaryDiv').style.display='none';
		
		// Show selects (for IE)
		show_selects();
		show_objects();
		return false
	}

	function hide_selects() {
		losSelect=document.getElementsByTagName('select');
		for(nombre in losSelect) {
			unSelect=document.getElementById(nombre);
			if(unSelect) {
				unSelect.style.visibility="hidden";
			}
		}
	}

	function show_selects() {
		losSelect=document.getElementsByTagName('select');
		for(nombre in losSelect) {
			unSelect=document.getElementById(nombre);
			if(unSelect) {
				unSelect.style.visibility="visible";
			}
		}
	}
	
	 hide_objects = function(){
        if (document.getElementsByTagName) {
            // Get all the tags of type object in the page.
            var objs = document.getElementsByTagName("object");
            
            for (i=0; i<objs.length; i++) {
                objs[i].style.visibility="hidden";
            }
            // Get all the tags of type applet in the page.
            var objs = document.getElementsByTagName("applet");
            //eval('var objs = '  + 'document.getElementsByTagName("applet")');
            for (i=0; i<objs.length; i++) {
                objs[i].style.visibility="hidden";
            }
        }
    }


     show_objects = function(){
        if (document.getElementsByTagName) {
          // Get all the tags of type object in the page.
          var objs = document.getElementsByTagName("object");
            //eval('var objs = ' + this.getElementByIdPrefix + 'document.getElementsByTagName("object")');
            for (i=0; i<objs.length; i++) {
        objs[i].style.visibility="visible";
            }
           // Get all the tags of type applet in the page.
           var objs = document.getElementsByTagName("applet");
            //eval('var objs = ' + this.getElementByIdPrefix + 'document.getElementsByTagName("applet")');
            for (i=0; i<objs.length; i++) {
        objs[i].style.visibility="visible";
            }
        }
     }

	function getDimensions() {
		// Try to get window dimensions
		try {
			window_x = document.documentElement.clientWidth;
			window_y = document.documentElement.clientHeight;
			document_x = document.body.clientWidth;
			document_y = document.body.clientHeight;
			//alert(window_x);
		}
		catch(err) {
			window_x = 0;
			window_y = 0;
			document_x = 0;
			document_y = 0;
		}
		//alert("wx "+window_x+"wy "+window_y+"dx "+document_x+"dy"+document_y)
	}

	function setPosition_y() {
		getDimensions();
		//alert(scrollTop);
		//alert(window_y);
		
	
		// Get maximum y dimension
		if(window_y>document_y) {
			mainDiv_y=window_y;
		} else {
			mainDiv_y=document_y;
		}
		
		// ################################################################
		// The DIV that will cover all the screen with opacity 50% (mainDiv)		
		document.getElementById('mainDiv').style.height=(mainDiv_y)+"px";
		if (navigator.appName == "Microsoft Internet Explorer"){
			scrollTop = document.documentElement.scrollTop;
		} else { 
			scrollTop = window.pageYOffset; 
		}
		// Calculate new position
		secondaryDiv_pos_y=(window_y/2)-(secondaryDiv_y/2)+(scrollTop);
		
		// Set position
		document.getElementById('secondaryDiv').style.top=(secondaryDiv_pos_y)+"px";
		
		// Set position
		
		//var stringTemp = document.getElementById('mainDiv').style.top;
		//var stringTemp2;
		//stringTemp2 = stringTemp.replace("px", "");
		//alert((stringTemp2*1)+scrollTop);
		//document.getElementById('mainDiv').style.top=((stringTemp2*1)+scrollTop)+"px";
	}
	
	// When the page loads:
window.onload = function(){
  if (document.getElementsByTagName) {
    // Get all the tags of type object in the page.
      var objs = document.getElementsByTagName("object");
      for (i=0; i<objs.length; i++) {
        // Get the HTML content of each object tag
        // and replace it with itself.
        objs[i].outerHTML = objs[i].outerHTML;
      }
   }
}
// When the page unloads:
window.onunload = function() {
  if (document.getElementsByTagName) {
    //Get all the tags of type object in the page.
    var objs = document.getElementsByTagName("object");
    for (i=0; i<objs.length; i++) {
      // Clear out the HTML content of each object tag
      // to prevent an IE memory leak issue.
      objs[i].outerHTML = "";
    }
  }
}


function closeWindow()
			{
				//unblock parent window
				show_main();
				//close popup
				//window.close();
			}