// NOTE val = speed value
var index = 0;
var yy = 0;
var xx = 0;
this.scroll(0,0);

// <----------------------------------------------------------------------------------------->
// OPENA A WINDOW FLASH

function openAWindow( pageToLoad, winName, width, height, center) {
/* Opens a new window on the users desktop.
   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName -    Name of the new window.
    width -      The horizontal size of the new window.
    height -     The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering

    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.

    A call to this function might look like this:
    <a href="javascript:openAWindow('ice.html','ice',375,250,1)">Ice</a>

   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.
*/
                                         
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=0,"
    + "scrollbars=0,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    cwin = window.open( pageToLoad,winName,args );
}

// <----------------------------------------------------------------------------------------->
// FULL SCREEN

function winFULL(){ 
        top.resizeTo(screen.availWidth,screen.availHeight);
	    top.moveTo(0,0);
}


// <----------------------------------------------------------------------------------------->
// RESIZE & CENTER
function WWRES(WWancho, WWalto){ 
      WWlef = Math.round((screen.availWidth - WWancho) / 2);
      WWtop = Math.round((screen.availHeight - WWalto) / 2);
      self.resizeTo(WWancho,WWalto);
	     self.moveTo(WWlef,WWtop);
}

// <----------------------------------------------------------------------------------------->
// RESIZE & CENTER TOP
function winRES1(ancho, alto){ 
     wleft = Math.round((screen.availWidth - ancho) / 2);
     wtop = Math.round((screen.availHeight - alto) / 2) - alto;
     top.resizeTo(ancho,alto);
	    top.moveTo(wleft,wtop);
}

// <----------------------------------------------------------------------------------------->
// RESIZE & CENTER MIDDLE
function winRES2(ancho, alto){ 
        wleft = Math.round((screen.availWidth - ancho) / 2);
        wtop = Math.round((screen.availHeight - alto) / 2);
        top.resizeTo(ancho,alto);
	    top.moveTo(wleft,wtop);
}

// <----------------------------------------------------------------------------------------->
// RESIZE & CENTER DOWN
function winRES3(ancho, alto){ 
        wleft = Math.round((screen.availWidth - ancho) / 2);
        wtop = Math.round((screen.availHeight - alto) / 2) + alto;
        top.resizeTo(ancho,alto);
	    top.moveTo(wleft,wtop);
}

// <----------------------------------------------------------------------------------------->
// FLASH open new window 

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
        newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

// <----------------------------------------------------------------------------------------->
// COLOR LIST

var Colors = new Array("#000000","#CCCCCC","#01010101","#eeeeee","#111111","#aaaaaa","#e1e1e1e1","#c2c2c2c2");


// <----------------------------------------------------------------------------------------->
// INITIAL SCROLL

function qw( ) {
      this.scroll(0,0);
}


// <----------------------------------------------------------------------------------------->
// GET NAME FROM FILE

function nameWIN(pageval) {
        var loc = new String (pageval);
        var index = loc.length - 5;
        pagename = loc.substring(0, index);
}


// <----------------------------------------------------------------------------------------->
// OPEN WINDOW simple

function openPS(pageval) {
    nameWIN(pageval)

    maxh = screen.availHeight;
    maxw = screen.availWidth;
    wleft = Math.round((maxw - wval) / 2);
    wtop = Math.round((maxh - hval) / 2);
    str = "scrollbars=0,titlebar=0,Width=780,Height=535,Top=" + wtop + ",Left=" + wleft;
    //self.close();
    win = window.open(pageval,pagename,str);
}

// <----------------------------------------------------------------------------------------->
// OPEN WINDOW

function openP1(pageval,wleft,wtop,wval,hval) {

    nameWIN(pageval)

    str = "scrollbars=0,titlebar=0,Width=" + wval + ",Height=" + hval + ",Top=" + wtop + ",Left=" + wleft;
    //self.close();
    win=window.open( pageval , pagename , str );
}


// <----------------------------------------------------------------------------------------->
// OPEN WINDOW CENTERED

function openPC(pageval,left,top,wval,hval) {
    nameWIN(pageval)

    maxh = screen.availHeight;
    maxw = screen.availWidth;
    wleft = Math.round((maxw - wval) / 2);
    wtop = Math.round((maxh - hval) / 2);
    str = "scrollbars=0,titlebar=0,Width="+ wval + ",Height=" + hval + ",Top=" + wtop + ",Left=" + wleft;
    //self.close();
    win = window.open( pageval , pagename , str );
}


// <----------------------------------------------------------------------------------------->
// OPEN RANDOM WINDOW  

