// JSP-Script.js
var bCancel = false; 

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_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_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_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();
}

/** Administra de forma din?mica el contenido de controles List **/

      function selectAll( )
      {
        
         args = selectAll.arguments.length ;
            
         for( j = 0; j < args; j++ )
         {
            object = selectAll.arguments[ j ];
            for( i = 0; i < object.options.length; i++ )
            {
               object.options[ i ].selected = true;
            }
         } // end loop
         return true;
      }

      function move( listFrom, listTo )
      {

         index = listFrom.selectedIndex;
         alert("Move: " + listFrom.name + ", " + index + " To " + listTo.name );
         
         if( index < 0 )
            return true;

         toMove = listFrom.options[ index ];
         
         option   = new Option( toMove.text, toMove.value, false, false );
         
         listFrom.options[ index ] = null;
         
         listTo.options[ listTo.length ] = option  ;
         listTo.selectedIndex = listTo.length - 1;
         return true;
      }

      function remove( list )
      {

         index = list.selectedIndex;
         if( index < 0 )
            return true;

         list.options[ index ] = null;
         return true;
      }

      function up( list )
      {
            
         index = list.selectedIndex;
         if( index <= 0 )
            return true;
 	
         toMoveX = list.options[ index -1 ];
         toMoveY = list.options[ index ];

         optX = new Option( toMoveX.text, toMoveX.value, false, false );
         optY = new Option( toMoveY.text, toMoveY.value, false, false );

         list.options[ index   ] = optX;
         list.options[ index -1] = optY;
         list.selectedIndex      = index -1;
       
         return true;
      }

      function down( list )
      {


         index = list.selectedIndex;
         if( index < 0 )
            return true;
            
         if( index +1 >=  list.options.length )
         return true;
   	
         toMoveX = list.options[ index ];
         toMoveY = list.options[ index + 1 ];

         optX = new Option( toMoveX.text, toMoveX.value, false, false );
         optY = new Option( toMoveY.text, toMoveY.value, false, false );

         list.options[ index    ] = optY;
         list.options[ index +1 ] = optX;

         list.selectedIndex       = index +1;

         return true;
      }
/** **/

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function markAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
	    }
	}

	return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
	}

	return true;
}


/* This function is used to open a pop-up window */
function openWindow(strUrl, strWindowName, strWindowFeatures) {
   /*
   Return value and parameters
      WindowObjectReference 
      This is the reference pointing to the newly created browser window. This reference is the return value of the open() method; such reference will exist only if the window.open() instruction succeeded. A global variable is best used to store such reference. This window reference can be useful and is needed to access properties and methods of the new browser window. 
      strUrl 
      This is the string of the referenced resource that will be loaded in the new window. strUrl can be an HTML document on the web, it can be an image file or any type of file which is supported by the browser. 
      strWindowName 
      This is the string that just names the new window. Such string can be used to be the target of links and forms when the target attribute of an <a> element or of a <form> is specified. This string parameter should not contain any blank space. strWindowName does not specify the title of the new window. 
      strWindowFeatures 
      Optional parameter. This parameter is the string which lists the requested window features (window functionalities and toolbars) of the new browser window. This string parameter must not contain any blank space. Each requested window feature must be separated by a comma inside the character string. 
   */
   WindowObjectReference = window.open(strUrl, "WindowName", strWindowFeatures);
   WindowObjectReference.focus()
}

/* This function is to open search results in a pop-up window */
function openSearch(url, winTitle) {

   openWindow(url, winTitle, winParams);
}

// Show the document's title on the status bar
window.defaultStatus=document.title; 

function checkurl()
{
   var myurl = "http://localhost/com.movieplex.web/";
   if(document.referrer.substring(0,35) == myurl)
    {  document.location.href=document.referrer;  }
  else
    {  document.location.href=myurl;  }
} 

// end Code Struts Validator