// JavaScript Document
	$(function() {
		$('#imggallery a').lightBox({fixedNavigation:true}); 
	});
	
	function showhide(elem){
		dsp = document.getElementById(elem).style;
		if (dsp.display == "none") { dsp.display = "block"; }
		else if (dsp.display == "block") { dsp.display = "none"; }
	}
	function highlightit(elem){
		dsp = document.getElementById(elem).style;
		//window.alert(dsp.color);
		if (dsp.color == "rgb(136, 136, 136)") { dsp.color = "#000000"; }
		else if (dsp.color == "rgb(0, 0, 0)") { dsp.color = "#888888"; }
	}
	
	var imgup = new Image();
	imgup.src = "images/bullet_arrow_up.png";
	var imgdown = new Image();
	imgdown.src = "images/bullet_arrow_down.png";
	var imgplus = new Image();
	imgplus.src = "images/bullet_add.png";
	var imgminus = new Image();
	imgminus.src = "images/bullet_delete.png";
	
	var Objekt = false;
	if (window.XMLHttpRequest) {
		Objekt = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		Objekt = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	function searching() {
		if (Objekt) {
			$("#adv").slideDown('slow');
			var result = document.getElementById('search_frame');
			search_string = document.search.sf.value;
			result.innerHTML = "";
			Objekt.open("POST", "search.php");
			Objekt.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			Objekt.onreadystatechange = function() {
				if (Objekt.readyState == 4 && Objekt.status == 200) {
					result.innerHTML = Objekt.responseText;
				}
			}
			Objekt.send("sf="+search_string);
		}
	}
	
	function imgswitchmain(elem){
		imgsrc = document.images[elem].src;
		if (imgsrc == imgplus.src) { document.images[elem].src = imgminus.src; }
		else if (imgsrc == imgminus.src) { document.images[elem].src = imgplus.src; }
	}
	function imgswitch(elem){
		imgsrc = document.images[elem].src;
		if (imgsrc == imgdown.src) { document.images[elem].src = imgup.src; }
		else if (imgsrc == imgup.src) { document.images[elem].src = imgdown.src; }
	}
	
	$(document).ready(function() {
		// show search filter
		$("#showadv").click(function () {
			$("#adv").slideToggle("slow");
		});
		
		// show all languages
		$("#langs").click(function () {
			$("#alllangs").slideToggle("slow");
		});
		
		// site object minigallery previews
		$('.gallerymini').hover(function(e){
			imgsize = 400;
			imgsource = $(this).attr('src');
			imgaddress = imgsource.substring(15, imgsource.length);
			img = new Image();
			img.src = 'photos/'+imgaddress;
			imgage_width = img.width;
			imgage_height = img.height;
			if (imgage_width >= imgage_height) {
				disp_width = imgsize;
				disp_height = Math.round(imgage_height*(disp_width/imgage_width));
			} else {
				disp_height = imgsize;
				disp_width = Math.round(imgage_width*(disp_height/imgage_height));
			}
			text = $(this).attr('title');
			image = '<img src="photos/'+imgaddress+'" width="'+disp_width+'" height="'+disp_height+'" style="display:block;" />';
			$('body').append('<div id="galleryimgprew" style="left:'+((e.clientX + document.documentElement.scrollLeft)-20-disp_width)+'px; top:'+((e.clientY + document.documentElement.scrollTop)+20)+'px;">'+image+'<div class="galleryimgdesc">'+text+'</div></div>');
		}, function(){
			$('#galleryimgprew').remove();
		});
		
		// VIP image rollover
		$('.gold_panel').hover(function(){
			$('.roll_cover', this).stop().animate({top:'-105px'}, {queue:true,duration:150,complete:function(){
				$('.cover_arrow', this).html('<img src="images/bullet_arrow_down.png" />');
			}});//,easing:'easeOutElastic'});
		}, function() {
			$('.roll_cover', this).stop().animate({top:'-15px'}, {queue:false,duration:700,complete:function(){
				$('.cover_arrow', this).html('<img src="images/bullet_arrow_up.png" />');
			}});//,easing:'easeOutElastic'});
		});
	});
	
	function imgswitchmain(elem){
		imgsrc = document.images[elem].src;
		if (imgsrc == imgplus.src) { document.images[elem].src = imgminus.src; }
		else if (imgsrc == imgminus.src) { document.images[elem].src = imgplus.src; }
	}
	
	function rotateObjects() {
		$('#rotatinglist').load('site_object_rotate.php', function() {
			$('#rotatinglist').fadeIn('slow', function() {
				$('#rotatinglist').delay(5000).fadeOut('slow', function() {
					rotateObjects();
				});
			});
		});
	}
