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="menu" value='+menu_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 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 check_date(dateStr) {
	// Formatos: mm-dd-yyyy or mm/dd/yyyy or yyyy/mm/dd or yyyy-mm-dd.

  var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
  var matchArray = dateStr.match(datePat); // is the format ok?
	
  if (matchArray == null) {
		datePat = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/;
  	matchArray = dateStr.match(datePat); // is the format ok?
	  if (matchArray == null) {
	    return false;
	  }else{
	  	month = matchArray[3]; // parse date into variables
		  day 	= matchArray[5];
  		year 	= matchArray[1];
	  }
  }else{
  	month = matchArray[1]; // parse date into variables
	  day 	= matchArray[3];
  	year 	= matchArray[5];
  }

  

  if (month < 1 || month > 12) { // check month range
    return false;
  }

  if (day < 1 || day > 31) {
    return false;
  }

  if ((month==4 || month==6 || month==9 || month==11) && day==31) {
    return false;
  }

  if (month == 2) { // check for february 29th
    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
    if (day > 29 || (day==29 && !isleap)) {
      return false;
    }
  }
  return true; // date is valid
}


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){
	popup("index.php?page=fileuploadpreview&webpath="+webpath+'&type='+type, "previewFile", 100, 100, 'no', 'yes');
}

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 reloadIframeSeccion()
{
}

function playing(idObj)
{
	 var idObj = ( typeof(idObj) != "undefined" ) ? idObj : 3 ;
	 var Obj  = (isMSIE() || isSafari() ) ? 'video_destacado_msie_' : 'video_destacado_msie_';
	 var strArguments  = 'stopVideo';
	 for (i =1 ;i<=5; i++){	 	
		if (idObj != i){				
			$(Obj+i).SetVariable('objSocket.call', strArguments);
			if (i != 1){
				$('VideoDetalle_'+i).style.display='none';		
			}
		}else{
	 		$('VideoDetalle_'+i).style.display='block';	 	
	 	}
	}
}