// JavaScript Document
var xcoord, ycoord;
document.onmousemove = getCoord;

function getCoord(e) {

  if( !e ) { e = window.event; }
  if( !e ) { return; }
  if( typeof( e.pageX ) == 'number' ) {
    xcoord = e.pageX;
    ycoord = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    xcoord = e.clientX;
    ycoord = e.clientY;
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      xcoord += document.body.scrollLeft;
      ycoord += document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      xcoord += document.documentElement.scrollLeft;
      ycoord += document.documentElement.scrollTop;
    }
  } else { return; }

}

function showSendQuote(quoteID) {

  	globalDiv = 'quote_' + quoteID;
	var html = document.getElementById('selectQuote').innerHTML;
	var regExp = /_QUOTE_ID_/;
	html = html.replace(regExp, quoteID);
	 
 	showAjaxDiv(globalDiv, html);
}
 
function selectQuote(quoteID) {

	var url = "/citations/selectquote_ajax/" + quoteID + ".html";
	var outDiv = "quote_" + quoteID;
	var imgID = "s" + quoteID;
	xget(url, outDiv, imgID);

}

function selectQuoteInetgrated(quoteID) {

 	globalDiv = 'quote_' + quoteID;
	var html = document.getElementById('loginDiv').innerHTML;
	var regExp = /_QUOTE_ID_/;
	html = html.replace(regExp, quoteID);
	regExp = /_DO_/; 
	html = html.replace(regExp, 'selectquote_ajax');

 	showAjaxDiv(globalDiv, html);
	
}

function showAjaxDiv(divId, content, w, h) {

    xWidth = w || 400;
	// xHeight = h || 400;
	
	var xDiv = document.getElementById(divId);
	xDiv.style.display = "block";
	
	var str = "<div class='closeDiv'><a href='javascript:toggle()'> <img src='/iquotes/close.png' alt='Fermer' border='0'></a></div>"; 
	xDiv.innerHTML = str + content;
 	xDiv.style.width = xWidth + "px";
	//xDiv.style.height = xHeight + "px";
 
	var xpos = xcoord; xpos -= 150;
        var ypos = ycoord; ypos += 20;
 	
	xDiv.style.left = xpos + "px";
	xDiv.style.top = ypos + "px";
	xDiv.focus();
}

// visibility function 

function toggle(divId, xdisplay) {

	var hDivId = divId || globalDiv;
	var hDisplay = xdisplay || 'block';
	
	var hDiv = document.getElementById(hDivId);
	 
	 	if (hDiv != null ) {
	    	
			if (hDiv.style.display == "none" || hDiv.style.display == "") {
     			 hDiv.style.display = hDisplay;
    		} else {
     			 hDiv.style.display = "none";
    		}
	 }
}

function o(url, divId) {
	
	        divId = divId ||'overlay'; 
			    
	         
			
			el = document.getElementById(divId);
			el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
			//setOpacity(divId, 100);
			// iget(url, divId);
			 
}	

 
function setOpacity(p_obj, p_value) { 

	var o = document.getElementById(p_obj); 
	o.style.opacity = p_value; 
	o.style.filter = 'alpha(opacity=' + p_value + ')';

}