var cookieid = 'cid85763639';
var cookie_domain = '';
var cookie_path ='';

function my_hide_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}

//==========================================
// Set DIV ID to show
//==========================================

function my_show_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "";
}

//==========================================
// Get cookie
//==========================================

function my_getcookie( name )
{
	cname = cookieid + name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

//==========================================
// Set cookie
//==========================================

function my_setcookie( name, value, sticky )
{
	expire = "";
	domain = "";
	path   = "/";
	
	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}
	
	if ( cookie_domain != "" )
	{
		domain = '; domain=' + cookie_domain;
	}
	
	if ( cookie_path != "" )
	{
		path = cookie_path;
	}
	
	document.cookie = cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';
}
//==========================================
// Get element by id
//==========================================

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}

function dofavorite( fid, add )
{
	saved = new Array();
	clean = new Array();

	//-----------------------------------
	// Get any saved info
	//-----------------------------------

	if ( tmp = my_getcookie('a') )
	{
		saved = tmp.split(",");
	}
	
	//-----------------------------------
	// Remove bit if exists
	//-----------------------------------
	
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != fid && saved[i] != "" )
		{
			clean[clean.length] = saved[i];
		}
	}
	
	//-----------------------------------
	// Add?
	//-----------------------------------
	
	if ( add )
	{
		clean[ clean.length ] = fid;
		my_show_div( my_getbyid( 'fc_'+fid  ) );
		my_hide_div( my_getbyid( 'fo_'+fid  ) );
		my_getbyid('id232').innerHTML = saved.length + 1;
	}
	else
	{
		my_show_div( my_getbyid( 'fo_'+fid  ) );
		my_hide_div( my_getbyid( 'fc_'+fid  ) );
		my_getbyid('id232').innerHTML = saved.length - 1;
	}
	
	my_setcookie( 'a', clean.join(','), 1 );


}


function abc(which,active,id){
	var tmp1 = document.getElementById('id5926');
	var tmp2 = document.getElementById('id5927');
	if(which){
		if(which==1){
			tmp1.className = 'div2';
			tmp2.className = 'div3';
			reset_bg('id'+active);			
			item_info(id);
		}else{
			tmp1.className = 'div0';
			tmp2.className = 'div3';
		}
	}else{
		if(tmp1.className == 'div2'){
			tmp1.className = 'div4';
			tmp2.className = 'div5';			
		}else{
			tmp1.className = 'div0';
			tmp2.className = 'div3';
		}
	}
}
	
function reset_bg(active){
	var elmts=document.getElementById('id5926').getElementsByTagName('nobr');
	for(var i=0;i<elmts.length;i++){
	//	alert(elmts[i].innerHTML);
		elmts[i].style.background='#FFFFCC';
	}
	elmts[active].style.background='#FFCC00';
}



function processIF(){
	var myajax=ajaxpack.ajaxobj
	var myfiletype=ajaxpack.filetype
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200 || window.location.href.indexOf('http')==-1){ //if request was successful or running script locally
			if (myfiletype=='txt'){
				document.getElementById('id5927').innerHTML=myajax.responseText;
			}else
				alert(myajax.responseXML)
		}
	}
}

function checkforexistent( vid,div )
{
	saved = new Array();
	var found=0;
	var string = '';
	if ( tmp = my_getcookie('a') )
	{
		saved = tmp.split(",");
	}
	
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] == vid && saved[i] != "" )
		{
			found = 1;
		}
	}
	if(found){
        string  = "<A href=\"javascript:dofavorite('" + vid + "',1);\" id=fo_" + vid + " style='DISPLAY: none;'><IMG src='images/exp_plus.gif' border='0' align='absbottom'>Favorite</A>";
        string += "<A href=\"javascript:dofavorite('" + vid + "',0);\" id=fc_" + vid + "><IMG src='images/exp_minus.gif' border='0' align='absbottom'><b>Favorite</b></A>";
	}else{
        string  = "<A href=\"javascript:dofavorite('" + vid + "',0);\" id=fc_" + vid + " style='DISPLAY: none;'><IMG src='images/exp_minus.gif' border='0' align='absbottom'>Favorite</A>";
        string += "<A href=\"javascript:dofavorite('" + vid + "',1);\" id=fo_" + vid + "><IMG src='images/exp_plus.gif' border='0' align='absbottom'><b>Favorite</b></A>";
	}
	document.getElementById(div).innerHTML = string;
}

//rotating thumb functions
var changing_thumbs = new Array();
function changeThumb(index, i, num_thumbs, path, cache_control)
{
    if (changing_thumbs[index])
    {
        hidden_image_id = (i + 1) % num_thumbs;
        document.getElementById(index).src = path + i + ".jpg?cache_control=" + cache_control;
        
        i = i % num_thumbs;
        i++;
        setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + path + "', " + cache_control + ")", 600);
    }
}    
function startThumbChange(index, num_thumbs, path, cache_control)
{    
    changing_thumbs[index] = true;
    
    changeThumb(index, 2, num_thumbs, path, cache_control);
}
function endThumbChange(index, path, cache_control)
{
    changing_thumbs[index] = false;
    document.getElementById(index).src = path + "?cache_control=" + cache_control;
}


function checkSbox(){
    if ((document.main_search.keyword.value.length < 3) || (document.main_search.keyword.value.length > 10)){
        mesg = "You have entered " + document.main_search.keyword.value.length + " character(s)\n"
        mesg = mesg + "Valid entries are between 3 and 10 characters.\n"
        mesg = mesg + "Please verify your input and submit again."
        alert(mesg);

        document.main_search.keyword.focus();
        return (false);
    }
    return (true);
}