var sent = false;
var strSVIDate;
var oNow = new Date();
var iNowDay = oNow.getDay();
var iNowHours = oNow.getHours();
var iNowMinutes = oNow.getMinutes();
var iNowYear = oNow.getYear();
var iNowMonth = oNow.getMonth();
var iNowDayOfMonth = oNow.getDate();
var arrDays = new Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
var strDayToday = arrDays[iNowDay-1];

flashVersion_DONTKNOW = -1;

if (iNowDayOfMonth <= 9){
	iNowDayOfMonth = "0" + iNowDayOfMonth;
}
if (iNowMonth <= 9){
	iNowMonth = "0" + iNowMonth;
}
if (iNowMinutes <= 9){
	iNowMinutes = "0" + iNowMinutes;
}

strSVIDate = strDayToday + " " + iNowYear + "." + iNowMonth + "." + iNowDayOfMonth + "<br>" + iNowHours + ":" + iNowMinutes + " PM GMT+2";

var strUserAgent = navigator.userAgent;

function popupLink(sURL) {
	window.open("/imagewindow.asp?disp=" + escape(sURL), "popuplink", "height=350,width=400,status=no,top=100,left=200,marginheight=0,marginwidth=0,scrollbars=1,toolbar=no,menubar=no,location=no,resizable=1");
}

function topMenuHighLight(obj){
	if (document.all && strUserAgent.indexOf("Win") != -1){
		objID = obj.uniqueID;
		if(document.all[objID]) {
			document.all[objID].className = "topMenuHL";
		}
	}
}

function topMenuLowLight(obj){
	if (document.all && strUserAgent.indexOf("Win") != -1){
		objID = obj.uniqueID;
		if(document.all[objID]) {
			document.all[objID].className = "topMenuLL";
		}
	}
}

function leftMenuHighLight(obj, sClassName){
	if (document.all && strUserAgent.indexOf("Win") != -1){
		objID = obj.uniqueID;
		document.all[objID].className = sClassName;
	}
}

function leftMenuLowLight(obj, sClassName){
	if (document.all && strUserAgent.indexOf("Win") != -1){
		objID = obj.uniqueID;
		document.all[objID].className = sClassName;
	}
}

function goTo(strLocation) {
	if (document.forms.navigationForm) {
		if (strLocation.indexOf("javascript:") > -1) {
			eval(strLocation);
		} else {
			document.forms.navigationForm.action = strLocation;
			document.forms.navigationForm.submit();
		}
	} else {
		if (strLocation.indexOf("javascript:") > -1) {
			eval(strLocation);
		} else {
			document.location = strLocation;
		}
	}
}


function openPopup(sUrl, sName, iWidth, iHeight, iLeft, iTop, bScroll) {
	var pos;
	
	if (sName == "") {
		sName = "popupWindow";
	}
	
	if (bScroll == true) {
		bScroll = 1;
	} else {
		bScroll = 0;
	}
		
   window.open(sUrl, sName, "left=" + iLeft + ",top=" + iTop + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + bScroll + ",resizable=0,copyhistory=0,width=" + iWidth + ",height=" + iHeight);
}

// Flash Version Detector  v1.1.4
// http://www.dithered.com/javascript/flash_detect/index.html
// code by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
// with VBScript code from Alastair Hamilton
agent = navigator.userAgent.toLowerCase();
function getFlashVersion() {
	if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		return getFlashVersion1();
	} else {
		return getFlashVersion2();
	}
}

