﻿//var jsUrl = "http://webstatic.dev/webstatic/gwt/scripts/";
var jsUrl = "http://webstatic-prod.masternaut.com/webstatic/gwt/scripts/";

var resourcesDir = "geonaut-resources";

var title 				= "Votre avis nous intéresse";
var presentationText 	= "Afin d’améliorer nos offres produits pour qu’elles répondent au mieux à vos attentes, nous vous remercions de prendre quelques instants pour remplir notre questionnaire. ";
var linkText 			= "Cliquez-ici";
var linkUrl 			= "http://www.masternaut.com";

var width = 250;
var height = 120;

LoginLink = function (){
	
	var thisObject			= this;
	this.container 			= null;	
	this.currentLeft		= 0;	
	constructor();
	
	function constructor(){	
		//LoadCSS("http://webstatic-prod.masternaut.com/webstatic/gwt/skins/aqua/_aqua.css");
		LoadCSS(jsUrl+ resourcesDir +"/geonaut-login-script.css");		
		createHTML();
		initPosition();
		showContainer();
	}
	
	function createHTML(){
		
		thisObject.container = document.createElement("div");
		thisObject.container.style.width = width + "px";
		thisObject.container.style.position = "absolute";

		
		var html = "";

		html += "	<table cellspacing='0' cellpadding='0' style='width: 100%;'><tbody>";
		html += "		<tr><td>";
		html += "				<table cellspacing='0' cellpadding='0' style='width: 100%;'>";
		html += "				<tbody>";
		html += "					<tr>";
		html += "						<td class=' ExpandableTopLeft '>&nbsp;</td>";
		html += "						<td class=' ExpandableTopMiddle '>";
		html += "							<div style='width: 100%;' >";
		html += "								<div style='display: inline;'>" + title + "</div>";
		html += "							</div>";
		html += "						</td>";
		html += "						<td width='1px' class=' ExpandableTopMiddle '>&nbsp;</td>";
		html += "						<td width='20px' align='right' style='vertical-align: middle;' class=' ExpandableTopExpand '>";
		html += "							<img id='ImgClose'   src='"+jsUrl+ resourcesDir + "/windowTopClose_on.png'/></td>";
		html += "						<td class=' ExpandableTopRight '>&nbsp;</td>";
		html += "					</tr>";
		html += "				</tbody>";
		html += "				</table>";
		html += "		</td></tr>		";
		html += "	</tbody></table>";
		html += "	<table cellspacing='0' cellpadding='0' style='width: 100%;'><tbody>";
		html += "		<tr>";
		html += "			<td class=' ExpandableBorderLeft '>&nbsp;</td>";
		html += "			<td class='ExpandableCenter'>";
		html += "				<div style='overflow: auto; position: relative; width: 100%; height: 100%;'>";
		html += "					<span class=' Common_Font_Std Common_Default_Font_Color '>";
		html +=  		presentationText + "<a href='" + linkUrl+ "' target=blanc>" + linkText + "</a>";
		html += "					</span>";
		html += "				</div>";
		html += "			</td>";
		html += "			<td class=' ExpandableBorderRight '>&nbsp;</td></tr><tr><td class=' ExpandableBottomLeft '>&nbsp;</td><td class=' ExpandableBottomMiddle '>&nbsp;</td><td class=' ExpandableBottomRight '>&nbsp;</td>";
		html += "		</tr>";
		html += "	</tbody></table>";	
	
		thisObject.container.innerHTML = html;
		
		
	}
	
	function initPosition(){
		thisObject.currentLeft = -width;
		thisObject.container.style.left = thisObject.currentLeft + "px";
		document.body.appendChild(thisObject.container);
		//alert(thisObject.container.offsetHeight);
		thisObject.container.style.top = getWindowHeight() - height + "px";	//thisObject.container.offsetHeight
		document.getElementById("ImgClose").onclick = hideContainer;
	}
	
	function showContainer(){
		thisObject.currentLeft += 10;
		thisObject.container.style.left = thisObject.currentLeft + "px";
		if(thisObject.currentLeft < 10){
			setTimeout(function(){showContainer()},60);
		}
	}
	
	function hideContainer(){
		thisObject.currentLeft -= 10;
		thisObject.container.style.left = thisObject.currentLeft + "px";
		if(thisObject.currentLeft > - width){
			setTimeout(function(){hideContainer()},60);
		}
	}
}

function LoadCSS(path){
	
    var link  = document.createElement("link");
    link.type = "text/css";
    link.rel  = "stylesheet";
    link.href = path;
	try{
		document.getElementsByTagName("head")[0].appendChild(link);
	}catch(e){
		alert(e.message);
	}
    
}

function getWindowHeight(){
	if (document.body){	
		return document.body.clientHeight;
	} else{
		return window.innerHeight;
	}
}
	

//setTimeout(function(){new LoginLink();}, 2000);	