function changeP(pageval,val) {

     WWRES(300, 300);
      for (i=0; i<val; i++) {
      wtop = Math.round(  Math.random() * screen.availHeight);
      wleft = Math.round(  Math.random() * screen.availWidth);
      wval = Math.round(  Math.random() * val);
      hval = Math.round(  Math.random() * val);
      //self.close()
      this.blur()
      pagename = i;

      str = "scrollbars=0,titlebar=0,Width=" + wval + ",Height=" + hval + ",Top=" + wtop + ",Left=" + wleft;
      win=window.open( pageval , pagename , str );
 }
}


// <----------------------------------------------------------------------------------------->
// OPEN & CLOSE RANDOM WINDOW  

function changePC(pageval,val) {

      for (i=0; i<val; i++) {
      wtop = Math.round(  Math.random() * screen.availHeight);
      wleft = Math.round(  Math.random() * screen.availWidth);
      wval = Math.round(  Math.random() * screen.availWidth);
      hval = Math.round(  Math.random() * screen.availHeight);
      //self.close()
      pagename = i;

      str = "scrollbars=0,titlebar=0,Width=" + wval + ",Height=" + hval + ",Top=" + wtop + ",Left=" + wleft;
      win=window.open( pageval , pagename , str );
      for (j=0; j<500000; j++) {
            // set speed here ....
      }
      win.close();
 }
}

// <----------------------------------------------------------------------------------------->
// CHANGE X SCROLL

function changeX(val) {
      dur = Math.round(  Math.random() *  val);
      con = "changeX(" + val + ")";
      window.setTimeout( con, dur ); 
      xx = Math.round(  Math.random() *  800);
      yy = 0;
      this.scroll(xx,yy);
}


// <----------------------------------------------------------------------------------------->
// CHANGE Y SCROLL

function changeY(val) {
      dur = Math.round(  Math.random() *  val);
      con = "changeY(" + val + ")";
      window.setTimeout( con, dur ); 
      xx = 0;
      yy = Math.round(  Math.random() *  800);
      this.scroll(xx,yy);
}


// <----------------------------------------------------------------------------------------->
// CHANGE XY SCROLL

function changeXY(val) {
      dur = Math.round(  Math.random() *  val);
      con = "changeXY(" + val + ")";

      window.setTimeout( con, dur ); 
      xx = Math.round(  Math.random() *  800);
      yy = Math.round(  Math.random() *  800);
      this.scroll(xx,yy);
}


// <----------------------------------------------------------------------------------------->
// CHANGE BACKGROUND

function changeBG(val) {
      dur = Math.round(  Math.random() *  val);
      con = "changeBG(" + val + ")";
      window.setTimeout( con, dur ); 
      index = Math.round(Math.random() * (Colors.length) );
      document.bgColor = Colors[index];
}


// <----------------------------------------------------------------------------------------->
// CHANGE SCROLL + BACKGROUND

function changeBGXY(val) {
      changeBG(val);
      changeXY(val);
}


// <----------------------------------------------------------------------------------------->
// 	CLOSE WINDOW

function closeW() {
      window.close();
}


// <----------------------------------------------------------------------------------------->
// 	WRITE NEW CONTENT TO WIN then close

function wWINc() {
var doc = win.document;
doc.open("text/html", "replace");
doc.write("<HTML>");
doc.write("<HEAD>");
doc.write("<TITLE>NUEVO DOC</TITLE>");
doc.write("</HEAD>");
doc.write("<BODY>");
doc.write("hello<BR>");
doc.write("hello<BR>");
doc.write("</BODY>");
doc.write("</HTML>");
doc.close();
}

// <----------------------------------------------------------------------------------------->
// 	WRITE NEW  WIN

function wNWIN() {
var win = window.open("", "win", "width=300,height=200"); // a window object
var doc = win.document;
doc.open("text/html", "replace");
doc.write("<HTML>");
doc.write("<HEAD>");
doc.write("<TITLE>NUEVO DOC</TITLE>");
doc.write("</HEAD>");
doc.write("<BODY>");
doc.write("hello<BR>");
doc.write("hello<BR>");
doc.write("hello<BR>");
doc.write("</BODY>");
doc.write("</HTML>");
doc.close();
}

// <----------------------------------------------------------------------------------------->
// change position of window
function winPOS(ancho,alto){ 
        //WWRES(ancho,alto);
        wtop = Math.round(  Math.random() * 250) + Math.round( screen.availHeight/2) - Math.round(  Math.random() * 250) - ancho;
        wleft = Math.round(  Math.random() * 250) + Math.round( screen.availWidth/2) - Math.round(  Math.random() * 250) - alto;
	       self.moveTo(wleft,wtop);
        //self.focus();
}


// <----------------------------------------------------------------------------------------->
// blur window
function blurWIN(){ 
     this.blur();
}

// <----------------------------------------------------------------------------------------->
// close MENU
function closeMENU() {
	win1.close();
	win2.close();
	win3.close();
	win4.close();
	win5.close();
	win6.close();
	win7.close();
	win8.close();
	win9.close();
}

