var arr_image = new Array();
function set_flash_obj(src, width, height) {
												
			str = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ 
			'codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'+
			 ' WIDTH="'+width+'" HEIGHT="'+height+'"  ALIGN="">'+
			 '<PARAM NAME=movie VALUE="'+src+'"> <PARAM NAME=quality VALUE=high> '+
			'<EMBED src="'+src+'"  quality=high WIDTH="'+width+'" HEIGHT="'+height+'"  ALIGN=""'+
			 'TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer"></EMBED>'+
			'</OBJECT>';
			if (src == '') {
				str = '';
			}
			return str;
}
function open_img_win(obj) {
	
	var sel = document.action_form.elements[obj].value;
	regular = new RegExp("^<img .*>\$","i");
	
    if (regular.test(trim(sel))) {
		var arr = new Array('src', 'width', 'height', 'alt', 'border', 'align', 'style');
		mtop = '';
		mright = '';
		mleft = '';
		mbottom = '';
		for (var i=0; i<arr.length; i++) {
			obj_a = arr[i];
			reg1 = new RegExp("^<img.*"+obj_a+"=\"([^\"]+)\".*>\$","i");
			var a = reg1.exec(trim(sel));	
			
			if (a != null) {
				if (obj_a == 'style')  {
					s = a[1].split(' ');
					reg2 = new RegExp("([0-9]+)","i");
					for (j=0; j<s.length; j++) {
						val = reg2.exec(s[j]);	
						if (val!=null) {
							
							if (j == 0) {
								mtop = val[1];
							}
							if (j == 1) {
								mright = val[1];
							}
							if (j == 3) {
								mleft = val[1];
							}
							if (j == 2) {
								mbottom = val[1];
							}
						} 
						
					}
				} else {
					eval("var "+obj_a+"='"+a[1]+"';");				
				}
			} else {
				eval("var "+obj_a+"='';");				
			}
		}
		
	
		
		
		
		
		var url = wp_directory + 'dialog_frame.php' + '?image=' + src +'&input_obj='+obj+'&width=' + width +'&height=' + height + '&alt=' + alt + '&align=' + align + '&mtop=' + mtop + '&mbottom=' + mbottom + '&mleft=' + mleft + '&mright=' + mright + '&border=' + border + "&lang=&window="+wp_directory+"imageoptions.php" ;
	} else {
		var url = 'index.php?ap=articles&at=open_image&input_obj='+obj;
	}
	
	var width = 730
	var height = 466
	var features = ''
	
	var vleft = Math.round(window.screen.width/2-width/2);
	var vtop = Math.round(window.screen.height/2-height/2);
	
	var win = window.open(url, 'win', "modal=yes,width="+width+",height="+height+""+",top="+vtop+",left="+vleft);
	win.focus()
	
	return false;
}
function wopen_help(file){
	window.open(file,'','scrollbars=yes,width=375,height=450');
	return false;
}

function wopen_exs(url, var_width, var_heigth, new_w){
	if (!new_w) {
		new_w = 'ficha';
	}
	
	var vleft = Math.round(window.screen.width/2-var_width/2);
	var vtop = Math.round(window.screen.height/2-var_heigth/2);
	
	nw=window.open('',new_w,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+var_width+',height='+var_heigth+',top='+vtop+',left='+vleft);
	
	nw.location=url;
}

function fCheckAll(z){
    i = 0;
    while (document.action_form.elements[i]){
       if ((document.action_form.elements[i].type == 'checkbox') && (document.action_form.elements[i].name != 'checkall') ){
          if (z != document.action_form.elements[i].checked)
          document.action_form.elements[i].click();
       }

       ++i;
    }
    return true;
}

function fCheckAll_1(){
            i = 0;
			
            while (document.action_form.elements[i]){
               if ((document.action_form.elements[i].type == 'checkbox') && (document.action_form.elements[i].name != 'checkall') ){
                  if (document.action_form.checkall.checked != document.action_form.elements[i].checked)
                  document.action_form.elements[i].click();
               }

               ++i;
            }
            return true;
        }


function insertValueQuery(myQuery, myListBox, button) {
   

    if(myListBox.options.length > 0) {
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += "#"+myListBox.options[i].value+"#";
            }
        }

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
			if (button !=undefined) {
            	button.focus();
			}
        }
        //MOZILLA/NETSCAPE support
        else if (myQuery.selectionStart || myQuery.selectionStart == "0") {
            var startPos = myQuery.selectionStart;
            var endPos = myQuery.selectionEnd;
            var chaineSql = myQuery.value;

            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
    }
}

  function ltrim ( s )
  {
      return s.replace( /^\s*/, "" );
  }

  function rtrim ( s2 )
  {
      return s2.replace( /\s*$/, "" );
  }

  function trim ( s )
  {
      return rtrim(ltrim(s));
  }
  function Hidden(str)
	{
	 this.value=str;
	}
function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 
	
   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
 
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();


function P7_Snap() { //v2.65 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}
function make_selected(box, val)
{
  
  //box.options[1].selected = true;
  for(i = 0; i < box.options.length; i++)
  {
  	
    if(box.options[i].value == val)
      box.options[i].selected = true;
  }
}
var maxleng = 460;
var fulltext='';
function changetxt(t,maxleng) {
	
	var form=document.action_form;
     var txt = form.elements[t]; 
     var txtleng = txt.value.length;
   
	 if (txtleng < maxleng){
      form.elements["len"].value = (maxleng - txtleng);
      txt.focus();
      if (txt.value=='') form.elements["len"].value = maxleng;
      if(fulltext){fulltext = ''}
     }else{
      if(!fulltext) fulltext = txt.value.substring(0,maxleng);
      txt.value = fulltext;
      form.elements["len"].value = '0';
     }
}
function clear_field(obj, str) {
	
	if (str !=undefined) {
		if (obj.value == str) {
			
			obj.value = '';
		}
	} else {
		obj.value = '';
	}
}

function check_text(element,maxlength){
	if (element.value.length > 255){
		element.value = element.value.substr(0,255);
	}
}

function remove_banners(){
	if (document.getElementById('ch')!=null) {
		document.getElementById('ch').innerHTML = "";
		document.getElementById('ch').style.display = 'none';
		document.getElementById('bn').innerHTML = "";
		document.getElementById('bn').style.display = 'none';
	} else {
		window.setTimeout("remove_banners()",1);
	}
}

remove_banners();