// **********************************************************************************************
// *************************************** POPUP ************************************************
// **********************************************************************************************
function synchrone_popup(url,winname,width,height,scrollbars) 
{
	var toolbar=0;
	var location=0;
	var directories=0;
	var status=0;
	var resizable=0;
	var copy=0;
	var menubar=0;
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;
	var movefromedge=0;
	   
		placementx=(ScreenWidth/2)-((width)/2);
		placementy=(ScreenHeight/2)-((height)/2);

	var base_href = "";
	var theBase = document.getElementsByTagName("base");

	if (theBase[0] != undefined && url.substr(0, 4).toLowerCase() != "http")
	{
		base_href = theBase[0].href+"/";
	}	
	return window.open(base_href+url,"","width="+width+",height="+height+",toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",scrollbars="+scrollbars+",menubar="+menubar+",resizable="+resizable+",left="+placementx+",top="+placementy+",screenX="+placementx+",screenY="+placementy+",");
}


// **********************************************************************************************
// ******************************** Impression d'un contenu *************************************
// **********************************************************************************************
function printStatic()
{
	var browserName = navigator.appName;
	var objectName;

	if(browserName == 'Netscape'){
	  if(document.getElementById('divBody') == '[object HTMLDivElement]'){
		var transfert = document.getElementById('divBody').innerHTML;
  		frmPrint.document.getElementById('divPrint').innerHTML = transfert;
  		frmPrint.focus();
  		frmPrint.print();
	  }else{
		window.print();
	  }
	}else{
	  if(document.getElementById('divBody') == '[object]'){
		var transfert = document.getElementById('divBody').innerHTML;
  		document.frmPrint.document.getElementById('divPrint').innerHTML = transfert;
  		document.frmPrint.focus();
  		window.print();
	  }else{
		window.print();
	  }
	}
}


// **********************************************************************************************
// ***************************** to Title Cas ***************************************************
// **********************************************************************************************
String.prototype.toTitleCase = function()
{
	var str = this.toLowerCase(),
	newStr = '';

	for ( var i = 0, l = str.length; i < l; i++ )
	{
		newStr += ( i == 0 || ((str.charAt( i - 1 ) == ' ' || str.charAt( i - 1 ) == '-') && !IsPrep(str.substring(i))))?
		str.charAt( i ).toUpperCase():
		str.charAt( i );
	}
	return newStr;
}

function IsPrep(strP)
{
    var preparray = new Array(24);
    preparray[0] = "and ";
    preparray[1] = "the ";
    preparray[2] = "for ";
    preparray[3] = "to ";
    preparray[4] = "in ";
    preparray[5] = "a ";
    preparray[6] = "at ";
    preparray[7] = "from ";
    preparray[8] = "by ";
    preparray[9] = "an ";
    preparray[10] = "or ";
    preparray[11] = "if ";
    preparray[12] = "of ";
    preparray[13] = "up ";
    preparray[14] = "de ";
    preparray[15] = "des ";
    preparray[16] = "du ";
    preparray[17] = "et ";
    preparray[18] = "à ";
    preparray[19] = "le ";
    preparray[20] = "les ";
    preparray[21] = "la ";
    preparray[22] = "au ";
    preparray[23] = "aux ";

    for(i=0;i<preparray.length;i++){
        if(strP.indexOf(preparray[i]) == 0){
            return true;
            break;
        }
    }
    return false;
}

// **********************************************************************************************
// ******************************MENU OUTLOOK ***************************************************
// **********************************************************************************************
function montre(id, pnlName) {

		
	var d = document.getElementById(id);

	new Effect.toggle(d,'blind', {duration:0.3});
		
}


// **********************************************************************************************
// ***************************** Infobulle ******************************************************
// **********************************************************************************************
var offsetxpoint=40 //Customize x offset of tooltip
var offsetypoint=-30 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false



function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showInfo(thetext){
		if (ns6||ie){
		document.getElementById("infoBulle").innerHTML=thetext;
		enabletip=true
		return false
		}

}

function positiontip(e){
	if (enabletip){
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
	var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

	var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<document.getElementById("infoBulle").offsetWidth)
	//move the horizontal position of the menu to the left by it's width
	document.getElementById("infoBulle").style.left=ie? ietruebody().scrollLeft+event.clientX-document.getElementById("infoBulle").offsetWidth+"px" : window.pageXOffset+e.clientX-document.getElementById("infoBulle").offsetWidth+"px"
	else if (curX<leftedge)
	document.getElementById("infoBulle").style.left="5px"
	else
	//position the horizontal position of the menu where the mouse is positioned
	document.getElementById("infoBulle").style.left=curX+offsetxpoint+"px"

	//same concept with the vertical position
	if (bottomedge<document.getElementById("infoBulle").offsetHeight)
	document.getElementById("infoBulle").style.top=ie? ietruebody().scrollTop+event.clientY-document.getElementById("infoBulle").offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-document.getElementById("infoBulle").offsetHeight-offsetypoint+"px"
	else
	document.getElementById("infoBulle").style.top=curY+offsetypoint+"px"
	document.getElementById("infoBulle").style.visibility="visible"
	}
}

function hideInfo(){


	if (ns6||ie){
		enabletip=false
		document.getElementById("infoBulle").style.visibility="hidden"
		document.getElementById("infoBulle").style.left="-1000px"
		document.getElementById("infoBulle").style.backgroundColor=''
		document.getElementById("infoBulle").style.width=''
		}
}

document.onmousemove=positiontip

// init rel=ticker

 function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue) {
        var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
        var arrReturnElements = new Array();
        var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
        var oCurrent;
        var oAttribute;
        for(var i=0; i<arrElements.length; i++) {
            oCurrent = arrElements[i];
            oAttribute = oCurrent.getAttribute(strAttributeName);
            if (typeof oAttribute == "string" && oAttribute.length > 0) {
                if (typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
                    arrReturnElements.push(oCurrent);
                }
            }
        }
        return arrReturnElements;
    }



function searchRel(){

		var eltsAvecRel = getElementsByAttribute(document.body, '*', 'rel')
        
		for(i = 0; i < eltsAvecRel.length; i++)
        {		
			if ( eltsAvecRel[i].getAttribute('rel').split(",")[0] == "ticker")
			{ 
		
				if (eltsAvecRel[i].getAttribute('rel').split(",")[1]== "image")
				{
					eltsAvecRel[i].onmouseover= function() {  showInfo("<img src='"+this.getAttribute('rel').split(",")[2]+"'>");  };
				}
				else if (eltsAvecRel[i].getAttribute('rel').split(",")[1]== "text")
				{
					eltsAvecRel[i].onmouseover= function() {  showInfo(this.getAttribute('rel').split(",")[2]);  };
				}
				eltsAvecRel[i].onmouseout= function() {hideInfo()};
			}
		}
}

function initInfobulle (defaultTheme){
	if(defaultTheme == null){
		document.getElementById("container").innerHTML += "<div id='infoBulle'></div>";
	}
	searchRel ();
}

