// **********************************************************************************************
// **********************************************************************************************
// ***************************** TICKER *********************************************************
// **********************************************************************************************
// **********************************************************************************************

var offsetxpoint=-350 //Customize x offset of tooltip
var offsetypoint=-450 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth)
{
	document.onmousemove=positiontip
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";
	if (ns6||ie)
	{
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML='<div class="dhtmltooltip_inner"><img src="'+thetext+'" height="150px"></div>'
		enabletip=true
		return false
	}
}

function positiontip(e)
{
	if (enabletip)
	{
		var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
		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<tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
		tipobj.style.left="5px"
		else
		//position the horizontal position of the menu where the mouse is positioned
		tipobj.style.left=curX+offsetxpoint+"px"

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
		tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
		tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	if (ns6||ie)
	{
		enabletip=false
		var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}


// **********************************************************************************************
// **********************************************************************************************
// ***************************** RESIZABLE POPUP*************************************************
// **********************************************************************************************
// **********************************************************************************************

function popupdyn(url){
//alert(url);
generate(url);
}

// ************************* GENEREATE POPUP ***********************************
function generate(name){
var theBase = document.getElementsByTagName("base");
var base_href = theBase[0].href;
name = base_href+name;
var t="<html><head><title>BELGOPRINT</title><style>html {  margin:0px;   padding:0px;   height:100%;}</style>";
t+="<script language='Javascript' src='"+base_href+"App_Themes/Default/resize_popup.js'></script>";
t+="</head><body bgcolor=#444444 topmargin=0 leftmargin=0 onLoad='XtendWin(document.photo.width,document.photo.height);'>";
t+="<div id='loading' style='visibility:visible;position:absolute;left: 0px;top: 0px;'><br>&nbsp;&nbsp;&nbsp;<img src='"+base_href+"App_Themes/Default/images/loading.gif' border='0'></div>";
t+="<div id='img' style='visibility:hidden'><img src='"+name+"' NAME=photo></div>";
t+="</body></html>";
var win=window.open("", "popup", "status=no,menubar=no,width=50,height=50,resizable=no,scrollbars=no");

win.document.write(t);
win.document.close();

}


// *******************************************************************************
// **********************  TITLE REPLACE  ****************************************                                            
// *******************************************************************************

var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 10; //This is qTip's X offset//
var qTipY = 20; //This is qTip's Y offset//



//There's No need to edit anything below this line//
tooltip = {  name : "qTip",  offsetX : qTipX,  offsetY : qTipY,  tip : null}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);

	var a, sTitle;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle && sTitle.substr(0, 1)== "*") {
			sTitle=sTitle.substring(1, sTitle.length);		
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}

window.onload = function () {
	tooltip.init ();
}

// *******************************************************************************
// **********************  LIBRAIRIE JAVASCRIPT  *********************************                                            
// *******************************************************************************



//============================================================ 
// Détermine le navigateur
//============================================================ 
var nsv=document.layers;
var iev=document.all;
if(!iev)var mov=document.getElementById;
var MouseX=0; 
var MouseY=0;
var ScrollX=0;
var ScrollY=0;


//============================================================ 
// Retourne la position des scrollbars
//============================================================ 
function GetScrollPos(){
var curScrollX=ScrollX;
var curScrollY=ScrollY;
if(nsv){
ScrollX=window.pageXOffset;
ScrollY=window.pageYOffset;
}else{
if(document.documentElement.scrollLeft)
ScrollX=document.documentElement.scrollLeft;
else ScrollX=document.body.scrollLeft;
if(document.documentElement.scrollTop)
ScrollY=document.documentElement.scrollTop;
else ScrollY=document.body.scrollTop;
}
if(curScrollX!=ScrollX||curScrollY!=ScrollY) NewScrollPos();
}


//============================================================ 
// Retourne la position de la souris
//============================================================ 
function GetMousePos(e){
var curMouseX=MouseX;
var curMouseY=MouseY;
if(nsv){
MouseX=e.pageX-2-ScrollX;
MouseY=e.pageY-2-ScrollY;
}else if(mov){
MouseX=e.clientX;
MouseY=e.clientY;
}else{ 
MouseX=window.event.x;
MouseY=window.event.y;
if((navigator.userAgent).indexOf('Opera',0)<0){ 
MouseX=MouseX-2; 
MouseY=MouseY-2;
}
}
if(curMouseX!=MouseX||curMouseY!=MouseY) NewMousePos();
}


//============================================================ 
// Permet de get par class
//============================================================ 
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
