/*if (top.location == window.location) {
	location.replace("index.html");
}*/

//Image preloader
imageSource = new Array (
	"images/bg_header_01.gif",
	"images/bg_header_02.gif",
	"images/bg_header_03.gif",
	"images/bg_header_04.gif"
);

imageList = new Array ();

for (counter in imageSource) {
    imageList[counter] = new Image();
    imageList[counter].src = imageSource[counter];
}

//Navigation rollover images with preload
//Swedish
swe01on = new Image();
swe01on.src = thisPath + 'images/nav-startsidan-h.gif';
swe01off = new Image();
swe01off.src = thisPath + 'images/nav-startsidan.gif';
swe02on = new Image();
swe02on.src = thisPath + 'images/nav-ledigalokaler-h.gif';
swe02off = new Image();
swe02off.src = thisPath + 'images/nav-ledigalokaler.gif';
swe03on = new Image();
swe03on.src = thisPath + 'images/nav-hyresgaester-h.gif';
swe03off = new Image();
swe03off.src = thisPath + 'images/nav-hyresgaester.gif';
swe04on = new Image();
swe04on.src = thisPath + 'images/nav-wtc-malmoe-h.gif';
swe04off = new Image();
swe04off.src = thisPath + 'images/nav-wtc-malmoe.gif';
swe05on = new Image();
swe05on.src = thisPath + 'images/nav-bli-medlem-h.gif';
swe05off = new Image();
swe05off.src = thisPath + 'images/nav-bli-medlem.gif';
swe06on = new Image();
swe06on.src = thisPath + 'images/nav-nyheter-h.gif';
swe06off = new Image();
swe06off.src = thisPath + 'images/nav-nyheter.gif';
swe07on = new Image();
swe07on.src = thisPath + 'images/nav-kontakt-h.gif';
swe07off = new Image();
swe07off.src = thisPath + 'images/nav-kontakt.gif';
swe08on = new Image();
swe08on.src = thisPath + 'images/nav-konferens-h.gif';
swe08off = new Image();
swe08off.src = thisPath + 'images/nav-konferens.gif';
//English
eng01on = new Image();
eng01on.src = thisPath + 'images/nav-startsidan-h.gif';
eng01off = new Image();
eng01off.src = thisPath + 'images/nav-startsidan.gif';
eng02on = new Image();
eng02on.src = thisPath + 'images/nav-premises-h.gif';
eng02off = new Image();
eng02off.src = thisPath + 'images/nav-premises.gif';
eng03on = new Image();
eng03on.src = thisPath + 'images/nav-tenant-services-h.gif';
eng03off = new Image();
eng03off.src = thisPath + 'images/nav-tenant-services.gif';
eng04on = new Image();
eng04on.src = thisPath + 'images/nav-wtc-malmoe-h.gif';
eng04off = new Image();
eng04off.src = thisPath + 'images/nav-wtc-malmoe.gif';
eng05on = new Image();
eng05on.src = thisPath + 'images/nav-become-a-member-h.gif';
eng05off = new Image();
eng05off.src = thisPath + 'images/nav-become-a-member.gif';
eng06on = new Image();
eng06on.src = thisPath + 'images/nav-news-h.gif';
eng06off = new Image();
eng06off.src = thisPath + 'images/nav-news.gif';
eng07on = new Image();
eng07on.src = thisPath + 'images/nav-contact-h.gif';
eng07off = new Image();
eng07off.src = thisPath + 'images/nav-contact.gif';
eng08on = new Image();
eng08on.src = thisPath + 'images/nav-conference-h.gif';
eng08off = new Image();
eng08off.src = thisPath + 'images/nav-conference.gif';

function changeImages() {
	if (document.images) {
		for (var i = 0; i < changeImages.arguments.length; i += 2) {
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i + 1] + '.src');
		}
	}
}

//Remove outline around links
function removeFocusOnAllLinks(){
	for(var i=0 ; i < document.links.length ; i++)
	document.links[i].onfocus=blurLink;
}

function blurLink() {
	if (this.blur) this.blur();
}

window.onload=removeFocusOnAllLinks;


