﻿function ExpandAnsweredQuestions(theDiv)
{
	var inputCollection = document.getElementsByTagName("INPUT");
	
	if(inputCollection.length > 0)
	{
		for(var i=0; i<inputCollection.length; i++)
		{
			var child1 = inputCollection[i];
			if(child1.tagName != null && child1.id.indexOf("radio_") != -1)
			{
				if(child1.checked == true)
				{
					child1.click();
				}
			}
		}
	}
}

function CreateBookmark(pageID)
{
	var checkedColl = new String();
	var inputCollection = document.getElementsByTagName("INPUT");
	
	if(inputCollection.length > 0)
	{
		for(var i=0; i < inputCollection.length; i++)
		{
			if(inputCollection[i].checked == true)
			{
				checkedColl += inputCollection[i].id + ";";
			}
		}
	}
	
	//alert(inputCollection.length + "\n" + checkedColl);
		
	if(checkedColl != "" && IsValid())
	{
		checkedColl = checkedColl.substring(0, checkedColl.length -1 );
		
		var title = "Min arbetsplatsguide";
		var url = window.location.protocol + "//" + window.location.host + window.location.pathname + "?PageID=" + pageID + "&Selected=" + checkedColl;
		
		// Show the expanded search or not
		if(searchExpanded == true){url += "&Expanded=true";}
		
		if (window.sidebar)
		{ // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		}
		else if( window.external )
		{ // IE Favorite
			window.external.AddFavorite( url, title);
		}
		else if(window.opera && window.print)
		{ // Opera Hotlist
			return true;
		}
	}
	else
	{
		alert("Alla frågor ej besvarade.");
		pageIsValid = true;
	}
} 

function OpenPrintableVersion(pageID)
{
	var checkedColl = new String();
	var inputCollection = document.getElementsByTagName("INPUT");
	
	if(inputCollection.length > 0)
	{
		for(var i=0; i < inputCollection.length; i++)
		{
			if(inputCollection[i].checked == true)
			{
				checkedColl += inputCollection[i].id + ";";
			}
		}
	}
	
	//alert(inputCollection.length + "\n" + checkedColl);
		
	if(checkedColl != "" && IsValid())
	{
		checkedColl = checkedColl.substring(0, checkedColl.length -1 );
		
		var title = "Uppslagsverket sökning";
		var url = window.location.protocol + "//" + window.location.host + window.location.pathname + "?PageID=" + pageID + "&UsePrintableVersion=true&Selected=" + checkedColl;	
		// Show the expanded search or not
		if(searchExpanded == true){url += "&Expanded=true";}
		
		window.open(url, 'printableVersion','')
	}
	else
	{
		alert("Alla frågor ej besvarade.");
		pageIsValid = true;
	}
}
