/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Build: http://www.modernizr.com/download/#-borderradius-opacity-cssgradients-input-cssclasses-testprop-testallprops-prefixes-domprefixes
 */
;window.Modernizr=function(a,b,c){function C(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)r[a[b]]=a[b]in l;return r}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" "))}function B(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+o.join(c+" ")+c).split(" ");return A(d,b)}function A(a,b){for(var d in a)if(k[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function z(a,b){return!!~(""+a).indexOf(b)}function y(a,b){return typeof a===b}function x(a,b){return w(n.join(a+";")+(b||""))}function w(a){k.cssText=a}var d="2.0.6",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l=b.createElement("input"),m=Object.prototype.toString,n=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),o="Webkit Moz O ms Khtml".split(" "),p={},q={},r={},s=[],t,u={}.hasOwnProperty,v;!y(u,c)&&!y(u.call,c)?v=function(a,b){return u.call(a,b)}:v=function(a,b){return b in a&&y(a.constructor.prototype[b],c)},p.borderradius=function(){return B("borderRadius")},p.opacity=function(){x("opacity:.55");return/^0.55$/.test(k.opacity)},p.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";w((a+n.join(b+a)+n.join(c+a)).slice(0,-a.length));return z(k.backgroundImage,"gradient")};for(var D in p)v(p,D)&&(t=D.toLowerCase(),e[t]=p[D](),s.push((e[t]?"":"no-")+t));e.input||C(),w(""),j=l=null,e._version=d,e._prefixes=n,e._domPrefixes=o,e.testProp=function(a){return A([a])},e.testAllProps=B,g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+s.join(" "):"");return e}(this,this.document);;
// JavaScript Document
function setIos4Class(){
	if (navigator.userAgent.indexOf('iPhone OS 4') > -1 || navigator.userAgent.indexOf('iPhone OS 3') > -1) {
		var html = document.getElementsByTagName('html');
		if(html.length > 0){
			html[0].className = html[0].className + " ios4";
		}
	}
}
var calendarTooltipDefault;
function setCalendarTooltips(){
	var calendarBlock = document.getElementById('block-views-events-calendar-block-1');
	if(calendarBlock != undefined){
		var links = new Array();
		var links = calendarBlock.getElementsByTagName('a');
		for(var i = 0;i < links.length;i++){
			if(links[i].href.indexOf("events/") > -1){
				if(!isNaN(links[i].innerHTML)){
					links[i].setAttribute('onmouseover', 'setCalendarTooltip("' + links[i].innerHTML + '")');
					links[i].setAttribute('onmouseout', 'resetCalendarTooltipTimed()');
				}
			}
		}
		var pTags = calendarBlock.getElementsByTagName('p');
		if(pTags.length > 0){
			calendarTooltipDefault = pTags[0];
		}
	}
}
var calendarTooltipTimeout; 
function clearCalenderTimeout(){
	clearTimeout(calendarTooltipTimeout);
}
function setCalendarTooltip(date){
	clearTimeout(calendarTooltipTimeout);
	var calendarBlock = document.getElementById('block-views-events-calendar-block-1');
	if(calendarBlock != undefined){
	    var listItems = calendarBlock.getElementsByTagName('li');
		for(var i = 0;i < listItems.length;i++){
			if(listItems[i].className.indexOf('day-' + date + ' ') > -1){
				listItems[i].className = listItems[i].className.replace(' element-hidden', '');
				listItems[i].setAttribute('onmouseover', 'clearCalenderTimeout()');
				if(calendarTooltipDefault != undefined){
					calendarTooltipDefault.className = calendarTooltipDefault.className + " element-hidden";
				}
			}
		}
	}
}
function resetCalendarTooltipTimed(){
	calendarTooltipTimeout = setTimeout('resetCalendarTooltip()', 1800);
}
function resetCalendarTooltip(){
	var calendarBlock = document.getElementById('block-views-events-calendar-block-1');
	if(calendarBlock != undefined){
	    var listItems = calendarBlock.getElementsByTagName('li');
		for(var i = 0;i < listItems.length;i++){
			if(listItems[i].className.indexOf(' element-hidden') == -1){
				listItems[i].className = listItems[i].className + " element-hidden";
			}
		}
	}
	if(calendarTooltipDefault != undefined){
		calendarTooltipDefault.className = calendarTooltipDefault.className.replace(' element-hidden', '');
	}
}
function openNewsLetterPopup() {
	var email = document.getElementById('newsletter-email');
	if(email != undefined){
		if(email.value.length > 0){
			window.open('http://www.forestry.se/NewsMail/v1/create.snm?email=' + email.value, 'Villkor', 'status = 0, height = 360, width = 440, resizable = 0');
		}
	}
}
function postToPopup(form, action){
	window.open('', 'formpopup', 'width=800,height=600,resizeable,scrollbars');
    form.target = 'formpopup';	
}
function html5fallback(){
	if(!Modernizr.input.placeholder){
		var loginForm = document.getElementById('user-login-form');
		var inputs = new Array();
		if(loginForm != undefined){
			inputs = loginForm.getElementsByTagName('input');
		}
		inputs[inputs.length] = document.getElementById('newsletter-email');
		inputs[inputs.length] = document.getElementById('edit-ctl00contentregionmainregionskogsencyklopedinbrowser1searchquery');
		inputs[inputs.length] = document.getElementById('edit-search-block-form--2');
		for(var i = 0;i < inputs.length;i++){
			if(inputs[i] != undefined){
				var placeholder = inputs[i].getAttribute("placeholder");
				if(placeholder != undefined){
					if(placeholder.length > 0){
						setFakePlaceholder(inputs[i].id, placeholder);
						inputs[i].setAttribute('onfocus', 'clearFakePlaceholder("' + inputs[i].id + '", "' + placeholder + '");');
						inputs[i].setAttribute('onblur', 'setFakePlaceholder("' + inputs[i].id + '", "' + placeholder + '");');
					}
				}
			}
		}		
	}
}
function clearFakePlaceholder(inputId, placeholder){
	var input = document.getElementById(inputId);
	if(input.value == placeholder){
		input.value = '';	
	}
}
function setFakePlaceholder(inputId, placeholder){
	var input = document.getElementById(inputId);
	if(input.value == '' || input.value == undefined){
		input.value = placeholder;
	}
}
var cookie_key = 'hide_hl';
function setHighlighted(){
	var highlighted = document.getElementById('highlighted');
	if(highlighted != undefined){
		var c_name = cookie_key;
		if(getCookie(c_name) == '1') {
			displayHighlighted(false);
		}else{
			displayHighlighted(true);	
		}
	}
}
function setHideHighlighted(){
	c_name = cookie_key;
	setCookie(c_name, '1');
	displayHighlighted(false);
}
function setShowHighlighted(){
	c_name = cookie_key;
	setCookie(c_name, '0');
	displayHighlighted(true);
}
function displayHighlighted(show){
	var display = 'block';
	var highlighted = document.getElementById('highlighted');
	if(!show){
		display = 'none';
		if(highlighted != undefined){
			var h1 = highlighted.getElementsByTagName('h1');
			if(h1.length == 1){
				h1[0].setAttribute('onclick', 'setShowHighlighted()'); 
				highlighted.className = highlighted.className + " hidden";
			}
		}
	}else{
		highlighted.className = highlighted.className.replace(' hidden', '');
	}
	var boxes = highlighted.getElementsByTagName('div');
	for(var i = 0; i < boxes.length; i++){
		if(boxes[i].className == 'boxes-box'){
			boxes[i].style.display = display;
		}
	}
	var closeLink = document.getElementById('highlight-close');
	if(closeLink != undefined){
		closeLink.style.display = display;	
	}
} 
function setRegisterPrice(checkbox, price, totalId){
	if(!checkbox.checked){
		price = 0 - price;	
	}
	var totalContainer = document.getElementById(totalId);
	if(totalContainer != undefined){
		var oldPrice = parseInt(totalContainer.innerHTML);
		var newPrice = oldPrice + price;
		totalContainer.innerHTML = newPrice;
		if(newPrice > 0){
			var addressForm = document.getElementById('user_user_form_group_address');
			if(addressForm != undefined){
				addressForm.style.display = "block";	
			}
		}
	}
}
function setFaqListEvents(){
	var h2tags = document.getElementById('main-content').getElementsByTagName('h2');
	for(var i = 0;i<h2tags.length;i++){
		var spans = h2tags[i].getElementsByTagName('span');
		if(spans.length == 1){
			var nid = spans[0].id.replace('faq-question-', '');
//			h2tags[i].setAttribute('onclick', 'displayFaqListAnswer(' + "'"  + spans[0].id + "', '" + nid + "')"); 
//			h2tags[i].onclick = function() { displayFaqListAnswer(spans[0].id, nid); };
			h2tags[i].onclick = new Function("displayFaqListAnswer('" + spans[0].id + "', '" + nid + "')");
		}
	}
}
function displayFaqListAnswer(spanId, nid){
	var answer = document.getElementById('faq-answer-' + nid);
	var span = document.getElementById(spanId);
	if(answer != undefined && span != undefined){
		if(answer.style.display == "block"){
			answer.style.display = "none";
			span.className = '';
		}else{
			answer.style.display = "block";
			span.className = 'active';
		}
	}
}
var popupStatus = 0;  
function displayShareEmail(){
	loadPopup();
}
function loadPopup(){  
if(popupStatus==0){  
document.getElementById("popupContact").style.display = "block";
popupStatus = 1;  
}  
}
function disablePopup(){  
if(popupStatus==1){  
document.getElementById("popupContact").style.display = "none";
popupStatus = 0;  
}  
}
function setCookie(c_name,value)
{
var exdays = 365;
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
function apsis_check_category(checkbox, hidden_id){
	var hidden = document.getElementById(hidden_id);
	if(checkbox.checked){
		hidden.value = '1';	
	}else{
		hidden.value = '';	
	}
}
function apsis_check_all(checkbox){
	var categories_box = document.getElementById('apsis-sub-option');
	if(categories_box != undefined){
		var inputs = categories_box.getElementsByTagName('input');
		for(var i = 0;i < inputs.length;i++){
			if(checkbox.checked){
				if(inputs[i].type == 'checkbox'){
					inputs[i].checked = true;
				}else{
					inputs[i].value= '1';
				}
			}else{
				if(inputs[i].type == 'checkbox'){
					inputs[i].checked = false;
				}else{
					inputs[i].value= '';
				}
			}
		}
	}
}
function apsis_validate(){
	var categories_box = document.getElementById('apsis-sub-option');
	if(categories_box != undefined){
		var checkboxes = categories_box.getElementsByTagName('input');
		for(var i = 0;i < checkboxes.length;i++){
			if(checkboxes[i].checked){
				var hidden = document.getElementById(checkboxes[i].id.replace('_checkbox', ''));
				hidden.value = '1';
				alert(1);	
			}
		}
		
	}
	document.getElementById('apsis-form').submit();
}
;

