var keycode;
var req = false;
var windowHeight = 0;

function openGoogleDir() {
	top.window.open('http://maps.google.es/maps?f=q&view=text&hl=es&q=Gremio+del+Cuero+HONTORIA+Segovia&ie=UTF8&ll=40.910026,-4.113801&spn=0.00793,0.012145&z=16&iwloc=addr');
}
function hoy() {
	var months=new Array(13);
	months[1]="Enero";
	months[2]="Febrero";
	months[3]="Marzo";
	months[4]="Abril";
	months[5]="Mayo";
	months[6]="Junio";
	months[7]="Julio";
	months[8]="Agosto";
	months[9]="Septiembre";
	months[10]="Octubre";
	months[11]="Noviembre";
	months[12]="Diciembre";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000) 
	year = year + 1900; 
        var hoy= date+" de "+lmonth+" de "+year;
        return hoy;
}
function nowindowstatus() {
window.status="© dihose";
return true;
}
document.onmouseover = nowindowstatus;
document.onmouseout = nowindowstatus;

function NewWindow(mihref){
caracteristicas= "width=770,height=580,top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
popup = window.open(mihref,"ventana",caracteristicas);
popup.focus();
}
/*var catPath = "imagenes/";
var catPics = new Array;

catPics[0] = new Array("undiablanco.jpg",530,200);
catPics[1] = new Array("videoconf.gif",90,90);
catPics[2] = new Array("domic.gif",90,90);
catPics[3] = new Array("grup.jpg",90,90);
catPics[4] = new Array("escuelapad.jpg",90,90);
catPics[5] = new Array("superv.jpg",90,90);
catPics[6] = new Array("promoc.jpg",90,90);
catPics[7] = new Array("logo_psiquiatria.gif",120,26);
catPics[8] = new Array("copsi.gif",120,79);
catPics[9] = new Array("sepcys.gif",120,66);
catPics[10] = new Array("seas.gif",120,60);
catPics[11] = new Array("amsm.gif",120,69);
catPics[12] = new Array("aen.gif",120,119);
catPics[13] = new Array("semc&ps.gif",120,25);
catPics[14] = new Array("aseteccs.png",120,73);
catPics[15] = new Array("llegar.gif",90,60);
catPics[16] = new Array("laber2.gif",85,86);
catPics[17] = new Array("lpsi.gif",75,99);

var myPics = preloadImages(catPath,catPics);
*/
function preloadImages(path,pics) {
        var images = new Array;
        for (var picNum=0; picNum<pics.length; picNum++)
            {
            images[picNum] = new Image(pics[picNum][1],pics[picNum][2]);
            images[picNum].src = (path + pics[picNum][0]);
            }
        return (images);
}
function cierra_child(id){
           var body = document.getElementsByTagName('body')[0];
           var d01 = document.getElementById(id);
           var quita = body.removeChild(d01);
}
function curriculum(){
}
function cogerVariable(variable){
	var tipo = typeof variable;
	var direccion = location.href;
	if (tipo == "string"){
		var posicion = direccion.indexOf("?");
		posicion = direccion.indexOf(variable,posicion) + variable.length;
	}
	else if (tipo == "number"){
		var posicion=0;
		for (var contador = 0 ; contador < variable + 1 ; contador++){
			posicion = direccion.indexOf("=",++posicion);
			if (posicion == -1)posicion=999;
		} 
	}
	if (direccion.charAt(posicion) == "="){
		var final = direccion.indexOf("&",posicion);
		if (final == -1){final=direccion.length;};
		return direccion.substring(posicion + 1,final);
	}
}

