nbLines = 0;

function init() {
	PreloadButtons();
	resizeLogoInter = setInterval('resizeLogoZone()', 250);
}
window.onload = init;


// Preload graphical elements
function PreloadButtons() {
	document.imageArray = new Array(1);
	document.imageArray[0] = new Image();
	document.imageArray[0].src = "/assets/img/buttons/signin_black_on.gif";
}
 
// Show logos' flash
function showFlashLogos (pFlasvars) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="350" height="100%" id="logoFlash">');
	document.write ('<param name="movie" value="/assets/flash/logo.swf">');
	document.write ('<param name="quality" value="high">');
	document.write ('<param name="bgcolor" value="#2e2c2d">');
	document.write ('<param name="scale" value="noscale">');
	document.write ('<param name="salign" value="lt">');
	document.write ('<param name="flashvars" value="'+pFlasvars+'">');
	document.write ('<embed src="/assets/flash/logo.swf" quality="high" width="350" height="100%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="logoFlash" swLiveConnect="true" flashvars="'+pFlasvars+'" salign="lt" bgcolor="#2e2c2d">');
	document.write ('</embed>');
	document.write ('</object>');
}

// Interact from flash to HTML
function setHtmlNetwork (pNetwork) {
	for ( i=0; i<document.loginfrm.network_id.options.length; i++ ) {
		if ( pNetwork==document.loginfrm.network_id.options[i].value ) {
			document.loginfrm.network_id.options[i].selected = true;
			document.loginfrm.network_id.focus();
		}
	}
	setFlashNetwork();
	return false;
}

// Interact from HTML to flash
function setFlashNetwork(){
  si = document.loginfrm.network_id.selectedIndex
  siv = document.loginfrm.network_id.options[document.loginfrm.network_id.selectedIndex].value;
	
  for ( i=0; i<document.loginfrm.network_id.options.length; i++ ) {
    var elmId = 'network-' + document.loginfrm.network_id.options[i].value;
    var nid = document.getElementById(elmId);
    if (nid) {
      if (document.loginfrm.network_id.options[i].value == siv) {
        nid.className = "selected";
      } else {
        nid.className = "";
      }
    }
  }
  
}

// Resizes the logos' flash depending on the number of elements
function resizeLogoZone() {
	if (nbLines != 0) {
		clearInterval (resizeLogoInter);
		resizeFlash("logo", (nbLines*70)+(nbLines-1));
	}
}
function setNbLines(pNbLines) {
	nbLines = pNbLines;
}


// Resize a div element so the flash resizes automatically
function resizeFlash(pElement, pHeight){
	document.getElementById(pElement).style.height = pHeight+"px";		
	document.getElementById(pElement+"Flash").style.height = pHeight+"px";
}

function callFlashFunc(movie, strLocation, strFunc, arrArgs, strCallBack) {
	var toggle = movie.GetVariable("jsCallTrigger");
	movie.SetVariable("jsCallFuncLocation", strLocation);
	movie.SetVariable("jsCallFuncName", strFunc);
	movie.SetVariable("jsCallFuncArgs", arrArgs.join(","));
	movie.SetVariable("jsCallFuncCallBack", strCallBack);
	movie.SetVariable("jsCallTrigger", !toggle);
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	} else {
		return document[movieName]
	}
}

var agent = navigator.userAgent.toLowerCase(); 
this.mac   = (agent.indexOf("mac")!=-1);
if (this.mac) { var offsetMac = 0; } else { var offsetMac = 0; }
function openWindow(pUrl,pTitle, pWidth,pHeight,pStyle) {
	var x = 0;
	var y = 0;
	var offset = 30;
		
	if (screen) x = (screen.availWidth - pWidth) / 2;
	if (screen) y = (screen.availHeight - pHeight) / 2;
	
	
	var popped;
	
	if ( pStyle == 'POP' ) { 
	    var popped = window.open(pUrl,pTitle,'width='+pWidth+',height='+(pHeight+offsetMac)+',status=no,menubar=no,scrollbars=no,resizable=no,screenX='+x+',screenY='+y+',left='+x+',top='+y); 
    }
    
	if ( pStyle == 'POPSCROLL' ) { 
	    var popped = window.open(pUrl,pTitle,'width='+pWidth+',height='+(pHeight+offsetMac)+',status=no,menubar=no,scrollbars=auto,resizable=yes,screenX='+x+',screenY='+y+',left='+x+',top='+y); 
    }

	if ( pStyle == 'WINDOW' ) {
		if (pHeight > screen.availHeight) pHeight = (screen.availHeight - offset);
		var popped = window.open(pUrl,pTitle,'width='+pWidth+',height='+(pHeight+offsetMac)+',status=yes,menubar=yes,scrollbars=yes,resizable=yes,screenX='+x+',screenY='+y+',left='+x+',top='+y);
	}
	
	if ( document.all) popped.focus();
	if ( !popped.opener) { popped.opener = window; }
}

