// JavaScript Document

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) {
  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_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break; 
	}  
		return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function chfpp(vfpp, vpagina){	
  document.formSearch02.vfpp.value 	  = vfpp;
  document.formSearch02.pactual.value = vpagina;
  document.formSearch02.submit();
} 
function chpag(page){
  document.formSearch02.pactual.value = page;
  document.formSearch02.submit();
} 

function imgprops(ref)
{
  document.formImgProps.img.value = ref;
  document.formImgProps.submit();  
}

function imgprops_keyword(ref, keyword)
{
  document.formImgProps.img.value 	  	  = ref;
  document.formImgProps.img_keyword.value = keyword;
  document.formImgProps.submit();  
}

function goPage(m) {
  if (!e) var e=window.event;
  var S=e.srcElement;
  if (S==undefined) S = e.currentTarget
  while (S.tagName!="TD"){
    S = S.parentElement;
  }
  n = S.childNodes.length
  for(i=0;i<n;i++) {
	obj = S.childNodes[i]
	if(obj.id=="go") i = n;
  }
  if(obj.value>0) {
    if(obj.value<=m && obj.value >0) { chpag(obj.value); }
    else chpag(m)
  }
}

function jsTrim(JSvalue) { 
	var JStemp = JSvalue;
	var JSobj = /^(\s*)([\W\w]*)(\b\s*$)/;
	
	if (JSobj.test(JStemp)) { JStemp = JStemp.replace(JSobj, "$2"); }
	
	var JSobj = / +/g;
	JStemp = JStemp.replace(JSobj, " ");
	if (JStemp == " ") { JStemp = ""; }
	return JStemp;
}

function goUrl(url) {
	parent.location = url;
}

function openUrl(url) {
  w = 500
  h = 650
  l = frameWidth / 2 - (w/2);   t = frameHeight / 2 - (h/2);	
  winNews = window.open(url, "", "width="+w+", height="+h+", left="+l+", top="+t+", status=yes, scrollbars=yes, resizable=yes");	
}

function toCart(ref, format) {
  form = MM_findObj("formCart");
  form.img.value    = ref;  
  if(format != "") form.format.value = format;
  form.submit();	
}

function f_subs_download(ref, format, uid1, uid2) {
	window.location = "/hires/"+uid1+"/"+uid2+"/"+format+"/"+ref+".jpg";
}

function showMenu(type) {	
  switch(type) {
	case "finder": 	MM_showHideLayers('op1','','show','op2','','hide','op3','','hide');	break;
	case "user":	MM_showHideLayers('op1','','hide','op2','','show','op3','','hide'); break;
	case "photer":	MM_showHideLayers('op1','','hide','op2','','hide','op3','','show'); break;
  }
}

/* delete from here */

function chSection() { showMenu(document.headSect); }

function headSection() {
  d = document;
  a = headSection.arguments;
  if(a.length==2) { d.headSect = a[1]; d.intSection = setTimeout("chSection();", 2500); } else { clearTimeout(d.intSection) }
}

/* to here */

function MO(e, type, obj, img) {
  if (!e) var e=window.event;
  var S=e.srcElement;
  if (S==undefined) S = e.currentTarget;
  if(S.tagName=="IMG") {
	  switch(type) {
		case "Cov" :   S.src = "../../img/shopcart03.gif";		break;
		case "Iov" :   S.src = "../../img/imginfo01.gif";		break;
		case "CDov":   S.src = "../../img/cdinfo01.gif";		break;
		case "Cout" :  S.src = "../../img/shopcart02.gif";		break;
		case "Iout" :  S.src = "../../img/imginfo00.gif";		break;
		case "CDout":  S.src = "../../img/cdinfo00.gif";		break;
		case "OCov" :  S.src = "../../img/shopcart05.gif";		break;
		case "OCout":  S.src = "../../img/shopcart04.gif";		break;
	  }
	obj = MM_findObj(obj);
	if(img=="0") obj.src = "../../img/trans.gif";
	else obj.src = "../img/imgtxt0"+img+".gif";
  }
}

function MO_img_coll(img, type, obj, c) {
	switch(type) {
		case "Cov"  :  img.src = "../../img/shopcart03.gif";	break;
		case "Iov"  :  img.src = "../../img/imginfo01.gif";		break;
		case "Cout" :  img.src = "../../img/shopcart02.gif";	break;
		case "Iout" :  img.src = "../../img/imginfo00.gif";		break;
	}
	obj = MM_findObj(obj);
	obj.className = c;
}

function MOobject(obj, c) {
	obj = MM_findObj(obj);
	if(obj) obj.className = c;
}

function MOthis(obj, c) {
	obj.className = c;
}

function Mbtn(e, type) {
  if (!e) var e=window.event;
  var S=e.srcElement;
  if (S==undefined) S = e.currentTarget
  else {
    while (S.tagName!="TD"){
	  S = S.parentElement;
	}
  }
  S.className=type;
}

function Browser() {
  this.dom = document.getElementById?1:0;
  this.ie4 = (document.all && !this.dom)?1:0;
  this.ns4 = (document.layers && !this.dom)?1:0;
  this.ns6 = (this.dom && !document.all)?1:0;
  this.ie5 = (this.dom && document.all)?1:0;
  this.ok  = this.dom || this.ie4 || this.ns4;
  this.platform	= navigator.platform;
  this.agntUsr	= navigator.userAgent.toLowerCase();
  this.appl		= navigator.appName;
}

var browser = new Browser();

function enter() {
	username = MM_findObj("username_box");
	password = MM_findObj("password_box");
	form	 = MM_findObj("formEnter");
	if(username.value=="") username.focus();
	else {
	  if(password.value=="") password.focus();
	  else {
		form.username.value = username.value;
		form.password.value = password.value;
		form.submit();
	  }
	}
}

function next_field(objfoco, e) {
   valor = e.keyCode ? e.keyCode : e.which;
   if (valor == 13){ 
   	   obj = MM_findObj(objfoco)
	   obj.focus();
    } 
}

function idUser(e) {
  valor = e.keyCode ? e.keyCode : e.which;
  if (valor == 13) {
	enter();
  }  
}

function find_id_tp() {
	var i;
	var id;
	id = MM_findObj("id_tp");  	 
    for (i=0;i<id.length;i++) { if (id[i].checked) break;  }	
	return(id[i].value);
}

// AJAX
function fobjetus() {         
	try {                 
		objetus = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		objetus= new ActiveXObject("Microsoft.XMLHTTP");    
		} catch (E) {                         
			objetus= false;                 
		}
	}
	if (!objetus && typeof XMLHttpRequest!='undefined') objetus = new XMLHttpRequest();
	return (objetus)
}