function getFlashVersion1() {
	flashVersion = -1;
	document.write('<scr' + 'ipt language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('dim obFlash \n');
	document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
	document.write('if IsObject(obFlash) then \n');
	document.write('flashVersion = 7 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
	document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
	document.write('flashVersion = 6 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
	document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
	document.write('flashVersion = 5 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
	document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
	document.write('flashVersion = 4 \n');
	document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
	document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
	document.write('flashVersion = 3 \n');
	document.write('end if');
	document.write('</scr' + 'ipt\> \n');
	return flashVersion;
}

function getFlashVersion2() {
	flashVersion_DONTKNOW = -1;
	var flashVersion = flashVersion_DONTKNOW;
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
			else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
			else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
			else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
			else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

function menuItemEffect(obj, sClassName){
	if (document.all && strUserAgent.indexOf("Win") != -1){
		objID = obj.uniqueID;
		document.all[objID].className = sClassName;
	}
}

function isMac() {
	return (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
}

function cancelBubble() {
	if (event) {
		if (event.stopPropagation) {
			event.stopPropagation();
		} else {
			event.cancelBubble = true;
		}
	}
}

// If the user is trying to open the page in an external frameset, open a new window and close the opener.
// marcus.andersson@sublime.se 20030708
//
// Changed for EP4 2004-02-20 by Johan Bergens
/*if (document.frames.length > 0) {
// is IFRAME
	var frm = document.frames;
	for (i=0; i<frm.length; i++) {
		alert("IFRAME: " + frm(i).location);
	}
} else */
if (window.parent.frames.length > 0){
// is FRAME

	var blnExtFrames = false;
	var blnBreak = false;
	var frm = window.parent.frames;
	for (i=0; i<frm.length; i++) {
		if (window.name != "ep_work"){
			if (window.name != "headerFrame"){
				if (window.name != "navFrame") {
					if (window.name.indexOf("weather") < 0) {
						blnExtFrames = true
						break;
					}
				}
			}
		}
//alert("window.name = " + window.name);
		if (window.name != "EditPanel") {
			blnExtFrames = true;
			break;
		}
	}
// DEBUG 
// Turn off this check for the moment since it doesn't work
	/*
	if (blnExtFrames) {
		window.open(this.location);
		window.parent.close();
	}
	*/
}


// Added for dynamic handling of the flash area on the fron page for IE
// marcus.andersson@sublime.se 20030711
function getBrowserSize() {
	var myWidth = 0, myHeight = 0;
	if(typeof(window.innerWidth) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else {
		if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else {
			if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			} else {
				myWidth = document.body.offsetWidth;
				myHeight = document.body.offsetHeight;
			}
		}
	}
	return myWidth;
}


// Client side script to generate the flash object tags moved to here
// Added by ulf@sublime.se 2004-08-31
function client_PrintConditionalFlash(file, width, height, altimage, link, linktarget) {
	if (getFlashVersion() >= 5) {
		document.write('<object tabindex="-1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0" width="' + width + '" height="' + height + '">');
		document.write('	<param name="movie" value="' + file + '">');
		document.write('	<param name="quality" value="high">');
		document.write('	<param name="loop" value="true">');
		document.write('	<embed width="' + width + '" height="' + height + '" loop="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" src="' + file + '" type="application/x-shockwave-flash"></embed>');
		document.write('</object>');
	} else {
		if(link.Length>0)
			document.write('<a href="' + link + '" target="' + linktarget + '">');
		document.write('<img src="' + altimage + '" width="' + width + '" height="' +  height + '" border="0">');
		if(link.Length>0)
			document.write('</a>');
		document.write('<br>');
	}
}

function launchSAS(url) {

	if ((isMac()) && (navigator.appName == "Microsoft Internet Explorer")) 
	{
		iLeft = 0;
		iTop = 0;
		iWidth = 765;
		iHeight = 610;
	} 
	else 
	{
		iLeft = 10;
		iTop = 10;
		iWidth = 755;
		iHeight = 550;
	}

	swedenAndSwedesPopup = openPopup(url, "SwedenAndSwedesPopup", iWidth, iHeight, iLeft, iTop, false);
}

function openBlockedWindow(thisURL) {
	window.open(thisURL,"","left=" + iLeft + ",top=" + iTop + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=" + iWidth + ",height=" + iHeight);
}

function changeImage(imageName, newSrc)
{
	if(document.images[imageName])
		document.images[imageName].src = newSrc;
}

zoomLevel = 0;

function zoomInMap(level) {
	if (!level) {
		zoomLevel++;
		level = zoomLevel;
	}
	
	if (level == 1) {
		changeImage("Map", "/subsites/studyinsweden/images/misc/EuropeMap.gif");
	} else if (level > 1) {
		openPopup("/subsites/studyinsweden/staticpages/SwedenMap.htm", "SwedenMap", 281, 530, 10, 10, false);
	}
}