function contarVariables(){
	var direccion = self.location.href;
	var posicion = direccion.indexOf("?");
	for (var contador = -1 ; posicion != -1 ; ++contador){
		posicion = direccion.indexOf("=",++posicion);
	}
				
	if (contador < 0)contador=0;
				
	return contador;
}
function nombreVariable(variable){
	var tipo = typeof variable;
	var direccion = location.href;
	if (tipo == "string"){
		var posicion = direccion.indexOf("?");
		if ((posicion > 0) && (direccion.indexOf(variable,posicion) > -1))
			posicion = direccion.indexOf(variable,posicion);
		else
			posicion = 0;
		
	}
	else if (tipo == "number"){
		var posicion = 0;
		posicion = direccion.indexOf("?");
		for (var contador = 0 ; ((contador < variable) && (posicion != -1)) ; contador++){
			posicion = direccion.indexOf("&", ++posicion);
		} 
		posicion++;
	}
	if (posicion > 0){
		var final = direccion.indexOf("=",posicion);
		if (final == -1){final=direccion.length;};
		return direccion.substring(posicion,final);
	}
	
}
function winload(){
	if(contarVariables()>0) {
		  for (var cont=0 ; cont < contarVariables() ; cont++){
               		wid=cogerVariable(cont).replace("#","")+".htm";
		}
    }else{
                  wid="pordefecto.htm"
    }
    winner="<iframe name='fr2' id='fr2' src='" + wid + "' height='628' width='698' FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 ALLOWTRANSPARENCY='true'></iframe>";
    document.getElementById("ifr2").innerHTML=winner;
    winloadresizeifr('fr2','fr2');
}
function getWindowData(n,i){
var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
if (typeof(window.innerHeight) == 'number'){
	var ifr=document.getElementById(i).contentWindow.document;
	widthViewport= window.frames[n].innerWidth;
	heightViewport= window.frames[n].innerHeight;
	xScroll=window.frames[n].pageXOffset;
	yScroll=window.frames[n].pageYOffset;
	widthTotal=Math.max(ifr.documentElement.scrollWidth,ifr.body.scrollWidth,widthViewport);
	heightTotal=Math.max(ifr.documentElement.scrollHeight,ifr.body.scrollHeight,heightViewport);
	if (heightTotal<628) heightTotal=628;
}else if(document.documentElement && document.documentElement.clientHeight){
	var ifr=document.getElementById(i).contentWindow.document;
	widthViewport=ifr.documentElement.clientWidth;
	heightViewport=ifr.documentElement.clientHeight;
	xScroll=(ifr.documentElement.scrollLeft+ifr.body.scrollLeft);
	yScroll=(ifr.documentElement.scrollTop+ifr.body.scrollTop) ;
	widthTotal=Math.max(ifr.documentElement.scrollWidth,ifr.body.scrollWidth,widthViewport);
	heightTotal=eval(document.getElementById(i).contentWindow.document.body.scrollHeight);
}else{
	var ifr=document.getElementById(i).contentWindow.document || document.getElementById(i).contentDocument;
	widthViewport= ifr.getElementsByTagName('body')[0].clientWidth;
	heightViewport=ifr.getElementsByTagName('body')[0].clientHeight;
	xScroll=window.frames[n].pageXOffset || (ifr.documentElement.scrollLeft+ifr.body.scrollLeft);
	yScroll=window.frames[n].pageYOffset || (ifr.documentElement.scrollTop+ifr.body.scrollTop) ;
	widthTotal=Math.max(ifr.documentElement.scrollWidth,ifr.body.scrollWidth,widthViewport) || Math.max(document.getElementById(i).document.documentElement.scrollWidth,document.getElementById(i).document.body.scrollWidth,widthViewport);
	heightTotal=Math.max(ifr.documentElement.scrollHeight,ifr.body.scrollHeight,heightViewport) || Math.max(document.getElementById(i).document.documentElement.scrollHeight,document.getElementById(i).document.body.scrollHeight,heightViewport);
	if (heightTotal<628) heightTotal=628;
}
return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
}
function resizeIframe(ID,NOMBRE){
document.getElementById(ID).height=null;
//document.getElementById(ID).width=null;
window.location='#';//necesario para safari
var m=getWindowData(NOMBRE,ID);
document.getElementById(ID).height=m[5];
//document.getElementById(ID).width=m[4]+22;
}
function addEvent(obj, evType, fn, useCapture){

if (obj.addEventListener){
obj.addEventListener(evType, fn, useCapture);

} else if (obj.attachEvent){
obj.attachEvent("on"+evType, fn);

} else {
obj['on'+evType]=fn;
}
}
function winloadresizeifr(id){
	addEvent(document.getElementById(id), 'load', function(){resizeIframe(id,id);}, false);
	document.getElementById('ifr2').style.display= "block";
	document.getElementById('ifr2').style.visibility= "visible";
}

