function getCell(id){
  return document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : document.layers ? document['NS_' + id].document.layers[0] : null
}
function getCell2(id){
  return window.document.parent.all ? window.document.parent.all(id) : window.document.parent.getElementById ? window.document.parent.getElementById(id) : window.document.parent.layers ? document['NS_' + id].window.document.parent.layers[0] : null
}

function CheckBrowser(){
  var br = new Object();
  br.isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
  br.NS4 = (document.layers) ? true : false;
  br.IEmac = ((document.all)&&(br.isMac)) ? true : false;
  br.IE4plus = (document.all) ? true : false;
  br.IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
  br.IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
  br.IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
  ver4 = (br.NS4 || br.IE4plus) ? true : false;
  br.NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

  br.IE5plus = br.IE5 || br.IE6;
  br.IEMajor = 0;

  if (br.IE4plus){
    var start = navigator.appVersion.indexOf("MSIE");
    var end = navigator.appVersion.indexOf(".",start);
    br.IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
    br.IE5plus = (br.IEMajor>=5) ? true : false;
  }
  return br
}

var Browser = CheckBrowser();

//Returns the document object
function getImage(id){
  if (Browser.IE4plus || Browser.IEmac) return document.all[id];
  if (Browser.NS4) return document.images[id];
  if (Browser.NS6) return document.getElementById(id);
}

//Returns the document object
function getElement(id){
  if (Browser.IE4plus || Browser.IEmac) return document.all[id];
  if (Browser.NS4) return document[id];
  if (Browser.NS6) return document.getElementById(id);
}

// Función para mostrar las imágenes en una ventana limpia.
//var _img_grande;

/*function mostrar(title, titlefoto, descfoto) {
	alert("hola");
  var ops = "top=" + ((screen.height - _img_grande.height) / 2);
  ops += ",left=" + ((screen.width - _img_grande.width) / 2);
  ops += ",width=" + _img_grande.width + ",height=" + _img_grande.height;
  var contenido = "<html><title>"+title+"</title><body style='cursor: pointer; margin:0; background-image: url(" + _img_grande.src + ")' onClick='self.moveTo(0,0); resizeTo(0,0); self.close();' title='Haz click para cerrar la ventana'>";
  contenido += "<div style='width:10px; height:100%; position:absolute; left:0px; top:0px; background-color:#fff;'></div>";
  contenido += "<div style='width:10px; height:100%; position:absolute; right:0px; top:0px; background-color:#fff;'></div>";
  contenido += "<div style='width:100%; height:10px; font-size:5px; position:absolute; left:0px; top:0px; background-color:#fff;'></div>";
  contenido += "<div style='margin-right:15px; height:10px; font:bold 14px Arial; color:#5e1b3e; position:absolute; right:0px; bottom:60px; text-transform:uppercase; z-index:100;'>"+titlefoto+"</div>";
  contenido += "<div style='margin-right:15px; height:10px; font:normal 11px Arial; color:#5e1b3e; position:absolute; right:0px; bottom:45px; z-index:100;'>"+descfoto+"</div>";
  contenido += "<div style='width:100%; height:80px; font-size:5px; position:absolute; left:0px; bottom:0px; background-color:#fff;'><img src='img/public/popup/logo.jpg' style='margin:6px 10px;'></div>";
  contenido += "</body></html>";
  var ventana = window.open("", "", ops);
  ventana.document.write(contenido);
  ventana.document.close();
}

function cargando(title, titlefoto, descfoto) {
  if(_img_grande.complete){
	  mostrar(title, titlefoto, descfoto);
  }else{
	  setTimeout("cargando('"+title+"', '"+titlefoto+"', '"+descfoto+"')", 100);
  }
}

function abrir(imagen, title, titlefoto, descfoto){
	alert("hola");
  if(!title){title= "GIMSA ˇ Imagen Personal";}
  if(!titlefoto){titlefoto= "&nbsp;";}
  if(!descfoto){descfoto= "&nbsp;";}
  _img_grande = new Image();
  _img_grande.onload = function(){cargando(title, titlefoto, descfoto);};
  _img_grande.src = imagen;
  //cargando(title, titlefoto, descfoto);
}*/

