function runSWF(archivo, ancho, alto, version, bgcolor, id,idm, menu, FlashVars, quality, allowScriptAccess) {
	if(version!=""){
  	var version_data=version;
  }else{
  	var version_data="6,0,0,0";
  }
  
  if(menu!=""){
  	menu_data=menu;
  }else{
  	menu_data=false;
  }
  if(bgcolor!=""){
  	var bgcolor_data=bgcolor;
  }else{
  	var bgcolor_data="#FFFFFF";
  }
  if(id!=""){
  	id_data=id;
  }else{
  	id_data="flashMovie";
  }
  if(quality!=""){
  	quality_data=quality;
  }else{
  	quality_data="high";
  }
  if(allowScriptAccess!=""){
  	allowScriptAccess_data=allowScriptAccess;
  }else{
  	allowScriptAccess_data="always";
  }
  
  var quality="high"; 
  
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
  document.write('<param name="movie" value='+archivo+'>\n');
  document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n');
  document.write('<param name="quality" value='+quality_data+'>\n');
  document.write('<param name="FlashVars" value='+FlashVars+'>\n');
  document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
  document.write('<param name="wmode" value="transparent" >\n');
  document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true id='+idm+' wmode="transparent" ></embed>');
  document.write('</object>\n');
}

function VerCategoria(idCategoria)
{
	//var categorias = 'categorias_'+idCategoria;
	window.location.href = "index.php?page=integrantes&sec=5&categoria="+idCategoria;
	//document.getElementById(categorias).style.backgroundColor   = '#D3DFF7';
}	

function iraPagina(pageNumber)
{
	document.getElementById("frm").pageNumber.value = pageNumber;
	document.getElementById("frm").submit();
}

function b_over(but){
  b_source = but.src;
  but.src  = b_source.replace(".gif","_over.gif");
}
function b_out(but){
  b_source = but.src;
  but.src  = b_source.replace("_over.gif",".gif");
}

function $(obj){
  return document.getElementById(obj)
}

function isMSIE(){
	return (navigator.appName == "Microsoft Internet Explorer");
}

function trim(valor){
	var re = /^(\s)*|(\s)*$/;
	var str = (valor ? valor : this);
	return str.replace(re,'');
}
String.prototype.trim = trim;

function dump(o)
{
	var str = "";
	for(p in o)
	{
		str += "\t" + p + " => " + o[p] + "\r\n";
	}
	str = "(" + typeof(o) + ") " + o + " {\r\n" + str + "}";
	return str;
}

function dumpWindow(o)
{
	var hw         = popup('', 'Debug', 600, 600, 'yes', 'yes');
	var htmlDump = dump(o).replace(/<(\/)?script/gi,'< $1script');
	var htmlDoc = '<html><body><pre style="font: 13px \'Courier New\'">%1</pre></body></html>'
	htmlDoc = sprintf(htmlDoc, htmlDump);
	hw.document.open();
	hw.document.write(htmlDoc);
	hw.document.close();
}
function sprintf()
{
	if(arguments.length==0) return '';
	var str = arguments[0];
	for(var i=arguments.length-1; i>0; --i)
	{
		var re = new RegExp("%" + i,"i");
		str = str.replace(re, arguments[i]);
	}
	return str;
}

function popup(url, name, width, height, isResizable, hasScrollbars, hasToolbar, hasMenubar, hasStatus)
{
	isResizable   = typeof(isResizable)   =='undefined' ? 'no'  :isResizable;
	hasScrollbars = typeof(hasScrollbars) =='undefined' ? 'auto':hasScrollbars;
	hasToolbar    = typeof(hasToolbar)    =='undefined' ? 'no'  :hasToolbar;
	hasMenubar    = typeof(hasMenubar)    =='undefined' ? 'no'  :hasMenubar;
	hasStatus     = typeof(hasStatus)     =='undefined' ? 'yes' :hasStatus;

	var top = (screen.height - height) / 2;
	var left = (screen.width - width) / 2;
	var settings = 'width=%1, height=%2, top=%3, left=%4, resizable=%5, scrollbars=%6, toolbar=%7, menubar=%8, status=%9';
	settings = sprintf(settings, width, height, top, left, isResizable, hasScrollbars, hasToolbar, hasMenubar, hasStatus);
	return window.open(url, name, settings);
}

