// COOKIES
function SetCookie (name,value,path,domain,secure,expires) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
	(( path ) ? ";path=" + path : "" ) + 
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookie(name) {        
	var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1) return "";
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function deleteCookie( name ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
/////////////////////////////////////

// SEARCH
function togGroup(el, classes){
	for (var els=document.getElementsByTagName(el.tagName), i = els.length-1; i > -1; --i)
	if (els[i]!==el&&els[i].className==classes.b)
	els[i].className=classes.a;
	el.className=el.className==classes.a? classes.b : classes.a;
}

function ActionDeterminator(toWhere)
{
	var dv = toWhere;
	
	//Delete_Cookie('FMSearch_path');

	if(dv==1) {
		document.srch.action = '/search_res.php?s=news';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 1, '/');
	}
	if(dv==2) {
		document.srch.action = 'http://shop.fishing-mania.com/search_res.php';
		document.srch.target = '_blank';
		//SetCookie ("FMSearch_path", 2, '/');
	}
	if(dv==3) {
		document.srch.action = '/search_res.php?s=ads';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 3, '/');
	}
	if(dv==4) {
		document.srch.action = '/search_res.php?s=rec';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 4, '/');
	}
	if(dv==5) {
		document.srch.action = '/search_res.php?s=shared';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 5, '/');
	}
	if(dv==6) {
		document.srch.action = '/search_res.php?s=meet';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 6, '/');
	}
	if(dv==7) {
		document.srch.action = 'http://forum.fishing-mania.com/search.php?mode=results';
		document.srch.target = '_blank';
		//SetCookie ("FMSearch_path", 7, '/');
	}
	if(dv==8) {
		document.srch.action = '/search_res.php?s=act';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 8, '/');
	}
	if(dv==9) {
		document.srch.action = '/catalog/search_res.php?s=cat';
		document.srch.target = '_self';
		//SetCookie ("FMSearch_path", 9, '/');
	}
	
	return dv;
}

/////////////////////////////////////////

// AFTER SEARCH
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
 
return vars;
}

function afsearch()
{
	var hash = getUrlVars();
	
	dv = hash['s'];
	
	if(dv=='news') {
		document.srch.action = '/search_res.php?s=news';
		document.srch.target = '_self';
		document.getElementById("t_1").setAttribute("class", "s_act");
	}
	if(dv==2) {
		document.srch.action = 'http://shop.fishing-mania.com/search_res.php';
		document.srch.target = '_blank';
		document.getElementById("t_2").setAttribute("class", "s_act");
	}
	if(dv=='ads') {
		document.srch.action = '/search_res.php?s=ads';
		document.srch.target = '_self';
		document.getElementById("t_3").setAttribute("class", "s_act");
	}
	if(dv=='rec') {
		document.srch.action = '/search_res.php?s=rec';
		document.srch.target = '_self';
		document.getElementById("t_4").setAttribute("class", "s_act");
	}
	if(dv=='shared') {
		document.srch.action = '/search_res.php?s=shared';
		document.srch.target = '_self';
		document.getElementById("t_5").setAttribute("class", "s_act");
	}
	if(dv=='meet') {
		document.srch.action = '/search_res.php?s=meet';
		document.srch.target = '_self';
		document.getElementById("t_6").setAttribute("class", "s_act");
	}
	if(dv==7) {
		document.srch.action = 'http://forum.fishing-mania.com/search.php?mode=results';
		document.srch.target = '_blank';
		document.getElementById("t_7").setAttribute("class", "s_act");
	}
	if(dv=='act') {
		document.srch.action = '/search_res.php?s=act';
		document.srch.target = '_self';
		document.getElementById("t_8").setAttribute("class", "s_act");
	}
	if(dv=='cat') {
		document.srch.action = '/catalog/search_res.php?s=cat';
		document.srch.target = '_self';
		document.getElementById("t_9").setAttribute("class", "s_act");
	}
}
/////////////////////////////////////////
