var telexTimer=0;
var presenceTimer=0;
var inittimer=0;

var famooz_base_url;
var pre_prod;

function parseUri(sourceUri)
{
    var uriPartNames = ["source", "protocol", "authority", "domain", "port", "path", "directoryPath", "fileName", "query", "anchor"];
    var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
    var uri = {};
    
    for(var i = 0; i < 10; i++){
        uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
    }
    
    // Always end directoryPath with a trailing backslash if a path was present in the source URI
    // Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key
    if(uri.directoryPath.length > 0) {
        uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
    }
    
    return uri;
}

function configure()
{
    var list;
    
    list = parseUri(location.href);
    
    famooz_base_url = list["protocol"] + "://" + list["domain"];
    if (list["port"] != "" && list["port"] != 80) {
        famooz_base_url = famooz_base_url + ":" + list["port"];
    }
    famooz_base_url = famooz_base_url + "/";
    
    pre_prod = (famooz_base_url != "http://www.famooz.com/");
}
configure();

function return_IDradio_selected(formID)
{

    // Loop from zero to the one minus the number of radio button selections
    var formID = "" + formID;
	found=false;
    for (i = 0; i < document.forms[formID].elements.length; i++) {
        if (document.forms[formID].elements[i].checked) {
            var radioID= document.forms[formID].elements[i].value;
			if (formID=="form_telex_cmde" && radioID=="private") {
				radioID= document.getElementById('telex_privateroom_name').value;
				if (radioID=="") radioID="none";
			} 
			found=true;
			radioIDFound=radioID;
        } 
    }
	if (found==true) {
		return radioIDFound;
	} else {
		return '-1';
	}
}

function addsmiley(smiley) {
	document.getElementById('telex_live_message').value =  document.getElementById('telex_live_message').value + " " + smiley + " ";
	document.getElementById('telex_live_message').focus();
}

var preloadedImages = new Array();

function preloadImage(url, imageId)
{
    preloadedImages[imageId] = new Image();
    preloadedImages[imageId].src = url;
}

function displayLoading(divName) {
	document.getElementById(divName).style.width='120px';
}

function rate_photo(photoId, score)
{
    window.location.replace("index.php?photoRate=" + photoId + "&score=" + score );
}

function rate_wiki(wikiId, score)
{
    window.location.replace("index.php?wikiRate=" + wikiId + "&score=" + score );
}

function rate_zic(zicId, score)
{
    window.location.replace("index.php?zicRate=" + zicId + "&score=" + score );
}

function rate_gov(govId, score)
{
    window.location.replace("index.php?govRate=" + govId + "&score=" + score );
}

function rate_coach(govId, score)
{
    window.location.replace("index.php?coachRate=" + govId + "&score=" + score );
}

function rate_citycontest(govId, score)
{
    window.location.replace("index.php?citycontestRate=" + govId + "&score=" + score );
}

function rate_group(groupId, score)
{
    window.location.replace("index.php?groupRate=" + groupId + "&score=" + score );
}

function rate_wikibug(wikiId, score)
{
    window.location.replace("index.php?wikibugRate=" + wikiId + "&score=" + score );
}

