
if (document.images) {
	preload_image_object = new Image();
	// set image url
	image_url = new Array();
	image_url[0] = "http://www2.talarforum.se/img/buttons/forelasare.png";
	image_url[1] = "http://www2.talarforum.se/img/buttons/moderatorer.png";
	image_url[2] = "http://www2.talarforum.se/img/buttons/artister.png";
	
	var i = 0;
	for(i=0; i<=3; i++){
		preload_image_object.src = image_url[i];
	}
}


function showPopUp(el) {
	var cvr = document.getElementById("cover")
	var dlg = document.getElementById(el)
	cvr.style.display = "block"
	dlg.style.display = "block"
	if (document.body.style.overflow = "hidden") {
		cvr.style.width = "100%"
		cvr.style.height = "100%"
	}
}
function closePopUp(el) {
	var cvr = document.getElementById("cover")
	var dlg = document.getElementById(el)
	cvr.style.display = "none"
	dlg.style.display = "none"
	document.body.style.overflowY = "scroll"
}

function showCountrySelectionBox() {
	var csb = document.getElementById('topbody');	
	csb.innerHTML='<table width="946" height="446" border="0" cellpadding="0" cellspacing="0" background="/img/map_country.png"><tr><td valign="top" style="padding:116px 0 0 84px;"><p><a href="http://www.talarforum.se/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/sweden.jpg" alt="SWEDEN" border="0" width="21" height="13" style="margin:0 30px 0 0;" />SWEDEN</a></p><br><p><a href="http://www.speakersforum.fi/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/finland.jpg" alt="FINLAND" border="0" width="21" height="13" style="margin:0 30px 0 0;" />FINLAND</a></p><br><p><a href="http://www.talerforum.no/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/norway.jpg" alt="NORWAY" border="0" width="21" height="13" style="margin:0 30px 0 0;" />NORWAY</a></p><br><p><a href="http://www.taleforum.dk/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/denmark.jpg" alt="DENMARK" border="0" width="21" height="13" style="margin:0 30px 0 0;" />DENMARK</a></p><br><p><a href="http://www.competenceforum.ee/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/estonia.jpg" alt="ESTONIA" border="0" width="21" height="13" style="margin:0 30px 0 0;" />ESTONIA</a></p><br><p><a href="http://www.talarforum.com/" target="_self" style="border: 0px solid red; text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:13px; color: #000000;width:300px; height:35px;" title=""><img src="/img/flags/usa.jpg" alt="USA" border="0" width="21" height="13" style="margin:0 30px 0 0;" />USA</a></p> </td></tr></table>';
}

function isValidEmailAddress(emailAddress) { 
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); 
	return pattern.test(emailAddress); 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function switchDIV(obj) {
	var el = document.getElementById(obj);
	if (el.style.display != 'none') {
		el.style.display = 'none';
	} else {
		el.style.display = 'inline';
	}
}

function displayStateDIV(obj,displaystate) {
	var el = document.getElementById(obj);
	el.style.display = displaystate;
}

function interestedIn() {
	displayStateDIV('speakerbookform','inline');
	displayStateDIV('speakertipfriendform','none');
	displayStateDIV('speakerformbox','none');
	self.scrollTo(0,400);
}

function tipFriend() {
	displayStateDIV('speakerbookform','none');
	displayStateDIV('speakertipfriendform','inline');
	displayStateDIV('speakerformbox','none');
	self.scrollTo(0,400);
}

/**
* The following is actually a javascript method I had to write to replace escape().  
* escape() is the javascript method equivalent to PHP's rawurlencode(), however it doesn't encode utf-8 multibyte characters correctly in most browsers.
*/
// Warning: the following code is JavaScript.  Ugh.  :D
// use this instead of escape() to ensure a correctly encoded url string (RFC1738)
function urlEncode (str) {
    len = str.length;
    res = new String();
    charOrd = new Number();
    
    for (i = 0; i < len; i++) {
        charOrd = str.charCodeAt(i);
        if ((charOrd >= 65 && charOrd <= 90) || (charOrd >= 97 && charOrd <= 122) || (charOrd >= 48 && charOrd <= 57) || (charOrd == 33) || (charOrd == 36) || (charOrd == 95)) {
            // this is alphanumeric or $-_.+!*'(), which according to RFC1738 we don't escape
            res += str.charAt(i);

        }
        else {
            res += '%';
            if (charOrd > 255) res += 'u';
            hexValStr = charOrd.toString(16);
            if ((hexValStr.length) % 2 == 1) hexValStr = '0' + hexValStr;
            res += hexValStr;
        }
    }

    return res;
}
