function setimgcolor(thisimage)
{
	thisimage.src = thisimage.src.replace("&fltr[]=gray","");
}

function setimggray(thisimage)
{
	thisimage.src = thisimage.src + "&fltr[]=gray";
}	

var lastZoomID="";

function SetOnLoad(c,n)
{
	
	getElementById('zoomfoto'+n).onload=zoom(c,n);
	
}	


function zoom(c,n)
{
	screenw = window.screen.width;
	screenh = window.screen.height;
	
	if (c=="in")
	{
		with (document)
		{
	
			zoomwidth = getElementById('zoomfoto'+n).width;
			zoomheight = getElementById('zoomfoto'+n).height+30;
			
			getElementById('zoom'+n).style.width=zoomwidth+"px";
			getElementById('zoom'+n).style.height=zoomheight+"px";
			
			
			x= (screenw - zoomwidth)/2
			y = (screenh - zoomheight-200)/2
			
			getElementById('zoom'+n).style.top = y+"px";
			getElementById('zoom'+n).style.left = x+"px";
			
			getElementById('zoom'+n).style.visibility = "visible";
			
			//setTimeout('effect_show_finish(\''+ 'zoom'+n +'\')', 1000);
			
			if(lastZoomID!="" && lastZoomID!=n)
			getElementById('zoom'+lastZoomID).style.visibility = "hidden";
			
			lastZoomID=n;
			
			
		}
	} else {
		with (document)
		{
			getElementById('zoom'+n).style.visibility = "hidden";
			//getElementById('foto'+n).style.visibility = "visible";
		}
	}
}

function QuickSubmitSearch()
{
	if(document.qsearchform.qsearch.value!="")
	document.qsearchform.submit();
}

function QuickSearch(searchurl)
{
	document.location.href = searchurl + document.getElementById("qsearch").value;
}	

function GetCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function SetCookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


//MENU SCRIPTS

function showdiv(div_id,p_div_id)
{
	var menudiv = document.getElementsByTagName("div"); 
	
	SetCookie( 'menuid',p_div_id, '', '/', '', '' );
	
	if(document.getElementById(div_id))
	{
		parentdiv = p_div_id;
		for (var i = 0; i < menudiv.length; i++) { 
		      if ( menudiv[i].className == "menudiv") {
		     	{
		     		if(menudiv[i].id==div_id)	 
		      		menudiv[i].style.display = "block";
		     	else
		   	  	menudiv[i].style.display = "none";	     
		   	  }
		    }
		}
	}
}

function startdiv(div_id,p_div_id)
{
	
		SetCookie( 'menuid', div_id, '', '/', '', '' );
		
		var menudiv = document.getElementsByTagName("div");
		for (var i = 0; i < menudiv.length; i++) { 
		      if ( menudiv[i].className == "menudiv") {
		     	{
		     		if(menudiv[i].id==div_id)	 
		      		menudiv[i].style.display = "block";
		     	else
		   	  	menudiv[i].style.display = "none";	     
		   	  }
		    }
		}
	
}	




function showdiv2(div_id,p_div_id)
{
	var menudiv = document.getElementsByTagName("div"); 
	
	SetCookie( 'menuid2',p_div_id, '', '/', '', '' );
	
	if(document.getElementById(div_id))
	{
		parentdiv = p_div_id;
		for (var i = 0; i < menudiv.length; i++) { 
		      if ( menudiv[i].className == "menudiv2") {
		     	{
		     		if(menudiv[i].id==div_id)	 
		      		menudiv[i].style.display = "block";
		     	else
		   	  	menudiv[i].style.display = "none";	     
		   	  }
		    }
		}
	}
}

function startdiv2(div_id,p_div_id)
{
	
		SetCookie( 'menuid2', div_id, '', '/', '', '' );
		
		var menudiv = document.getElementsByTagName("div");
		for (var i = 0; i < menudiv.length; i++) { 
		      if ( menudiv[i].className == "menudiv2") {
		     	{
		     		if(menudiv[i].id==div_id)	 
		      		menudiv[i].style.display = "block";
		     	else
		   	  	menudiv[i].style.display = "none";	     
		   	  }
		    }
		}
	
}	

function showparentdiv()
{
	 if(parentdiv!="")
	 showdiv(parentdiv);
}	


function effect_showdiv(div_id,p_div_id)
{
	
	if(document.getElementById(div_id))
	{
		SetCookie( 'menuid',div_id, '', '/', '', '' );
		
		//addDiv(div_id,p_div_id);
	
		new Effect.Fade(document.getElementById(last_div_id));
		last_div_id = div_id;
		setTimeout('effect_show_finish(\''+ div_id +'\')', 1000);
		//new Effect.Appear(document.getElementById(div_id));
	}
}

function effect_showdiv2(div_id,p_div_id)
{
	
	if(document.getElementById(div_id))
	{
		SetCookie( 'menuid2',div_id, '', '/', '', '' );
		
		//addDiv(div_id,p_div_id);
	
		new Effect.Fade(document.getElementById(last_div_id));
		last_div_id = div_id;
		setTimeout('effect_show_finish(\''+ div_id +'\')', 1000);
		//new Effect.Appear(document.getElementById(div_id));
	}
}

