var ancho=screen.width/2;
var alto=screen.height/2;
var IE = document.all?true:false;
//--------------------------------------------------MACROMEDIA-----------------------------------//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MF(lnk,id,w,h){
	cb="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
	ci="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	tp="application/x-shockwave-flash";
	pp="http://www.macromedia.com/go/getflashplayer";
	obj ="<object classid=\""+ci+"\" codebase=\""+cb+"\" width=\""+w+"\" height=\""+h+"\" id=\""+id+"\" align=\"middle\">";
	obj+="<param name=\"allowScriptAccess\" value=\"sameDomain\"/>";
	obj+="<param name=\"movie\" value=\""+lnk+"\"/>";
	obj+="<param name=\"quality\" value=\"high\"/>";
	obj+="<param name=\"bgcolor\" value=\"#ffffff\"/>";
	obj+="<embed src=\""+lnk+"\" quality=\"high\" bgcolor=\"#ffffff\" width=\""+w+"\" height=\""+h+"\" name=\""+id+"\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\""+tp+"\" pluginspage=\""+pp+"\" />";
	obj+="</object>";
	document.write(obj);
}
//-----------------------------------------------------------------------------------------------//

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};
function getPos(id){
	xx=0;yy=0;
	obj=document.getElementById(id);
	if(obj.offsetParent){
		xx=obj.offsetLeft;
		yy=obj.offsetTop;
		while(obj=obj.offsetParent){
			xx+=obj.offsetLeft;
			yy+=obj.offsetTop;
		}
	}
	r=new Array(xx,yy);
	return r;
}
function VerificaEmail(correo){
	ret=true;
	var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
	var reg1 = new RegExp(reg1str);
	var reg2 = new RegExp(reg2str);
	if (reg1.test(correo) || !reg2.test(correo)) ret=false;
	return ret;
}
function ajaxSEND(url,metodo,variables,f){
	http_request = false;
	if(window.XMLHttpRequest){
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
		}
	}else if(window.ActiveXObject){
		try{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){}
		}
	}
	if(!http_request){
		alert('Cannot create XMLHTTP instance');
		return false;
	}      
	http_request.onreadystatechange = function(){
		if(http_request.readyState == 4){
			if (http_request.status == 200) {
				f(http_request.responseText);
			}else{
				alert('There was a problem with the request.');
			}
		}
	}
	if(metodo='GET'){
		http_request.open('GET', url, true);
		http_request.send('');
	}else{
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", variables.length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(variables);
	}
}
function miembros(t,i){
	respuesta=function(v){
		document.getElementById('td_miembros').innerHTML=v;
	}
	ajaxSEND("miembros.php?cat="+t+"&id="+i,"GET",'',respuesta);
}
function verifcaBusqueda(){
	r=true;
	nombre=document.getElementById('oftalmologo').value;
	if(nombre.length<=2){
		alert("Debe de ingresar el nombre y/o apellido de su oftalmólogo");
		r=false;
	}
	return r;
}
function verificaContacto(){
	r=true;
	alerta="";
	nombres=document.getElementById('nombres').value;
	correo=document.getElementById('correo').value;
	comentario=document.getElementById('comentario').value;
	if(nombres.length<=2){
		alerta+="Debe de ingresar su nombre\n";
		r=false;
	}
	if(!VerificaEmail(correo)){
		alerta+="Debe de ingresar una cuenta de correo válida\n";
		r=false;
	}
	if(comentario.length<=10){
		alerta+="Debe de ingresar su comentario o consulta";
		r=false;
	}
	if(!r) alert(alerta);
	return r;
}
function ventana(p){
	window.open(p,"",'width=510,height=535,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,left='+(ancho-305)+',top='+(alto-300));
}