function clearCombo(idCombo){
  var combo = document.getElementById(idCombo);
 	var i;
 	for ( i = combo.options.length - 1 ; i >= 0 ; i-- ){
		combo.options[i] = null ;
	}
}

function addComboOption(idCombo,val,desc,select){
	select = (typeof(select) != "undefined" ) ? select : 0 ;
  var combo = document.getElementById(idCombo);
  combo.options[combo.length] = new Option(desc,val);
  if( Number(select) == 1 ){
  	combo.selectedIndex = (combo.length - 1);
  }
}

function check_email(email){
  var strRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
  return strRegExp.test(email);
}


function heightTable(){
	var max 	  = 0;
	var td 		  = 0;

	for ( var i = 0; i < arguments.length; i++ ) {
		 var element = arguments[i];
		 $(element[0]).style.position = 'absolute';
		 element[2] = topH = Number($(element[0]).offsetTop) ;
		 maxTemp = Number($(element[0]).offsetHeight) + topH ;
		 if( maxTemp > max ){
		 	td = element[1];
		 	max = maxTemp;
		 }
		 $(element[0]).style.position = 'relative';
	}	

	for( var i = 0; i < arguments.length; i++ ){
		var element = arguments[i];
		if( element[1] != td ) {
			$(element[1]).style.height = max - ( Number($(element[0]).offsetHeight) + Number(element[2]) ) + 1 ;
		}
	}
}

function ResizeAdmin(){
	var array1 = new Array("contentMenuBack","menuBack");
	var array2 = new Array("contentAdmin"		,"contentAdminTd");
	//heightTable(array1,array2);
}

function ResizeEdit(){
	var m_height = $("MainTable").offsetHeight;
	try{
		if( Number(m_height) > 500 ){
			window.resizeTo(600,500);
		}else{
			window.resizeTo(600,Number(m_height)+80);
		}
	}catch(e){
	}
}

function isMSIE(){
	return (navigator.appName == "Microsoft Internet Explorer");
}

function isSafari(){
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1)) ? true : false;
}

function fileUploadPreview(webpath,type,realpath){
	popup("index.php?page=fileuploadpreview&webpath="+webpath+'&type='+type+'&realpath='+realpath, "previewFile", 100, 100, 'no', 'yes');
}

function zoom(id){
}


// Herramientas

var ACTUAL_FONTSIZE_CUERPO 	  = 12;
var SMALLEST_FONTSIZE_CUERPO  =  9;
var LARGEST_FONTSIZE_CUERPO   = 18;

var ACTUAL_FONTSIZE_TITULO    = 18;
var SMALLEST_FONTSIZE_TITULO  = 15;
var LARGEST_FONTSIZE_TITULO   = 25;

var ACTUAL_FONTSIZE_VOLANTA   =  9;
var SMALLEST_FONTSIZE_VOLANTA =  7;
var LARGEST_FONTSIZE_VOLANTA  = 16;

var ACTUAL_FONTSIZE_COPETE   	= 12;
var SMALLEST_FONTSIZE_COPETE 	=  9;
var LARGEST_FONTSIZE_COPETE  	= 18;

