var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;
function buildSurveyBox()
{
	  
	 document.write('<div id="SurveyBox" style="visibility:hidden;position:absolute;left:0px;top:0px;font-family:verdana;font-weight:bold;	padding:40px;	background-image:url(/SiteCollectionImages/SurveyImages/gray.png);width:'+ window.screen.width + 'px; height:'+window.screen.height+'px;"></div>');
}
function buildBox()
{
 var box='<div style="position:absolute;left:0px;top:0px;width:547px;height:500px !important; border:2px solid silver; background-color:White;visibility:hidden" id="windowcontent">';
     box +='<img id="header" alt="header" src= "/SiteCollectionImages/SurveyImages/header.jpg"/>';
	 box +='<div style="width:100%;padding-top:10px;">';
     box +='<div id="left" style="float:left;width:260px; padding-left:10px;">';
     box +='<p>';
     box +='Your opinion about the St. John Ambulance web site is "Important to Us!" Please take 2 minutes to share your thoughts.';
     box +='<br/><br/> As a valued member of the St. John Ambulance Canada community, we want to better understand how we are meeting, or failing to meet, your training and community services needs via our website <a style="color:blue;" href="http://www.sja.ca/">(www.sja.ca)</a> and what we can do to improve. All responses will be kept strictly confidential. <br/><br/> Thank you in advance for your time and insightful comments.';
     box +='<br/><br/>';
     box+='<a style="color:blue;" href="javascript:fncGo(\'windowcontent\');void(0);"> Click here to take our website survey >> </a><br/><br/><br/><a style="color:blue;" href="javascript:fncCancel(\'windowcontent\');void(0);">No thank you>></a>';    
     box +='</p>';
     box+='</div>';
     box+='<div id="right" style="float:right;width:250px;padding-right:10px;">';
	 box +='<p>';
     box += 'Votre opinion concernant le site Web d\'Ambulance Saint-Jean est importante pour nous! Veuillez prendre deux minutes pour nous faire part de vos commentaires.';
     box+='<br/><br/> &Eacute;tant donn&eacute; que vous &ecirc;tes une membre appr&eacute;cit&eacute;e de la communaut&eacute; d\'Ambulance Saint-Jean du Canada, nous souhaitons mieux comprendre dans quelle mesure notre site Web <a style="color:blue;" href="http://www.sja.ca/">(www.sja.ca)</a> r&eacute;pond &aacute; vos besoins en mati&egrave;re de formation et de services communautaires ainsi que ce que nous pouvons faire pour nous am&eacute;lliorer. Toutes les r&eacute;ponses demeureront enti&egrave;rement confidentielles.<br/><br/> Merci &aacute; l\'avance de votre temps ainsi que de vos commentaires et suggestions.';
     box+='<br/><br/> <a style="color:blue;" href="javascript:fncGo(\'windowcontent\');void(0);"> Cliquez ici pour r&eacute;pondre au sondage concernant notre site Web>> </a><br/><br/><br/><a style="color:blue;" href="javascript:fncCancel(\'windowcontent\');void(0);">Non, merci.>></a>';
     box+='</p></div></div></div>';    
     document.write(box);
}
function displaySurveyBox(divId, title, width, height, left, top,boxtop) 
{
	
	var tstDiv=	document.getElementById('SurveyBox');
	tstDiv.style.visibility = "visible";
	tstDiv.style.zIndex='2147000000';
    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = boxtop + 'px';
	var addHeader;	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;	
	addHeader = '<table style="width:' + width + 'px;background-color:#DFAD00 !important;">' +
	            '<tr><td ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;" style="cursor:move;height:18px"></td>' +
	            '<td style="width:18px" align="right"><a href="javascript:fncCancel(\'' + divId + '\');void(0);">' + 
	            '<img alt="Close..." title="Close..." src="/SiteCollectionImages/SurveyImages/close.jpg" border="0"></a></td></tr></table>';    	
	document.getElementById(divId).innerHTML = addHeader + originalDivHTML;	
	var dv=document.getElementById(divId);
	dv.style.backgroundColor="#ffffff";
	dv.style.position='absolute';
	dv.style.zIndex='2147000001';
	dv.style.visibility= 'hidden';	
	dv.style.borderStyle= 'solid';
	dv.style.borderColor= '#999999';
	dv.style.borderWidth= '1px';
	document.getElementById(divId).style.visibility = "visible";
}

function fncGo(divId)
{
	var cookieName='detect';
	var cookieValue='newUser';
	var nDays=120;	
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
	window.open('http://survey.constantcontact.com/survey/a07e2kqtu6bfzln1eqf/start');
	 document.getElementById(divId).innerHTML = originalDivHTML;
    document.getElementById(divId).style.visibility = 'hidden';
    document.getElementById('SurveyBox').style.visibility = 'hidden';
    DivID = "";
}
function fncCancel(divId) {
	var cookieName='detect';
	var cookieValue='newUser';
	var nDays=120;	
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + expire.toGMTString() +"; path=/";
    document.getElementById(divId).innerHTML = originalDivHTML;
    document.getElementById(divId).style.visibility = 'hidden';
    document.getElementById('SurveyBox').style.visibility = 'hidden';
    DivID = "";           
}
function SetCookie(cookieName, cookieValue, nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + expire.toGMTString()+"; path=/";
}
function readCookie(cookieName) {
	var theCookie = "" + document.cookie;
    var ind = theCookie.indexOf(cookieName);
    if (ind == -1 || cookieName == "") {
        return null;
    }
    else {
        var ind1 = theCookie.indexOf(';', ind);
        if (ind1 == -1)
            ind1 = theCookie.length;
        return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
    }
}
function MouseDown(e) 
{
    if (over)
    {
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}
function MouseMove(e) 
{
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';
            return false;
        }
        else 
        {
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
            return false;
        }
    }
}
function MouseUp() 
{
    objDiv = null;
}
function setup()
{

    isMozilla = (document.all) ? 0 : 1;


    if (isMozilla) 
    {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

   // document.onmousedown = MouseDown;
   // document.onmousemove = MouseMove;
   // document.onmouseup = MouseUp;
	buildSurveyBox();
	buildBox();	

}
setup();
