// JavaScript Document

//
// Funciones Standard de Dreamweaver
//
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 MM_showHideLayers() { //v6.0
  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; }
}

//
// Funciones Genericas
//
function popup(a,titulo,ancho, alto) {
	var windowprops = "width="+ancho+",height="+alto+",outerwidth=0,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, status=no, location=no, resizable=no";
	window.open(a,titulo,windowprops);
}


var i=0;
function resize() {
  if (navigator.appName == 'Netscape') i=40;
  if (document.images[0]) window.resizeTo(document.images[0].width, document.images[0].height+60-i);
  self.focus();
}

function resizeIframe() {
	// Must launched on the body onload event handler for IE
	// Use document.documentElement if you are in Compat mode
	i = parent.document.getElementById(window.name)
	iHeight = document.body.scrollHeight
	i.style.height = iHeight + 5 + "px"
}


function makevisible(cur,which){
strength=(which==0)? 1 : 0.2
if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

function borderit(which,color){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
which.style.borderColor=color
}
}

function seoChars(formulario, field_name) {
	var field_value = formulario.elements[field_name].value;
	document.getElementById('CAR'+field_name).innerHTML =field_value.length ;
  
}

/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TR"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}



function OnOff( cual, estado ) {
		document.getElementById(cual).style.display=estado;
}

function popupImage(img, titulo) {
	var salto="\r\n";
	var win = window.open("", "win", "width=600,height=412"); 
	var html_begin="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+salto+"<html xmlns=\"http://www.w3.org/1999/xhtml\">"+salto;
	var html_headI="<head>"+salto+"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />"+salto+"<title>"+titulo+"</title>"+salto;
	var html_headF="</head><body onload=\"agrandar(50);\">"+salto;
	var html_end="</body>"+salto+"</html>";
	var html_css="<style type=\"text/css\">"+salto+"<!-- "+salto+"body {  margin: 0px; } "+salto+"-->"+salto+" </style>"+salto;
	var html_img="<img name='imagen' id='imagen' src='"+img+"' />"+salto;

	var scriptStart="<";
	var scriptEnd=">";
	var scriptI=scriptStart+ "script  type=\"text/JavaScript\""+scriptEnd;
	var scriptF=scriptStart+ "/script"+scriptEnd;

var html_js=scriptI+salto+"function agrandar (extrapix) {   	"+salto+"var w=imagen.width ;"+salto+"var h=imagen.height + parseInt(extrapix);		"+salto+"var sh=screen.height;		"+salto+"var sw=screen.width;		"+salto+"if (h > sh) {h=sh-40}		"+salto+"if (w > sw) {w=sw-40}	"+salto+"			self.resizeTo(w,h);	}	"+salto+"self.scrollbars.visible = 0;	"+salto+""+scriptF+salto;


	var htmlX=html_begin+html_headI+html_css+html_js+html_headF+html_img+html_end;
	with (win.document) {
	  open("text/html", "replace");
	  write(htmlX);
	  close();
	}
}


function calcularAlto(idiframe){
  document.getElementById(idiframe).height=document.getElementById(idiframe).contentWindow.document.body.scrollHeight;
}

/* Funcion Random mas oportunidades */
function randomArray(muestra, universo)
	{if (universo < muestra)
		{vec = randomArray(universo, universo);
		 }
	 else
		{vec = new Array(muestra);
		 for(ii = 0; ii < muestra; ii++)
			{repetido = true;
			 while (repetido)
				{nn = Math.floor((Math.random() * universo));
				 repetido = false;
				 for(jj = 0; jj < ii; jj++)
					if (vec[jj] == nn)
						repetido = true;
				 }
			 vec[ii] = nn;
			 }
		 }
	return vec;
	}

/* POPUP */
function Popup(url,name,width,height,resize,scroll) {
	var dialogWin = new Object();
	dialogWin.width = width;
	dialogWin.height = height;
	now = new Date();
	var millis=now.getTime();
	var mstr=""+millis;
	if (navigator.appName == "Netscape") {
		dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
		dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
		var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	} else if (document.all) {
		dialogWin.left = (screen.width - dialogWin.width) / 2;
		dialogWin.top = (screen.height - dialogWin.height) / 2;
		var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	}
window.open(url,name,attr);
}

/****************/
function toggler(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
function toggler_estilo(obj) {
	var el = document.getElementById(obj);
	if ( el.className != 'chat_chico' ) {
		el.className = 'chat_chico';
	}
	else {
		el.className = 'chat_grande';
	}
}
/****************/
function ShowHide(LayerName,TotalLayers){//v1.0
	var temp = new Array();
	temp = LayerName.split('_');
	ReLayerName = temp[0];
	
		for (i=1;i<=TotalLayers;i++){
		document.getElementById(ReLayerName+'_'+i).style.display = 'none';
		}
	document.getElementById(LayerName).style.display = 'block';
}
/****************/