function masGrande() {
  ACTUAL_FONTSIZE_TITULO  = ACTUAL_FONTSIZE_TITULO+1;
  ACTUAL_FONTSIZE_VOLANTA = ACTUAL_FONTSIZE_VOLANTA+1;
  ACTUAL_FONTSIZE_COPETE  = ACTUAL_FONTSIZE_COPETE+1;
  ACTUAL_FONTSIZE_CUERPO  = ACTUAL_FONTSIZE_CUERPO+1;
  
  if (ACTUAL_FONTSIZE_TITULO  > LARGEST_FONTSIZE_TITULO)  { ACTUAL_FONTSIZE_TITULO  = LARGEST_FONTSIZE_TITULO   }
  if (ACTUAL_FONTSIZE_VOLANTA > LARGEST_FONTSIZE_VOLANTA) { ACTUAL_FONTSIZE_VOLANTA = LARGEST_FONTSIZE_VOLANTA  }
  if (ACTUAL_FONTSIZE_COPETE  > LARGEST_FONTSIZE_COPETE)  { ACTUAL_FONTSIZE_COPETE  = LARGEST_FONTSIZE_COPETE   }
  if (ACTUAL_FONTSIZE_CUERPO  > LARGEST_FONTSIZE_CUERPO)  { ACTUAL_FONTSIZE_CUERPO  = LARGEST_FONTSIZE_CUERPO   }
  ChangeProp('titulo','','style.fontSize',ACTUAL_FONTSIZE_TITULO,'SPAN');
  ChangeProp('volanta','','style.fontSize',ACTUAL_FONTSIZE_VOLANTA,'SPAN');
  ChangeProp('copete','','style.fontSize',ACTUAL_FONTSIZE_COPETE,'SPAN');
  ChangeProp('cuerpo','','style.fontSize',ACTUAL_FONTSIZE_CUERPO,'SPAN');
  //SaveActualFontSize();
  //extenderDIV();
}

function masChica() {
  ACTUAL_FONTSIZE_TITULO 	= ACTUAL_FONTSIZE_TITULO-1;
  ACTUAL_FONTSIZE_VOLANTA = ACTUAL_FONTSIZE_VOLANTA-1;
  ACTUAL_FONTSIZE_COPETE  = ACTUAL_FONTSIZE_COPETE-1;
  ACTUAL_FONTSIZE_CUERPO 	= ACTUAL_FONTSIZE_CUERPO-1;
  
  if (ACTUAL_FONTSIZE_TITULO  < SMALLEST_FONTSIZE_TITULO)  { ACTUAL_FONTSIZE_TITULO  = SMALLEST_FONTSIZE_TITULO   }
  if (ACTUAL_FONTSIZE_VOLANTA < SMALLEST_FONTSIZE_VOLANTA) { ACTUAL_FONTSIZE_VOLANTA = SMALLEST_FONTSIZE_VOLANTA  }
  if (ACTUAL_FONTSIZE_COPETE  < SMALLEST_FONTSIZE_COPETE)  { ACTUAL_FONTSIZE_COPETE  = SMALLEST_FONTSIZE_COPETE   }
  if (ACTUAL_FONTSIZE_CUERPO  < SMALLEST_FONTSIZE_CUERPO)  { ACTUAL_FONTSIZE_CUERPO  = SMALLEST_FONTSIZE_CUERPO   }
  ChangeProp('titulo','','style.fontSize',ACTUAL_FONTSIZE_TITULO,'SPAN');
  ChangeProp('volanta','','style.fontSize',ACTUAL_FONTSIZE_VOLANTA,'SPAN');
  ChangeProp('copete','','style.fontSize',ACTUAL_FONTSIZE_COPETE,'SPAN');
  ChangeProp('cuerpo','','style.fontSize',ACTUAL_FONTSIZE_CUERPO,'SPAN');
  //SaveActualFontSize();
  //extenderDIV();
}

function EnviarAmigo(idx)
{
	window.open("../enviaramigo/enviaramigo.php?idx="+idx,"EnviarAmigo","width=490, height=510, scrollbars=no");
}

