fields = {
	empty : function(which){
		fields.initialValue = $(which).attr('value');

		if($(which).attr('value') == fields.initialValue){
			$(which).attr('value', '');
		}

		$(which).bind("blur", function(){
			if(this.value == ""){ this.value = fields.initialValue; }
		});
	}
}

subitem = {
	open : function(caller){
		// Get the longest item with
		$(caller).find('ul').width(document.getElementById('wrap').offsetWidth);
		var ul = caller.getElementsByTagName('ul')[0];
		ul.style.left = '-' + caller.offsetLeft + 'px';
		$(caller).find('ul').show();
	},
	close : function(caller){
		$(caller).find('ul').hide();
	}
}

var obj = null;
var tooltipZindex = 3;

mainMenu = {
	init : function(){
		var t = new Array();
		t.push(['News', 'News']);
		t.push(['Creative', 'Creative']);
		t.push(['Community', 'Community']);
		t.push(['CareerZone', 'CareerZone']);
		t.push(['Resources', 'Resources']);
		t.push(['Our Products', 'Our Products']);
		t.push(['Contact Us', 'Contact Us']);
	}
}

/* Rajout de l'ancien fichier script.js*/

function open_print(){
	window.open('/shared/print.jsp'+document.location.search, 'print', 'scrollbars=yes,menubar=no,status=no,top=100px,left=100px,width='+(screen.width-200)+',height='+(screen.height-400));
}

function open_printoakley(){
	window.open('/shared/print_oakley.jsp'+document.location.search, 'print', 'scrollbars=yes,menubar=no,status=no,top=100px,left=100px,width=400,height=500');
}

function open_email(){
	lang = 'en';
	if(document.location.href.indexOf("/francais/")>0){
		lang = 'fr';
	}
	lang = '/shared/email_'+lang+'.jsp'+document.location.search;
	window.open(lang, 'email', 'scrollbars=yes,menubar=no,status=no,top=100px,left=100px,width=480,height=600');
}

function open_emailOakley(){
	lang = 'en';
	if(document.location.href.indexOf("/francais/")>0){
		lang = 'fr';
	}
	lang = '/shared/emailOakley_'+lang+'.jsp'+document.location.search;
	window.open(lang, 'email', 'scrollbars=yes,menubar=no,status=no,top=100px,left=100px,width=480,height=600');
}
/* function popup pour le formulaire de feedback.*/

function popfeedback()
	{
	msg=window.open("http://www.louloumagazine.com/feedback/index.html","popv","toolbar=no,left=0,top=360,width=500,height=600,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no");
}

function popfeedbackEn()
	{
	msg=window.open("http://www.louloumagazine.com/feedback/index_en.html","popv","toolbar=no,left=0,top=360,width=500,height=600,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no");
}

function openWindow(url, width, height) {
	leftPos   = (screen.availWidth-10  - width)  / 2;
	topPos    = (screen.availHeight-20 - height) / 2;
	features  = "width=" + width +",height=" + height;
	features += ",scrollbars=1,resizable=0,location=0";
	features += ",menubar=0,toolbar=0,status=1";
	var myWindow = window.open(url, name, features);
	myWindow.moveTo(leftPos, topPos);
}

function openit(imgname) {
  var OpenWindow=window.open("", "newwin","height=640,width=640");
   OpenWindow.document.write("<div align=\"center\">" +imgname)
   OpenWindow.document.write("<br>")
   OpenWindow.document.write("<a href='javascript:self.close()' target='_self'>Close</a></div>")
   }

function openPlayer(stationId, lang) {
  if(lang == null || lang == ''){
    lang='en';
  }
  var url = "http://loulou.rogers.icebergradio.com/loulou-radio-" + lang + ".html";
  if (stationId && stationId > 0) {
    url += "?station=" + stationId
  }

  var w = null;
  w = window.open(url, "PLAYER", "scrollbars=0,width=602,height=351");

  if (w){
    w.focus();
  } else {
    alert('player window failed to open.  perhaps your popup blocker blocked it?');
  }
}

// fonction pour le pulldown menu de TV
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// fonction to set the operating mode (default, print)
function setOperatingMode(mode) {
	setActiveStyleSheet(mode);
}

// fonction to set the operating mode for default use (like default css...)
function setDefaultMode() {
	setOperatingMode("default");
}

// fonction to set the operating mode for print use
function setPrintMode() {
	setOperatingMode("print");
}

// fonction to set the active stylesheet based on link attribute title ex: <link ... title="primary"
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	  //alert("css title: " + a.getAttribute("title") + "  passed title: " + title);
      a.disabled = true;
      if(a.getAttribute("title") == title){
		  a.disabled = false;
	  }
    }
  }
}

function getStyleSheet(title) {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      if(a.getAttribute("title") == title){
		  return a;
	  }
    }
  }
}


// checks existence of ID in markup
function checkID(idName) {
	if (document.getElementById(idName)) {
		return true;
	} else {
		return false;
	}
}

/* changes a stylesheet class
 * if changeClass(idName,toClass) changes a stylesheet class to a specified ID
 * if changeClass(parentIdName,childIdName,toClass) changes a child stylesheet class within a collection and reset the others
*/
function changeClass() {
 	var args = changeClass.arguments;

	switch(args.length) {
		case 2: //changes a stylesheet class to a specified ID

			var idName = args[0], toClass = args[1];
			if (checkID(idName)) {
				document.getElementById(idName).className=toClass;
			}
			break;

		case 3: //changes a child stylesheet class within a collection and reset the others
			var parentIdName = args[0], childIdName = args[1], toClass = args[2];
			if (checkID(parentIdName) && checkID(childIdName)) {
				var parentObj = document.getElementById(parentIdName);
				var childObj = document.getElementById(childIdName);
			    var childList = parentObj.getElementsByTagName(childObj.tagName); //array containing the elements within parent
				for (var x=0; x<childList.length; x++){ //loop through each child element
					if (childList[x].id == childIdName) {
						childList[x].className = toClass;


					}
					else {
						childList[x].className = '';
					}
				}
			}
			break;
	}
}



// ------------------Timeout---------------------//



<!--
var timeout         = 3000;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(subitem)
{
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(subitem);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;
// -->