//Open url in new window from selection in select box
function gotoPage(thisurl) {
	if (thisurl != "") {
		window.open(thisurl);
	}
}

//Iframe resizer
var ie = (document.all) ? true : false; //sets browser to Internet Explorer
var ns6_mozilla = (document.getElementById) ? true : false; //sets browser to Netscape 6 or higher, or Mozilla

function ResizeFrame()
{
	//if Macintosh
	if (navigator.platform.indexOf('Mac') != -1) {
		//if Internet Explorer
		if (ie) {
			document.all.listitems.height=listitems.document.documentElement.offsetHeight+0;
		}
		//if at least Netscape 6 or Mozilla
		else if (ns6_mozilla) {
			document.getElementById("listitems").height=listitems.document.body.offsetHeight+0;
		}
	}
	else {
		//if Internet Explorer
		if (ie) {
			document.all.listitems.height=listitems.document.body.scrollHeight+0;
		}
		//if at least Netscape 6 or Mozilla
		else if (ns6_mozilla) {
			document.getElementById("listitems").height=listitems.document.body.offsetHeight+0;
		}
	}		
}

//Call popup window for map
function popThis(thisObj, thisWidth, thisHeight) {
	leftPos = (screen.width) ? (screen.width-thisWidth)/2 : 0;
	topPos = (screen.height) ? (screen.height-thisHeight)/2 : 0;
	window.open(thisObj, "", "resizable=0,height="+thisHeight+",width="+thisWidth+",left="+leftPos+",top="+topPos);
}

//Browser detect
var detect = navigator.userAgent.toLowerCase();
var OS, browser, version, total, thestring;

if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) {
	browser = "Safari";
}
else if (checkIt('omniweb')) {
	browser = "OmniWeb";
}
else if (checkIt('opera')) {
	browser = "Opera";
}
else if (checkIt('webtv')) {
	browser = "WebTV";
}
else if (checkIt('icab')) {
	browser = "iCab";
}
else if (checkIt('msie')) {
	browser = "Internet Explorer";
}
else if (!checkIt('compatible')) {
	browser = "Netscape Navigator";
	version = detect.charAt(8);
}
else {
	browser = "An unknown browser";
}

if (!version) version = detect.charAt(place + thestring.length);