var blackDiv;
function abrir(imagen, title, titlefoto, descfoto){
	showBlack();
	var img=new Image();
	$(img).load(function(){
		var content="<div style='width:"+img.width+"px; height:"+img.height+"px; position:absolute; left:0px; top:0px; background-image: url(" + imagen + ")'></div>";
		content += "<div style='width:10px; height:100%; position:absolute; left:0px; top:0px; background-color:#fff;'></div>";
		content += "<div style='width:10px; height:100%; position:absolute; right:0px; top:0px; background-color:#fff;'></div>";
		content += "<div style='width:100%; height:10px; font-size:5px; position:absolute; left:0px; top:0px; background-color:#fff;'></div>";
		content += "<div style='margin-right:15px; height:10px; font:bold 14px Arial; color:#5e1b3e; position:absolute; right:0px; bottom:60px; text-transform:uppercase; z-index:100;'>"+titlefoto+"</div>";
		content += "<div style='margin-right:15px; height:10px; font:normal 11px Arial; color:#5e1b3e; position:absolute; right:0px; bottom:45px; z-index:100;'>"+descfoto+"</div>";
		content += "<div style='width:100%; height:80px; font-size:5px; position:absolute; left:0px; bottom:0px; background:#fff url(img/public/popup/logo.jpg) no-repeat 15px 5px;'></div>";
		content += "<div style='width:20px; height:20px; position:absolute; right:0px; top:0px; background:#fff;color:black;line-height:20px; font:bold 15px tahoma;cursor:pointer;'>X</div>";
		var container=document.createElement("DIV");
		var size=pageSize();
		container.innerHTML=content;
		$(container).css({position:'fixed', cursor:'pointer', left:parseInt(size[0]/2-img.width/2)+'px', top:parseInt(size[1]/2-img.height/2)+'px', background:'white', border:'1px solid #ccc', width:img.width+'px', height:img.height+'px', zIndex:'101'});
		document.body.appendChild(container);
		$(container).click(function(){
			$(container).remove();
			$(blackDiv).css('display', 'none');
		});
	});
	img.src=imagen;
}

pageSize=function(){
	//funcion que pone el alto y ancho a la capa gris
	var altoPag;
	var anchoPag;
	if( typeof( window.innerWidth ) == 'number' ) {
	  //Non-IE
	  anchoPag = window.innerWidth;
	  altoPag = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  //IE 6+ in 'standards compliant mode'
	  anchoPag = document.documentElement.clientWidth;
	  altoPag = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	  //IE 4 compatible
	  anchoPag = document.body.clientWidth;
	  altoPag = document.body.clientHeight;
	}
	return [anchoPag, altoPag];
}

function createBlack(){
	var black=document.createElement("DIV");
	var size=pageSize()
	$(black).css({position:'fixed', left:'0', top:'0', background:'black url(img/public/loading.gif) no-repeat center', height:size[1]+'px', width:size[0]+'px', opacity:'.6', filter:'alpha(opacity=60)', display:'none', zIndex:'100'});
	document.body.appendChild(black);
	return black;
}

function showBlack(){
	$(blackDiv).css('display', '');
}
	
//

function abrirVideo(video, ancho, alto) {
  var ops = "top=" + ((screen.height - alto) / 2);
  ops += ",left=" + ((screen.width - ancho) / 2);
  ops += ",width=" + ancho + ",height=" + alto;
  var contenido = "<html><title>Dia Mundial del Agua 2007</title><meta http-equiv='refresh' content='0.5;url=../../../../flash/video.swf'></html>";
  var ventana = window.open("", "", ops);
  ventana.document.write(contenido);
  ventana.document.close();
}

if(screen.width>1024) var wsize="_L";
if(screen.width==1024) var wsize="_M";
if(screen.width<1024) var wsize="_S";

function privacidad(){
	var pDiv = document.getElementById('politica');
	if(pDiv.style.display == 'none'){
		pDiv.style.display = '';
	}else{
		pDiv.style.display = 'none';
	}
}

//FUNCION QUE ENVIA A LOS PRODUCTOS
sendTo=function(URL, urlIfr){
	var ifr=document.createElement('IFRAME');
	$(ifr).css('display', 'none');
	document.body.appendChild(ifr);
	$(ifr).load(function(){
		var form=document.createElement('FORM');
		form.action=URL;
		form.target='_blank';
		form.method="GET";
		$(form).css('display', 'none');
		var paramsString = URL.substring(URL.indexOf('?') + 1, URL.length);
		var paramsArray = paramsString.split('&');

		for (var i = 0; i < paramsArray.length; ++i) {
			var elementIndex = paramsArray[i].indexOf('=');
			var elementName = paramsArray[i].substring(0, elementIndex);
			var elementValue = paramsArray[i].substring(elementIndex + 1, paramsArray[i].length);
			var temporalElement = document.createElement('input');
			with(temporalElement) {
				setAttribute('type', 'hidden');
				setAttribute('name', elementName);
				setAttribute('value', elementValue);
			}
			form.appendChild(temporalElement);
		}
		document.body.appendChild(form);
		form.submit();
		$(form).remove();
		$(ifr).remove();
	});
	ifr.src=urlIfr;
}