function change_star(starId, betId, index)
{
    var i;
    
    if (index == 0) {
        /* la souris sort, il faut remettre les étoiles de la note comme elles étaient avant */
        document.getElementById('rated_stars' + betId).innerHTML = document.getElementById(starId + betId + "1").saveStarRating;
        document.getElementById(starId + betId + "1").saveStarRating = null;
    } else {
        if (document.getElementById(starId + betId + "1").saveStarRating == null) {
            /* la souris entre, il faut sauver le HTML à propos des étoiles de la note, afin de le remplacer, le mieux pour le sauvegarder, c'est de prendre la première étoile voter, et de sauvegarder le HTML dedans */
            document.getElementById(starId + betId + "1").saveStarRating = document.getElementById('rated_stars' + betId).innerHTML;
        }
        var title;
        switch (index) {
            case 5:
                title = "Excellent";
                break;
            case 4:
                title = "Bon";
                break;
            case 3:
                title = "Moyen";
                break;
            case 2:
                title = "Mauvais";
                break;
            case 1:
                title = "Très mauvais";
                break;
        }
        document.getElementById('rated_stars' + betId).innerHTML = "<span class='small pink'>"+title+"</span>";
    }
    for (i = 1; i <= index; i++) {
        var starName = "star";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
    for (; i <= 5; i++) {
        var starName;
        starName = "star_bg"+i;
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
}

function change_star2(starId, betId, index)
{
    var i;
    
    if (index == 0) {
        /* la souris sort, il faut remettre les étoiles de la note comme elles étaient avant */
        document.getElementById('rated_stars' + betId).innerHTML = document.getElementById(starId + betId + "1").saveStarRating;
        document.getElementById(starId + betId + "1").saveStarRating = null;
    } else {
        if (document.getElementById(starId + betId + "1").saveStarRating == null) {
            /* la souris entre, il faut sauver le HTML à propos des étoiles de la note, afin de le remplacer, le mieux pour le sauvegarder, c'est de prendre la première étoile voter, et de sauvegarder le HTML dedans */
            document.getElementById(starId + betId + "1").saveStarRating = document.getElementById('rated_stars' + betId).innerHTML;
        }
        var title;
        switch (index) {
            case 5:
                title = "excellent";
                break;
            case 4:
                title = "good";
                break;
            case 3:
                title = "average";
                break;
            case 2:
                title = "bad";
                break;
            case 1:
                title = "very bad";
                break;
        }
        document.getElementById('rated_stars' + betId).innerHTML = "<span class='small pink'>"+title+"</span>";
    }
    for (i = 1; i <= index; i++) {
        var starName = "star2";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
    for (; i <= 5; i++) {
        var starName;
        starName = "star2_bg";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
}

function change_star_zic(starId, betId, index)
{
    var i;
    
    if (index == 0) {
        /* la souris sort, il faut remettre les étoiles de la note comme elles étaient avant */
        document.getElementById('rated_stars_zic' + betId).innerHTML = document.getElementById(starId + betId + "1").saveStarRating;
        document.getElementById(starId + betId + "1").saveStarRating = null;
    } else {
        if (document.getElementById(starId + betId + "1").saveStarRating == null) {
            /* la souris entre, il faut sauver le HTML à propos des étoiles de la note, afin de le remplacer, le mieux pour le sauvegarder, c'est de prendre la première étoile voter, et de sauvegarder le HTML dedans */
            document.getElementById(starId + betId + "1").saveStarRating = document.getElementById('rated_stars_zic' + betId).innerHTML;
        }
        var title;
        switch (index) {
            case 5:
                title = "excellent";
                break;
            case 4:
                title = "good";
                break;
            case 3:
                title = "average";
                break;
            case 2:
                title = "bad";
                break;
            case 1:
                title = "very bad";
                break;
        }
        document.getElementById('rated_stars_zic' + betId).innerHTML = "<span class='small pink'>"+title+"</span>";
    }
    for (i = 1; i <= index; i++) {
        var starName = "star2";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
    for (; i <= 5; i++) {
        var starName;
        starName = "star2_bg";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
}

function change_star_gov(starId, betId, index)
{
    var i;
    
    if (index == 0) {
        /* la souris sort, il faut remettre les étoiles de la note comme elles étaient avant */
        document.getElementById('rated_stars_gov' + betId).innerHTML = document.getElementById(starId + betId + "1").saveStarRating;
        document.getElementById(starId + betId + "1").saveStarRating = null;
    } else {
        if (document.getElementById(starId + betId + "1").saveStarRating == null) {
            /* la souris entre, il faut sauver le HTML à propos des étoiles de la note, afin de le remplacer, le mieux pour le sauvegarder, c'est de prendre la première étoile voter, et de sauvegarder le HTML dedans */
            document.getElementById(starId + betId + "1").saveStarRating = document.getElementById('rated_stars_gov' + betId).innerHTML;
        }
        var title;
        switch (index) {
            case 5:
                title = "excellent";
                break;
            case 4:
                title = "bon";
                break;
            case 3:
                title = "moyen";
                break;
            case 2:
                title = "mauvais";
                break;
            case 1:
                title = "très nul";
                break;
        }
        document.getElementById('rated_stars_gov' + betId).innerHTML = "<span class='small pink'>"+title+"</span>";
    }
    for (i = 1; i <= index; i++) {
        var starName = "star2";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
    for (; i <= 5; i++) {
        var starName;
        starName = "star2_bg";
        document.getElementById(starId + betId + i).src = preloadedImages[starName].src;
    }
}

var newWin = null;
function closeWin()
{
    if (newWin != null) {
        if (!newWin.closed) {
            newWin.close();
        }
    }
}

function generic_http_request(local_url, post_data, callback)
{
    var url = famooz_base_url + local_url;
    if (document.all) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    if (post_data == null) {
        XhrObj.open("GET", url, true);
    } else {
        XhrObj.open("POST", url, true);
    }
    XhrObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    XhrObj.onreadystatechange = function() {
        if (XhrObj.readyState == 4) {
            if (callback != null) {
                callback(XhrObj);
            }
        }
    }
    XhrObj.send(post_data);
    return XhrObj;
}

function http_request(method, command, urlComplement, timer, data)
{
    http_request_with_callback(method, command, urlComplement, timer, data, null);
}

function http_request_with_callback(method, command, urlComplement, timer, data, callback)
{
    var url = "xmlhttp.php?page=" + command;
    
    if (urlComplement != null && urlComplement != '') {
        url = url  + '&' + urlComplement;
    }
        
    if (method == 'GET' && data != null) {
        url = url + "&" + data;
        data = null;
    }
    if (timer == -1) {
        request = generic_http_request(url, data, callback);
    } else {
        setTimeout(function () { generic_http_request(url, data, callback); }, timer);
    }
}

function checkSignupForm(form) {
	var email = form.elements['useremail'].value;
	var pseudo = form.elements['userpseudo'].value;
	var pw = form.elements['password1'].value;
	var pw2 = form.elements['password2'].value;
    var older14 = form.elements['14yearsold_check'].checked;
	var privacy = form.elements['policy_check'].checked;
	var msgBox = document.getElementById('divSignupErr');
	var err="";
	var codeErr = new Array();
	var urlErr = "http://www.famooz.com/resources/images/stop.gif";	
	var bullet = "<img valign='middle' src='http://www.famooz.com/resources/images/bullet.gif' alt='bullet' style='border: 0px'/>";
	
    if (email.length==0) {
		err=err+bullet+"&nbsp;empty email<br />";codeErr[0]="email";
	} else {
		if (email.indexOf("@") == -1) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.indexOf(" ") >=0 ) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.indexOf(".") == -1) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.indexOf(".")==(1+email.indexOf("@"))) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.indexOf(".")==((email.length)-1)) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.indexOf(".")==((email.length)-2)) {err=err+bullet+"&nbsp;incorrect email address<br />";codeErr[0]="email";}
		else if (email.length >= 60) {err=err+bullet+"&nbsp;email: size>60<br />";codeErr[0]="email";}
	}
	if (pseudo.length==0) {
		err=err+bullet+"&nbsp;empty username/pseudo<br />";codeErr[1]="username";
	} else {
		if (pseudo.length >= 20) {err=err+bullet+"&nbsp;oversize username<br />";codeErr[1]="username";}
		if (pseudo.length < 3) {err=err+bullet+"&nbsp;username must be over 2 chrs<br />";codeErr[1]="username";}
	}
	if (pw.length==0) {
		err=err+bullet+"&nbsp;empty password<br />";codeErr[2]="password1";
	} else {
		if (pw.indexOf(" ") >=0 ) {err=err+bullet+"&nbsp;space is not ALLOWED for password<br />";codeErr[2]="password1";}
		if (pw.length >= 20) {err=err+bullet+"&nbsp;oversize password<br />";codeErr[2]="password1";}
		if (pw.length < 6) {err=err+bullet+"&nbsp;password must have at least 6 characters<br />";codeErr[2]="password1";}
		if (pw2.length==0) {
			err=err+bullet+"&nbsp;password not confirmed<br />"; codeErr[3]="password2";
		} else if (pw != pw2) {
			err=err+bullet+"&nbsp;passwords do not match<br />"; codeErr[4]="password3";
		}
	}
	if (older14==false) {err=err+bullet+"&nbsp;you can't subscribe because you are not old enougth<br />";codeErr[9]="older14";}
	if (privacy==false) {err=err+bullet+"&nbsp;please accept youward term of use<br />";codeErr[10]="privacy";}

	if (codeErr!=null && err!="") {
		msgBox.style.backgroundColor="#ffffcc";
		msgBox.style.border="3px";
		msgBox.style.borderStyle="solid";
		msgBox.style.borderColor='#ea7100';
		msgBox.style.fontSize="12px";
		msgBox.style.weight="normal";
		msgBox.innerHTML="<table><tr><td colspan='2'><span class='error'>Please correct the following error(s):</span></td></tr>"
		+ "<tr><td><img valign='middle' src='"+urlErr+"' alt='Error' style='border: 0px'/></td><td>"+err+"</td></tr></table>";
		
		if (codeErr[0]=="email") {
			document.getElementById('divEmail').innerHTML = "<span class='error'>Email : </span>";
		} else {
			document.getElementById('divEmail').innerHTML = "<b>Email : </b>";
		}
		if (codeErr[1]=="username") {
			document.getElementById('divUsername').innerHTML = "<span class='error'>Username : </span>";
		} else {
			document.getElementById('divUsername').innerHTML = "<b>Username : </b>";
		}
		if (codeErr[2]=="password1") {
			document.getElementById('divPassword1').innerHTML = "<span class='error'>Password : </span>";
		} else {
			document.getElementById('divPassword1').innerHTML = "<b>Password : </b>";
		}
		if (codeErr[3]=="password2") {
			document.getElementById('divPassword2').innerHTML = "<span class='error'>Confirm Password : </span>";
		} else {
			document.getElementById('divPassword2').innerHTML = "<b>Confirm Password : </b>";
		}
		if (codeErr[4]=="password3") {
			document.getElementById('divPassword1').innerHTML = "<span class='error'>Password : </span>";
			document.getElementById('divPassword2').innerHTML = "<span class='error'>Confirm Password : </span>";
		}
		return false;
	} else {
		form.onsubmit=null;
		return true;
	}

}

function $( id ) { return document.getElementById( id ); }

function textCounter(field,countfield,maxlimit) {
   if (field.value.length>=maxlimit) {
      field.value = field.value.substring(0,maxlimit);
      alert('The message can be a maximum of 1,000 characters in length. Current message is '+field.value.length+' characters.');
      return false;
   } else {
      countfield.value=1+maxlimit-field.value.length;
   }
}

function smileyIntoPic () {
var mystring = document.getElementById('telex_live_message').value;
/*
	mystring=mystring.replace(/:-\)/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil18.gif" />');
	mystring=mystring.replace(/:-p/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil02.gif" />');
	mystring=mystring.replace(/:-P/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil02.gif" />');
	mystring=mystring.replace(/8o/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil03.gif" />');
	mystring=mystring.replace(/:-\(/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil04.gif" />');
	mystring=mystring.replace(/:\(/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil04.gif" />');
	mystring=mystring.replace(/:-j/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil05.gif" />');
	mystring=mystring.replace(/ -- /g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil06.gif" />');
	mystring=mystring.replace(/ \+\+ /g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil07.gif" />');
	mystring=mystring.replace(/:-D/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil08.gif" />');
	mystring=mystring.replace(/;-\(/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil09.gif" />');
	mystring=mystring.replace(/;-\)/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil01.gif" />');
	// mystring=mystring.replace(/:\'(/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil09.gif" />');
	mystring=mystring.replace(/:-!/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil10.gif" />');
	mystring=mystring.replace(/:-\?/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil11.gif" />');
	mystring=mystring.replace(/;-!/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil12.gif" />');
	mystring=mystring.replace(/:-d/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil13.gif" />');
	mystring=mystring.replace(/8-I/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil14.gif" />');
	mystring=mystring.replace(/;-?/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil15.gif" />');
	mystring=mystring.replace(/:-O/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil16.gif" />');
	mystring=mystring.replace(/;- /g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil17.gif" />');
	mystring=mystring.replace(/:-\)/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil18.gif" />');
	mystring=mystring.replace(/:\)/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil18.gif" />');
	mystring=mystring.replace(/;-D/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil19.gif" />');
	mystring=mystring.replace(/;-b/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil20.gif" />');
	mystring=mystring.replace(/;-I/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil21.gif" />');
	mystring=mystring.replace(/;-s/g,'<img align="absmiddle" src="http://www.famooz.com/resources/images/smiley/smil22.gif" />');
*/
	return mystring;
}

var hexa = "0123465789ABCDEF";
        
function DecToHexa(DecNb) {
	x = Math.floor(DecNb / 16);
	h = hexa.charAt(x);
	x = DecNb % 16;
	h += hexa.charAt(x);

	return h;
}

function Degrade(dr,dg,db,fr,fg,fb,texte) {
	steps = texte.length;
	cr = dr; cg = dg; cb = db;
	sr = (fr - dr) / steps;
	sg = (fg - dg) / steps;
	sb = (fb - db) / steps;
	var texte2="";
	for (var x = 0; x <= steps; x++) {
		texte2=texte2+'<FONT COLOR="#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb) + '">';
		texte2=texte2+texte.charAt(x);
		texte2=texte2+'</FONT>';
		cr += sr; cg += sg; cb += sb;
	}
	return texte2;
}

function openpopup(objId, typeRequest, strHeight)
{
	strHeight = strHeight + 16;
	var strWidth = 560;
	var client_height = document.body.clientHeight;
	var client_width = document.body.clientWidth;
	var left = (client_width - strWidth) / 2;
	var top = (client_height - strHeight) / 8;
	//var top = 50;// En attendant de corriger le problème de footer sous Mozilla
		
	var blockdiv = document.createElement("div");
    blockdiv.style.top = "0px";
    blockdiv.style.left = "0px";
	blockdiv.style.width = "100%";
	blockdiv.style.height = client_height+"px";
	blockdiv.style.backgroundColor = "#000000";
	blockdiv.style.opacity="0.8";
	blockdiv.style.filter="alpha(opacity=80)"; //IE4 syntax
	blockdiv.style.MozOpacity="0.8";
	blockdiv.style.zIndex = "50";
    blockdiv.style.position = "absolute";
	blockdiv.id="block_popup";
	document.body.appendChild(blockdiv);
	
    var newdiv = document.createElement("div");
    newdiv.style.top = top+"px";
    newdiv.style.left = left+"px";
	newdiv.style.width = strWidth+"px";
    newdiv.style.height = strHeight+"px";
	newdiv.style.border="1px";
    newdiv.style.borderStyle="solid";
    newdiv.style.borderColor="#ff1a99";
	newdiv.style.backgroundColor="#ffffff";
	newdiv.style.zIndex = "51";
    newdiv.style.position = "absolute";
	newdiv.id="div_popup";
	document.body.appendChild(newdiv);
	
    var newiframe = document.createElement("iframe");
    newiframe.style.width = strWidth+"px";
    newiframe.style.height = strHeight+"px";
    newiframe.style.zIndex = "51";
    newiframe.style.border = "0px";
	newiframe.style.align="middle";
	newiframe.style.frameborder="0px";
	newiframe.id="iframe_popup";
	newiframe.src = famooz_base_url + 'popup.php?' + typeRequest + '=' + objId;
	newdiv.appendChild(newiframe);
}

function openpopup_close()
{
	var body_div_popup = parent.document.body;
	var div_popup = parent.document.getElementById('div_popup');
	var oldiframe = parent.document.getElementById('iframe_popup');
	var old_block_popup = parent.document.getElementById('block_popup');
	
	div_popup.removeChild(oldiframe);
	body_div_popup.removeChild(div_popup);
	body_div_popup.removeChild(old_block_popup);	
}

function roundTooltip(divName)
{
	roundedCornerObj = new DHTMLgoodies_roundedCorners();
	// (divId,xRadius,yRadius,color,backgroundColor,padding,heightOfContent,whichCorners)
	roundedCornerObj.addTarget('div_tooltip_'+divName,10,10,'#ffb5da','#333333',0);
	roundedCornerObj.init();
}

function FamoozPopup(popupmessage, OKurl, btn1, btn2, type, onlyOneButton)
{
	var strHeight = 300;
	var strWidth = 400;
	var client_height = document.body.clientHeight;
	var client_width = document.body.clientWidth;
	var left = (client_width - strWidth) / 2;
	//var top = (client_height - strHeight) / 3;
	var top = 250;// En attendant de corriger le problème de footer sous Mozilla
		
	var blockdiv = document.createElement("div");
    blockdiv.style.top = "0px";
    blockdiv.style.left = "0px";
	blockdiv.style.width = "100%";
	blockdiv.style.height = client_height+"px";
	blockdiv.style.backgroundColor = "#000000";
	blockdiv.style.opacity="0.8";
	blockdiv.style.filter="alpha(opacity=80)"; //IE4 syntax
	blockdiv.style.MozOpacity="0.8";
	blockdiv.style.zIndex = "60";
    blockdiv.style.position = "absolute";
	blockdiv.id="block_popup";
	document.body.appendChild(blockdiv);
	
    var newdiv = document.createElement("div");
    newdiv.style.top = top+"px";
    newdiv.style.left = left+"px";
	newdiv.style.width = strWidth+"px";
    newdiv.style.height = strHeight+"px";
	newdiv.style.border="8px";
    newdiv.style.borderStyle="solid";
    newdiv.style.borderColor="#333333";
	newdiv.style.backgroundColor="#F1F1F1";
	newdiv.style.zIndex = "61";
    newdiv.style.position = "absolute";
	newdiv.id="div_popup";
	newdiv.className="arrondi2 halo";
	
	if (type==1) {
		popup_type_picto=famooz_base_url+"/resources/images/picto_popup_question.png";
	} else if (type==2) {
		popup_type_picto=famooz_base_url+"/resources/images/picto_popup_warning.png";
	} else {
		popup_type_picto=famooz_base_url+"/resources/images/picto_popup_error.png";
	}
	if (onlyOneButton==false) {
		if (OKurl.indexOf("submit()")>=0) {
			OKurl="onclick='"+OKurl+";return false;'";
		} else {
			OKurl="onclick='window.location.replace(\""+OKurl+"\");return false;'";
		}
		btn2="&nbsp;&nbsp;&nbsp;&nbsp;<a class='button1' href='#' "+OKurl+" >"+btn2+"</a>";
	} else {
		btn2="";
	}
	newdiv.innerHTML="<table width='100%' border='0' cellpadding='0' cellspacing='4'><tr><td><img src='"+popup_type_picto+"' style='margin:14px;'/></td><td><span class='medium dark'>"+popupmessage+"</span></td></tr></table><br/><center><a class='button1' href='#' onclick='FamoozPopup_close();return false;' >"+btn1+"</a>"+btn2+"</center>";
    
	document.body.appendChild(newdiv);
	

}

function FamoozPopup_close()
{
	var body_div_popup = parent.document.body;
	var div_popup = parent.document.getElementById('div_popup');
	var old_block_popup = parent.document.getElementById('block_popup');
	
	body_div_popup.removeChild(div_popup);
	body_div_popup.removeChild(old_block_popup);	
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : ";path=/" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