if (!OS) {
	if (checkIt('linux')) {
		OS = "Linux";
	}
	else if (checkIt('x11')) {
		OS = "Unix";
	}
	else if (checkIt('mac')) {
		OS = "Mac";
	}
	else if (checkIt('win')) {
		OS = "Windows";
	}
	else {
		OS = "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function chkfrmFelanmalan() {
	var form = document.frmFelanmalan;
	if (form.company.value == "") {
		alert('Du måste ange företag!');
		form.company.focus();
		return false;
	}
	else if (form.name.value == "") {
		alert('Du måste ange namn!');
		form.name.focus();
		return false;
	}
	else if (form.message.value == "") {
		alert('Du måste ange en felbeskrivning!');
		form.message.focus();
		return false;
	}
}

function chkfrmAnmalan() {
	var form = document.frmAnmalan;
	if (form.company.value == "") {
		alert('Du måste ange företag!');
		form.company.focus();
		return false;
	}
	else if (form.street.value == "") {
		alert('Du måste ange adress!');
		form.street.focus();
		return false;
	}
	else if (form.zip.value == "") {
		alert('Du måste ange postnummer!');
		form.zip.focus();
		return false;
	}
	else if (form.city.value == "") {
		alert('Du måste ange postort!');
		form.city.focus();
		return false;
	}
	else if (form.phone.value == "") {
		alert('Du måste ange telefonnummer!');
		form.phone.focus();
		return false;
	}
	else if (form.employees_total.value == "") {
		alert('Du måste ange antalet anställda i bolaget!');
		form.employees_total.focus();
		return false;
	}
	else if (form.employees_here.value == "") {
		alert('Du måste ange antalet anställda på arbetsstället!');
		form.employees_here.focus();
		return false;
	}
	else if (form.turnover.value == "") {
		alert('Du måste ange omsättning!');
		form.turnover.focus();
		return false;
	}
	else if (form.orgno.value == "") {
		alert('Du måste ange organisationsnummer!');
		form.orgno.focus();
		return false;
	}
	else if (form.company_type.value == "") {
		alert('Du måste ange bolagsform!');
		form.company_type.focus();
		return false;
	}
	else if (form.ceo_company.value == "") {
		alert('Du måste ange VD eller platschef!');
		form.ceo_company.focus();
		return false;
	}
	
	if (form.homepage.value != "") {
		if (form.homepage.value.substring(0,7) != "http://") {
			alert('Du måste ange http:// framför hemsideadressen!');
			form.homepage.focus();
			return false;
		}
	}
	
	if (form.company_email.value == "") {
		alert('Du måste ange företagets epostadress!');
		form.company_email.focus();
		return false;
	}
	else if (form.contact_name.value == "") {
		alert('Du måste ange kontaktperson!');
		form.contact_name.focus();
		return false;
	}
	else if (form.contact_email.value == "") {
		alert('Du måste ange kontaktpersonens epostadress!');
		form.contact_email.focus();
		return false;
	}
	else if (form.description_se.value == "") {
		alert('Du måste skriva en verksamhetsbeskrivning på svenska!');
		form.description_se.focus();
		return false;
	}
	else if (form.submitter.value == "") {
		alert('Du måste ange namn på anmälaren!');
		form.submitter.focus();
		return false;
	}
	else if (form.submitter_email.value == "") {
		alert('Du måste ange namn på anmälarens epostadress!');
		form.submitter_email.focus();
		return false;
	}
}

function chkfrmRegister() {
	var form = document.frmAnmalan;
	if (form.company.value == "") {
		alert('Missing value for company!');
		form.company.focus();
		return false;
	}
	else if (form.street.value == "") {
		alert('Missing value for address!');
		form.street.focus();
		return false;
	}
	else if (form.zip.value == "") {
		alert('Missing value for post code!');
		form.zip.focus();
		return false;
	}
	else if (form.city.value == "") {
		alert('Missing value for town/city!');
		form.city.focus();
		return false;
	}
	else if (form.phone.value == "") {
		alert('Missing value for telephone!');
		form.phone.focus();
		return false;
	}
	else if (form.employees_total.value == "") {
		alert('Missing value for number of employees in the company!');
		form.employees_total.focus();
		return false;
	}
	else if (form.employees_here.value == "") {
		alert('Missing value for number of employees at the work place!');
		form.employees_here.focus();
		return false;
	}
	else if (form.turnover.value == "") {
		alert('Missing value for turnover!');
		form.turnover.focus();
		return false;
	}
	else if (form.orgno.value == "") {
		alert('Missing value for organization number!');
		form.orgno.focus();
		return false;
	}
	else if (form.company_type.value == "") {
		alert('Missing value for company form!');
		form.company_type.focus();
		return false;
	}
	else if (form.ceo_company.value == "") {
		alert('Missing value for MD/Site Manager!');
		form.ceo_company.focus();
		return false;
	}
	
	if (form.homepage.value != "") {
		if (form.homepage.value.substring(0,7) != "http://") {
			alert('Missing http:// before web site url!');
			form.homepage.focus();
			return false;
		}
	}
	
	if (form.company_email.value == "") {
		alert('Missing value for email for the company!');
		form.company_email.focus();
		return false;
	}
	else if (form.contact_name.value == "") {
		alert('Missing value for contact person!');
		form.contact_name.focus();
		return false;
	}
	else if (form.contact_email.value == "") {
		alert('Missing value for email for contact person');
		form.contact_email.focus();
		return false;
	}
	else if (form.description_se.value == "") {
		alert('Missing value for description of activity in Swedish!');
		form.description_se.focus();
		return false;
	}
	else if (form.submitter.value == "") {
		alert('Missing value for applicant!');
		form.submitter.focus();
		return false;
	}
	else if (form.submitter_email.value == "") {
		alert('Missing value for e-mail for applicant!');
		form.submitter_email.focus();
		return false;
	}
}
