var objMyImg = null;

function init() {
	objMyImg = new OpacityObject('pagewrap','/images/dropshadow');
	objMyImg.setBackground();
	//window.setTimeout("showFlash(false)", 5000); 
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function showFlash(force)
{
	if(force || (get_cookie("kinaresa") + '' == ''))
	{
		document.cookie="kinaresa=true";
		MM_openBrWindow('kinaresa/flash.html','Flash','width=493,height=698');
	}
}

//Get cookie routine by Shelley Powers 
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function setHeight(elID) {
	el = document.getElementById(elID);
	var divTop = 90;
	var divMiddle = 160;
	var divClear = 2;
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			if (parseInt(document.getElementById("top").offsetHeight)>0) 
				divTop = document.getElementById("top").offsetHeight;
			if (parseInt(document.getElementById("mainmenu").offsetHeight)>0)
				divMiddle = document.getElementById("mainmenu").offsetHeight;			
					
			var totalHeight=divTop+divMiddle+divClear;
			var elHeight=el.offsetHeight;
			
			if (windowHeight-(totalHeight+elHeight)>=0) {
				el.style.height=windowHeight-totalHeight+'px';
			}
		}
	}
}

function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement&&document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight;
		}
		else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function replaceImage(el) {
	el.src = "/images/no_image.gif";
}

function badImage(el) {
	if (browser.isNS4x) {
		el.src = "/images/empty.gif";
	}
	else el.parentNode.removeChild(el);
}

function goodImage(el) {
	el.className = "border";
}

function submitform(el) {
	var searchform = document.getElementById("search_recipe");
	var sLocation;
	var sCountry;
	var sSearchType;
	var obj;

	if (el.id=="search_form_advanced") {
		obj = document.getElementById("type");
		sLocation = ",typ-" + obj.options[obj.selectedIndex].value;
		sLocation = sLocation + ",pro-" + document.getElementById("product").value;
		obj = document.getElementById("ingredient");
		sLocation = sLocation + ",ing-" + obj.options[obj.selectedIndex].value;
		obj = document.getElementById("fri_adv");
		sLocation = sLocation + ",fri-" + obj.value;
		sLocation = sLocation + ",";
		obj = document.getElementById("countrylist");
		sCountry = obj.options[obj.selectedIndex].value;
		sSearchType = "advanced";
	}
	else if (el.id=="search_form") {
		sLocation = ",typ-";
		sLocation = sLocation + ",pro-";
		sLocation = sLocation + ",ing-";
		sLocation = sLocation + ",fri-" + document.getElementById("fri").value;
		sLocation = sLocation + ",";
		sCountry = "0";
		sSearchType = "basic";
	}
	
	document.getElementById("oid").value = sLocation;
	document.getElementById("country").value = sCountry;
	document.getElementById("searchtype").value = sSearchType;
	searchform.action = "/default.asp?#searchres";
	searchform.submit();
	return false;
}

function getAnimal(year) {
	var toyear = 1997;
	var animalSID;
	var x = (toyear - year) % 12;
	
	if ((isNaN(year)) || (year == "")) {
		alert("Felaktigt årtal. Var vänlig skriv in ett årtal med endast siffror (t ex 1978)");
	}
	else {
	
		if ((x == 1) || (x == -11)) {
			// Rat
			animalSID="8770";
		}
		else if (x == 0) {
			// Ox
			animalSID="8771";
		}
		else if ((x == 11) || (x == -1)) {
			// Tiger
			animalSID="8772";
		}
		else if ((x == 10) || (x == -2)) {
			// Rabbit
			animalSID="8773";
		}
		else if ((x == 9) || (x == -3)) {
			// Dragon
			animalSID="8774";
		}
		else if ((x == 8) || (x == -4)) {
			// Snake
			animalSID="8775";
		}
		else if ((x == 7) || (x == -5)) {
			// Horse
			animalSID="8764";
		}
		else if ((x == 6) || (x == -6)) {
			// Sheep
			animalSID="8765";
		}
		else if ((x == 5) || (x == -7)) {
			// Monkey
			animalSID="8766";
		}
		else if ((x == 4) || (x == -8)) {
			// Rooster
			animalSID="8767";
		}
		else if ((x == 3) || (x == -9))  {
			// Dog
			animalSID="8768";
		}
		else if ((x == 2) || (x == -10)) {
			// Boar
			animalSID="8769";
		}
	
	location = "default.asp?sid=" + animalSID;
	//window.open('popup.asp?pet=' + pet,pet,'width=400,height=400,scrollbars=yes');
	}
}
