/* Global variables */

var d = document;

/* Search class */

var niForm = {
	action : '',
	href : '',
	name : '',
	html : ''
}

/* Search class end */

/* Search function */

function niSrch(o){ 
hide('eventshow');
SetCookie('picsearch',1,0,'/', 'netinfo.bg','');

var html = '', _t = o.id.substring(0,3), _x = 1;

	while($(_t + _x)){
		$(_t + _x).className = (_t + _x == o.id)? 'sel' : '';
		_x++;
	}
	
	switch(o.id.substring(3)){
		case '2':
			niForm.action = 'http://search.gbg.bg/rdr_g.phtml';
			niForm.name = 'q';
			niForm.html = '<input type="hidden" name="s" value="33"><input type="hidden" name="lr" value="">'
			+ '<img src="h/google.gif" alt="" />';
			niForm.href = 'http://search.gbg.bg/google/nisearch.php';
		break;
		case '3':
			niForm.action = 'http://search.netinfo.bg/picsearchni/search.php';
			niForm.name = 'q';
			niForm.html = '<input type="hidden" name="s" value="6"><input type="hidden" name="r" value="1" />'
			+ '<br />';
			niForm.href = 'http://search.netinfo.bg/picsearchni/search.php?s=6';
		break;
		case '5':
			niForm.action = 'http://search.netinfo.bg/picsearchni/search.php';
			niForm.name = 'q';
			niForm.html = '<input type="hidden" name="s" value="7"><input type="hidden" name="r" value="1" />'
			+ '<br />';
			niForm.href = 'http://search.netinfo.bg/picsearchni/search.php?s=7';
		break;
		case '4':
			niForm.action = 'http://search.netinfo.bg/picsearchni/search.php';
			niForm.name = 'q';
			niForm.html = '<input type="hidden" name="s" value="8"><input type="hidden" name="r" value="1" />'
			+ '<br />';
			niForm.href = 'http://search.netinfo.bg/picsearchni/search.php?s=8';
		break;
		default:
			niForm.action = 'http://search.netinfo.bg/search.phtml';
			niForm.name = 'aStr';
			niForm.html = '<br />';
			niForm.href = 'http://search.netinfo.bg/search.phtml';
		break;
	}
	
	_($('search'), 'form').action = niForm.action;
	_($('search'), 'input').name = niForm.name;
	_(_($('search'), 'span'), 'span').innerHTML = niForm.html;
	_(_($('search'), 'span'), 'a').href = niForm.href;
	_($('search'), 'input').focus();
	
}

/* Search function end */

/* DOM functions */

function $(id, f){
	return eval('d.getElementById(id)' + (f? '.style' : ''));
}

function _(o, _e, id, f){
	return eval('o.getElementsByTagName(_e)[' + (id? id : 0) + ']' + (f? '.style' : ''));
}

/* DOM functions end */


function hide(id) {
	if($(id))
  $(id).style.display = "none";
}


function SetCookie(name,value,expires,path,domain,secure){
  var today=new Date();
  today.setTime(today.getTime());
  if(expires) expires=expires*1000*60*60*24;  
  var expires_date = new Date(today.getTime()+(expires));
  //document.cookie=name+"="+escape(value)+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"");
  document.cookie=name+"="+escape(value)+((expires)?";expires="+expires_date.toGMTString():"")+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"");
}

function checkCoockie(domain){
  if (document.cookie.length) return 0;
  else return 1;
}

function GetCookie(name) {
var start=document.cookie.indexOf(name+"=");
var len=start+name.length+1;
if((!start)&&(name!=document.cookie.substring(0,name.length))) return null;
if(start==-1) return null;
var end=document.cookie.indexOf(";",len);
if(end==-1) end=document.cookie.length;
return unescape(document.cookie.substring(len,end));
}

