
function signin(locale) {
	noWarning = false;
	
	// careful - these can throw exceptions from the ad stuff
	showAd(locale);
	checkSize();
}

var lastAd = 0;
function showAd(locale) {
  document.getElementById("adPanel").style.width = "160px";
  document.getElementById("content").style.marginRight = "160px";
  document.getElementById("container").style.marginRight = "-160px";

  document.getElementById("ad").style.width="160px";
  frames.ad.width="160";
  
  // setup the ad context
  var lg_cc = locale.split("_");
  frames.ad.start(lg_cc[1],lg_cc[0]); /// tentatively working intl code for ads
  
  frames.ad.rotate("login");
}

// for the ad scheduler..
function userActive(bool_str) {
  frames.ad.userActive(bool_str);
}

// used by the signed out dialog.
function reload() {
  noWarning = true;
  location.reload(true);
}
function exit(url) {
  noWarning = true;
  if (!url) url ="http://webmessenger.yahoo.com/";
  location.href= url;
}

function focusMe() {
  try {
  	getFlashMovieObject(myName).focus();
  } catch(e) {}
}

// called via ExternalInterface
function IsFocused() {	return IsFocusedHandler.Impl(); }
function IsFocusedHandler()
{
	window.onfocus = function()
	{
		window.bFocused = true;
		try {
			// focus on flash			
			getFlashMovieObject(myName).focus(); 
		} 
		catch (e) {}
	};

	// see externalnotifier for details
	if (document.hasFocus)  // IE?
	{
		IsFocusedHandler.Impl = document.hasFocus;
	}
	else // not IE
	{
		window.onblur = function()	{	window.bFocused = false; };
		IsFocusedHandler.Impl = function() { return window.bFocused; };
	}
}
IsFocusedHandler();

 /******************Ad button****************/
  function getHeight(){
    if(window.innerHeight){
	    return window.innerHeight;
	}
	else{
		return document.body.clientHeight;
	}
  }
  var adHeight = 650; // [hpt] was 600. consider restoring when survey goes away.
  window.onresize = function(){
	 checkSize();
  }
  function checkSize(){
  	if(getHeight() < adHeight){
  		document.getElementById("adScroller").style.display = "block";
  		resetAd();
  	}
  	else{
  		document.getElementById("adScroller").style.display = "none";
  		restoreAdPos();
  		reg();
  	}
  }
  
  var adbtn = document.getElementById("adScroller");
  
  function reg(){
    if(adIsUp){
    	adbtn.style.backgroundPosition = 0;
    }
    else{
	    adbtn.style.backgroundPosition = -78;
	}
  }
  function over(){
    if(adIsUp){
    	adbtn.style.backgroundPosition = -26;
    }
    else{
    	adbtn.style.backgroundPosition = -104;
    }
  }

  adbtn.onmouseout = reg;
  adbtn.onmouseover = over;
  adbtn.onmousedown = function(){
     if(adIsUp){
    	adbtn.style.backgroundPosition = -52;
     }
     else{
    	 adbtn.style.backgroundPosition = -130;
     }
  }
  adbtn.onmouseup = function(){
      toggleAd();
  }

  var adIsUp = false;
  function toggleAd(){
    moveAd(adIsUp);
    over();
  }
  function resetAd(){
	moveAd(!adIsUp);
  }
  function moveAd(restore){
    if(restore){
      restoreAdPos();
    }
    else{
      moveAdUp();
    }
  }
  
  
  function restoreAdPos(){
  	document.getElementById("ad").style.marginTop = 0;
    adIsUp = false;
  }
  function moveAdUp(){
  	  var diff = adHeight - getHeight();
      document.getElementById("ad").style.marginTop = "-" + diff + "px";
      adIsUp = true;
  }
  
  function setButtonTitle(t){
  	adbtn.title = t;
  }
  /***************end Ad button***************/
 
/*************** Logger stuff***************/

var PICO = {
	timer: -1,
	writeLog: function(str) {
		logger.writeLog(str + "\n");
		if (timer != -1) {
			clearTimeout(timer);
			timer = -1;
		}
		timer = setTimeout("logger.flushLog()", 1000);
	}
}

var loggerEnabled = false;		// if browser has the required logger plugin

function initLogger() {
	var enableLog = true;
	var plugin = "Yahoo Message Logger Plugin";
	loggerEnabled = (navigator.plugins && navigator.plugins[plugin]) ? navigator.plugins[plugin][0].enabledPlugin : 0;
	
	if (loggerEnabled) {
		var logger = document.getElementById('logger');
		enableLog = logger ? enableLog : false;
		if (enableLog) {
			setLogFile();
		}
	}
}

function setLogFile()
{
	var date = new Date();
	var str = [	date.getFullYear(),
				("0"+(1+date.getMonth())).substr(-2, 2),
				("0"+1+date.getDate()).substr(-2, 2),
				"-",
				("0"+date.getHours()).substr(-2, 2),
				("0"+date.getMinutes()).substr(-2, 2),
				("0"+date.getSeconds()).substr(-2, 2)
			].join("");
	var varLogFile = "c:\\temp\\pico_" + str + ".log";
	logger.setLogFile(varLogFile);
}
 
 