function effect_show_finish(div_id)
{
	new Effect.Appear(document.getElementById(div_id));
}

function effect_showparentdiv(child_id)
{
	 if(findDiv(child_id)!="")
	 effect_showdiv(findDiv(child_id));
}

function effect_showparentdiv2(child_id)
{
	 if(findDiv2(child_id)!="")
	 effect_showdiv2(findDiv2(child_id));
}


function findDiv(childdiv)
{
	for(var i=0; i<=counter; i++)
	{
		if(childDivArray[i]==childdiv)
		return parentDivArray[i];
	}	
	
	return "";	
}	

function findDiv2(childdiv)
{
	for(var i=0; i<=counter2; i++)
	{
		if(childDivArray2[i]==childdiv)
		return parentDivArray2[i];
	}	
	
	return "";	
}

function addDiv(childdiv,parentdiv)
{
	childDivArray[counter]=childdiv;	
	parentDivArray[counter]=parentdiv;
	counter++;
}	

function addDiv2(childdiv,parentdiv)
{
	childDivArray2[counter2]=childdiv;	
	parentDivArray2[counter2]=parentdiv;
	counter2++;
}	



function HighlightMenulink(thisurl)
{
	
	var menulinks = document.getElementsByTagName("a"); 
	
	for (var i = 0; i < menulinks.length; i++) { 
	      if ( menulinks[i].className == "menulink") {
	     	
	     		//if(menulinks[i].href.indexOf(thisurl)==0)
	     		if(menulinks[i].href==thisurl)
	      		{
	      			menulinks[i].className = "menulink_selected";
	      			SetCookie( 'menulink',thisurl, '', '/', '', '' );
	      			return true;
	      		}
	     	  
	   	  }
	    }
	
}

function HighlightMenulink2(thisurl)
{
	
	var menulinks = document.getElementsByTagName("a"); 
	
	for (var i = 0; i < menulinks.length; i++) { 
	      if ( menulinks[i].className == "menulink2") {
	     	
	     		//if(menulinks[i].href.indexOf(thisurl)==0)
	     		if(menulinks[i].href==thisurl)
	      		{
	      			menulinks[i].className = "menulink_selected2";
	      			SetCookie( 'menulink',thisurl, '', '/', '', '' );
	      			return true;
	      		}
	     	  
	   	  }
	    }
	
}

function GoToPage(page)
{
	document.searchnavigation.Page.value=page;
	document.searchnavigation.submit();
}	


function popup_window(url,w,h)
{
	seth= h;
	setw= w;
		
	screenw = window.screen.width;
	screenh = window.screen.height;
		
	x = (screenw - setw)/2
	y = (screenh - seth)/2
		
	if((screenw-100)<setw)
	setw = screenw-100;

	if((screenh-100)<seth)
	seth = screenh-100;

	thewin = window.open(url,'popwindow','left=' + x + ',top=' + y + ',toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=' + setw +',height=' + seth);
	thewin.focus();
}


var slideTimeBetweenSteps = 40;	// General speed variable (Lower = slower)
	
var scrollingContainer = false;
var scrollingContent = false;
var containerHeight;
var contentHeight;	

var contentObjects = new Array();
var originalslideSpeed = false;
function slideContent(containerId)
{
	var topPos = contentObjects[containerId]['objRef'].style.top.replace(/[^\-0-9]/g,'');
	topPos = topPos - contentObjects[containerId]['slideSpeed'];
	if(topPos/1 + contentObjects[containerId]['contentHeight']/1<0)topPos = contentObjects[containerId]['containerHeight'];
	contentObjects[containerId]['objRef'].style.top = topPos + 'px';
	setTimeout('slideContent("' + containerId + '")',slideTimeBetweenSteps);
	
}

function stopSliding()
{
	var containerId = this.id;
	contentObjects[containerId]['slideSpeed'] = 0;	
}

function restartSliding()
{
	var containerId = this.id;
	contentObjects[containerId]['slideSpeed'] = contentObjects[containerId]['originalSpeed'];
	
}
function initSlidingContent(containerId,slideSpeed)
{
	scrollingContainer = document.getElementById(containerId);
	scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];
	
	scrollingContainer.style.position = 'relative';
	scrollingContainer.style.overflow = 'hidden';
	scrollingContent.style.position = 'relative';
	
	scrollingContainer.onmouseover = stopSliding;
	scrollingContainer.onmouseout = restartSliding;
	
	originalslideSpeed = slideSpeed;
	
	scrollingContent.style.top = '0px';
	
	contentObjects[containerId] = new Array();
	contentObjects[containerId]['objRef'] = scrollingContent;
	contentObjects[containerId]['contentHeight'] = scrollingContent.offsetHeight;
	contentObjects[containerId]['containerHeight'] = scrollingContainer.clientHeight;
	contentObjects[containerId]['slideSpeed'] = slideSpeed;
	contentObjects[containerId]['originalSpeed'] = slideSpeed;
	
	slideContent(containerId);
	
}
	
