﻿<!--
function changeBokForm(radiobtn)
{
	theForm = document.getElementById("form_search");
	boktyp = radiobtn.value;
	
	theForm.search_type.length=0;

	/*alert("hej"+boktyp);*/
	if(boktyp == "tryckta")
	{
		theForm.search_type.options[0] = new Option('Titel','titel');
		theForm.search_type.options[1] = new Option('ISBN13','artnr');
		theForm.search_type.options[2] = new Option('ISBN10','isbn10');
		theForm.search_type.options[3] = new Option('Författare','forfattare');
	}
	if(boktyp == "inlasta")
	{
		theForm.search_type.options[0] = new Option('Titel','titel');
		theForm.search_type.options[1] = new Option('ISBN','isbn');
		theForm.search_type.options[2] = new Option('Författare','forfattare');
	}	
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function goSearch(theForm)
{
	boktyp = getCheckedValue(theForm.boktyp);
	
	if(boktyp == "tryckta")
	{
		goSearchTryckta(theForm);
	}
	else if(boktyp == "inlasta")
	{
		goSearchIlab(theForm);
	}
}

function goSearchTryckta(theForm)
{
	searchType=theForm.search_type.value;
	searchVal1=theForm.search_this.value;

	if((searchType == "titel" || searchType == "forfattare") && searchVal1 != '')
	{
		if(searchVal1.length < 3)
		{
			alert('Din sökning måste bestå av minst 3 tecken');
		}
		else
		{
			window.location = "search.php?"+searchType+"=" + searchVal1 + "&p=0";
		}
	}

	if( searchType == "isbn10"  && searchVal1 !='' )
	{
		if(searchVal1.length < 4)
		{
			alert('Din sökning måste bestå av minst 4 tecken');
		}
		else
		{	
			//window.location = "artikel.php?" + searchType + "=" + searchVal1;
			window.location = "search.php?" + searchType + "=" + searchVal1;
		}
	}	
	
	if( searchType == "artnr" && searchVal1 !='' )
	{
		if(searchVal1.length < 7)
		{
			alert('Din sökning måste bestå av minst 7 tecken');
		}
		else
		{	
			//window.location = "artikel.php?" + searchType + "=" + searchVal1;
			window.location = "search.php?" + searchType + "=" + searchVal1;
		}
	}		
}

function goSearchIlab(theForm)
{
	searchType=theForm.search_type.value;
	searchVal1=theForm.search_this.value;
	if(searchType == "isbn10")
		searchType = "isbn";

	if((searchType == "titel" || searchType == "isbn" || searchType == "forfattare") && searchVal1 != '')
	{
		if(searchVal1.length < 3)
		{
			alert('Din sökning måste bestå av minst 3 tecken');
		}
		else
		{
			window.location = "ilab_search.php?"+searchType + "=" + searchVal1;
		}
	}

	/*if( (searchType == "isbn10" || searchType == "artnr" ) && searchVal1 !='' )
	{
		//window.location = "artikel.php?" + searchType + "=" + searchVal1;
		window.location = "search.php?" + searchType + "=" + searchVal1;
	}*/	
}

/*
function goSearchLaromedel(theForm)
{
	searchType=theForm.search_type.value;
	searchVal1=theForm.search_this.value;

	if((searchType == "titel" || searchType == "forfattare") && searchVal1 != '')
	{
		if(searchVal1.length < 3)
		{
			alert('Din sökning måste bestå av minst 3 tecken');
		}
		else
		{
			window.location = "search_laromedel.php?"+searchType+"=" + searchVal1 + "&p=0";
		}
	}

	if( (searchType == "isbn10" || searchType == "artnr" ) && searchVal1 !='' )
	{
		//window.location = "artikel.php?" + searchType + "=" + searchVal1;
		window.location = "search_laromedel.php?" + searchType + "=" + searchVal1;
	}	
}
*/
 -->