function checkAll(formName, cName) 
{
	
	mac = navigator.userAgent.indexOf("mac") > -1; 
	n = navigator.userAgent; 
	
	var agent = navigator.userAgent.toLowerCase();
	var agent_isMac = (agent.indexOf('mac') > -1);
	var agent_isIE = (agent.indexOf("msie")>-1 && parseInt(navigator.appVersion.substring(0,1))>=4);
	
	if(agent_isMac && agent_isIE)
	{
		for(var i=0;i<eval("document." + formName + ".elements").length;i++){
		var e=eval("document." + formName + ".elements[" + i + "]");
		if(e.name==cName) e.checked=eval("document." + formName + ".All" + cName + ".checked");
		}
	}
	else
	{

		theForm = document.getElementById(formName);
		
		for (i=0,n=theForm.elements.length;i<n;i++)
			if(theForm.elements[i])
			{
		    if (theForm.elements[i].name == cName)
		    {
					var e=eval("document." + formName + ".elements[" + i + "]");
					if(e.name==cName) e.checked=eval("document." + formName + ".All" + cName + ".checked");
		    }
		  }
	}
}


function toggleThis(thetype,theid) {
	  
  activity = document.getElementById(thetype+"_"+theid);
  facts = document.getElementById(thetype+"_facts"+theid);
  closet = document.getElementById(thetype+"_close"+theid);

  if (thetype == 'ak' || thetype == 'bo' || thetype == 'se' )
  img = document.getElementById(thetype+"_img"+theid); 
	
	if(facts.style.display != 'block') {
		activity.style.border = '1px solid #83cfdf';
		activity.style.padding = '8px';
		facts.style.display = 'block';
		closet.style.display = 'block';
		if (thetype == 'ak' || thetype == 'bo' || thetype == 'se' )
		img.style.display = 'block';
	}		
	else {
		activity.style.border = '0px';
		activity.style.padding = '0px';
		facts.style.display = 'none';
		closet.style.display = 'none';
		
		if (thetype == 'ak' || thetype == 'bo' || thetype == 'se' )
		img.style.display = 'none';
	}
}


function themesCheck(theForm, alertTxt)
{
   if (!checkInput(theForm.theme, '')){
     alert(alertTxt);
     return false;
    }
   return true 
}


function accomodationCheck(theForm, alertTxtcounties, alertTxtaccomodation)
{
   if (!checkInput(theForm.counties, '')){
     alert(alertTxtcounties);
     return false;
    }
  
   if (!checkInput(theForm.accomodationtype, '')){
     alert(alertTxtaccomodation);
     return false;
    }
    
   return true 
}


function doSubmit(theForm, LangID) {
  
  switch (LangID)
   {
    case 1:   txt = 'You have not selected a county'; break
    case 2:   txt = 'Du har inte valt kommun.'; break
    case 3:   txt = 'Keine Gemeinde ausgew\344hlt'; break
    }
  
  if (checkInput(theForm.counties, txt)) {
		if (checkInput(theForm.activitytypes, '') || checkInput(theForm.sighttypes, '') || checkInput(theForm.Alleventtypes, '') ) {
			return true;
		} else {
		  switch (LangID)
		  { 
      case 1:   alert("You have not selected an activity or sight"); break
      case 2:   alert('Du har inte valt aktivitet eller sevärdhet.'); break
      case 3:   alert("Sie haben weder \"Aktivit\344t\" noch \"Sehensw\374rdigkeit\" ."); 
     
      break
     } 
     	return false;
		}
	}
	
	return false;
}

function checkInput(theField, textString) {
	if (theField.length > 1) 
	{
		for (j=0; j<theField.length; j++) {
			if (theField[j].checked) {
				return true;
			}
		}
		//no box was checked
		if (textString.length > 0) {
		  alert(textString)
		}
		return false;
	} else {
		if (theField.checked) {
			return true;
		} else {
			alert(textString)
			return false;
		}
	}
}

function utmarkt(langID){
	switch(langID){
		case 1:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=en&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
		case 2:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=sv&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
		case 3:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=de&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
		case 11:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=en&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
		case 12:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=sv&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
		case 13:
			MM_openBrWindow('http://upplevmittsverige.nu/broschyrer/index.cfm?Stylesheet=vasterbotten.css&Sprak=de&Kanal=34&organisation=35&avsandare=35&stegvis=0&sida=vasterbotten.net','Utmarkt','width=730,height=470,scrollbars=yes')
		break
	}
}

/*The themes popup on the start page*/
	function showThemesDiv(linkclicked)
	{
	  obj = document.getElementById('activitiesDiv');
	  MM_showHideLayers('activitiesDiv','','show');

    posx = findPosition(linkclicked)[0] + 12;
  	posy = findPosition(linkclicked)[1] + 5;
	
	  obj.style.left = posx + "px";
  	obj.style.top = posy + "px";
}
	
	
	function findPosition( oLink ) {
	if( oLink.offsetParent ) {
    for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
      posX += oLink.offsetLeft;
      
      posY += oLink.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oLink.x, oLink.y ];
  }
}

		
	function hideThemesDiv()
	{
		MM_showHideLayers('activitiesDiv', '', 'hide')
	}
	
	function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