function ChangeProp(objName,x,theProp,theValue) { //v6.0
  var obj = FindObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
    if( theProp.indexOf("fontSize") >= 0 ){
    	var objs = obj.getElementsByTagName("font");
    	for( i = 0 ; i < objs.length ; i++){
    		objs[i].style.fontSize = theValue;
    	}
    }
  }
}

function 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.getElementById(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=FindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function SaveActualFontSize() {
  var expire = new Date ();
  expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
  expire = expire.toGMTString();
  document.cookie="fontSize="+ACTUAL_FONTSIZE+"; path=/; expires="+expire;
}

//////////

function ImprimirNota(id){
	window.open("index.php?page=imprimirnota&idNota="+id);
}

function EnviarNotaPopUp(id){
	
	StrError="";
	
	if(!StrError && form.comentario.value == ""){
		StrError="Por Favor, ingresar un comentario";
	}
	
	if(!StrError && !check_email(form.destinatario.value)){
		StrError="Por Favor, ingresar una direccion de email válida";
	}
	
	if(!StrError && !check_email(form.emailremitente.value)){
		StrError="Por Favor, ingresar una direccion de email válida";
	}
	
	if(StrError){
		alert(StrError);	
	} else {
		document.getElementById("form").submit();
	}
	
}

function EnviarNota(id)
{
	//window.open("index.php?page=popupnota&idNota="+id
	popup("index.php?page=popupnota&idNota="+id, "enviarAmigo", 650, 370, 'yes', 'no');

}

function BuscarNota()
{
	$('frm').method = 	"GET";
	$('accion').value =	"Buscar";
	$('frm').submit();
}

function LoginFront()
{
	WindowLogin = popup("index.php?page=loginfront", "LoginFront", 380, 230);
}

function Login(){
	window.location.href = "index.php?page=login";
}

function LogoutFront()
{
	window.location = "index.php?page=logoutfront";
}

function cambiarSeccion(seccion)
{
	switch(seccion)
	{
		case 'rubros':
			document.getElementById('rubrosList').style.display       = 'block';
			document.getElementById('clientesList').style.display     = 'none';
			document.getElementById('rubros').style.backgroundColor   = '#D3DFF7';
			document.getElementById('clientes').style.backgroundColor = '';
			break;
			
		case 'clientes':
			document.getElementById('clientesList').style.display     = 'block';
			document.getElementById('rubrosList').style.display       = 'none';
			document.getElementById('clientes').style.backgroundColor = '#D3DFF7';
			document.getElementById('rubros').style.backgroundColor   = '';
			break;
	}	
}	

function Imprimir(){
	window.print();
	}
	
function sendMail(){

	StrError="";
	
	if(!StrError && form.nombre.value == ""){
		StrError="Por Favor, ingresar un nombre";
	}
	
	if(!StrError && form.comentario.value == ""){
		StrError="Por Favor, ingresar un comentario";
	}
	
	if(!StrError && !check_email(form.email.value) ){
		StrError="Por Favor, ingresar una direccion de email válida";
	}
	
	if(StrError){
		alert(StrError);	
	} else {
		document.getElementById("form").submit();
	}
	
}

function apretoEnter()
{
	return (window.event.keyCode==13);
}

function getCookie(name)
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  }
  else
  {
    begin += 2;
  }
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
  {
    end = dc.length;
  }
  return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(cookieName,cookieValue,nDays)
{
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function $(id)
{
	return document.getElementById(id);
}

function escucharAudio(srcFile, typeFile)
{
	var urlFile    = "index.php?page=mediaplayer&file="+srcFile;
	popup(urlFile, "MediaPlayer", 300, 140);
}

function verVideo(srcFile, typeFile)
{
	var urlFile    = "index.php?page=mediaplayer&file="+srcFile;
	popup(urlFile, "MediaPlayer", 300, 320);
}

function verFlash(srcFile, typeFile)
{
	var urlFile    = "index.php?page=flashplayer&file="+srcFile;
	popup(urlFile, "FlashPlayer", 300, 300);
}	