﻿/* BFB: 24-01-12: script to change links to recipes in school news items 
script call is placed on 'nyheder' (news) pages of the two mobile sites*/
function changeRecipeLinks(){
var links = document.getElementsByTagName('a');
  for(var i = 0; i < links.length; i++) {
    if (links[i].href.indexOf('/opskrifter')>-1){
	links[i].onclick='return;';
	links[i].href='http://www.tme-elnet.dk/opskriftermobil';
	links[i].target='_blank';
	   /*if (links[i].innerHTML.indexOf('Flere')>-1){
		links[i].style.display='none';
			console.log(links[i].style.display);
	    }*/
/*
console.log(links[i].href);
console.log(links[i].onclick);
console.log(links[i].innerHTML);
*/

  }
}
}



function GetFilterValues()
{
  var selects = document.getElementsByTagName("SELECT");
  var address_path = "";
  var address = "";
  var city = "";
  var validation = 0;
  var v = "";
  var p = "";
  var cityId = "";
  var municipalityId = "";

  for(var i = 0; i < selects.length; i++)
  {
     v = selects[i].options[selects[i].selectedIndex].innerHTML;
     p = selects[i].options[selects[i].selectedIndex].text;
     if(selects[i].value != "0")
     {
	   validation = i;
		address_path += " > " + p;
	   
	   if(i == selects.length-1)
	   {
		 address = v;
	   }
	  if(i == 1)
	  {
	   	city = p; 
	  }
     }
  }

  if(validation < 2)
  {
	window.alert("Alle felter skal udfyldes");
   }
   else
   {
	    if (true || location.href.indexOf ("testform")!=-1)
	    {
		var frm=document.getElementById("err_report");
			var wrapper = document.getElementById("SelectFilters");
				    var dropDowns = wrapper.getElementsByTagName("select");
			var streetDropDown = dropDowns[2];
			var streetId = streetDropDown.options[streetDropDown.selectedIndex].value;
			//var streetId = document.rediger1083.filtercontrol10831_3.options [document.rediger1083.filtercontrol10831_3.options.selectedIndex].value;
			
			var pageId = "1367";
			if(document.location.href.indexOf("1678")>-1)
			  pageId = "1679";
			  if(document.location.href.indexOf("1743")>-1)
			  pageId = "1757";

		frm.action="/page" + pageId + ".aspx?vejid="+ streetId;

			var cityDropDown = dropDowns[1];
			var municipalityDropDown = dropDowns[0];
			cityId = cityDropDown.options[cityDropDown.selectedIndex].value;
			municipalityId = municipalityDropDown.options[municipalityDropDown.selectedIndex].value;
	    }

	document.getElementById("address_path").value = address_path;
	document.getElementById("address").value = address;
	document.getElementById("city").value = city;
	document.getElementById("city_id").value = cityId;
	document.getElementById("municipality_id").value = municipalityId;
	document.getElementById("err_report").submit();

   }
}
