var req;
function Initialize(){
    try
    {
        req=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            req=null;
        }
    }
    if(!req&&typeof XMLHttpRequest!="undefined"){
		req= new
		XMLHttpRequest();
	}
	return req;
}
function SendQuery(keyVal){
	
	var req = Initialize(); 
	varurl= "includes/get_data.php?item=" + keyVal;
	if(req!=null)
	{
		req.onreadystatechange = Process;
		req.open("GET", varurl, true);
		req.send(null);
	}
	AddTag('javascript/jquery-1.2.6.js');
}

function LoadScript(file){
	var request = Initialize();
	if (request!=null){
		request.onreadystatechange = function() {
			if (request.readyState == 4 && request.status == 200) {
				eval(request.responseText);	
			}
		}
		request.open("GET", file, true);
		request.send(null);
	}
}

function AddTag(fileName) {
	// add a script file, if it isn't already there
	var head = document.getElementsByTagName("head")[0];
	for(i=0;i<document.getElementsByTagName("script").length;i++){
		if(fileName === document.getElementsByTagName("script")[i].getAttribute("src"))
			head.removeChild(document.getElementsByTagName("script")[i]); // remove it so it can be added again
	}
	var newScript = document.createElement('script');
	newScript.setAttribute('type', 'text/javascript');
	newScript.setAttribute('src', fileName);
	head.appendChild(newScript);
	
}
function Process(){
    if (req.readyState == 4){
		if (req.status == 200)
		{
			if(req.responseText=="")
				HideDiv("autocomplete");
			else
			{
				
				ShowDiv("autocomplete");

				document.getElementById("autocomplete").innerHTML = req.responseText;
				// this function calls the tabpane and sets it up
				setupAllTabs();
				
				// this function will need to work similar to setupAllTabs()
				

			}
		}
		else
		{
			document.getElementById("autocomplete").innerHTML=
				"There was a problem retrieving data:<br>"+req.statusText;
		}
	}
}

function ShowDiv(divid){
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.visibility="visible";
}

function HideDiv(divid){
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.visibility="hidden";
}

function BodyLoad(){
    HideDiv("autocomplete");
    document.form1.keyword.focus();
}
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}
function autoSizePop(type,source) {
	if(type=='image'){
		photo = new Image();
		photo.src = source;
		if((photo.width != 0) && (photo.height != 0)){
			var width = photo.width;
			var height = photo.height;
			// limit window to max size of 500 hundred on the largest side
			if ((width > 500) || (height > 500)){
				var ratio = width/height;
				if(width > height) {
					width = 500;
					height = width/ratio;

				} else {
					height = 500;
					width = height*ratio;
				}
			}
			height = height+20;
			width = width+20;
			sizeString = "width="+width+",height="+height;
			openWin = window.open(source,"",sizeString+",resizable=1,scrollbars=1");
		} 	
	}
}

function RemoveTag(fileName) {
	// add a script file, if it isn't already there
	var head = document.getElementsByTagName("head")[0];
	for(i=0;i<document.getElementsByTagName("script").length;i++){
		if(fileName === document.getElementsByTagName("script")[i].getAttribute("src"))
			head.removeChild(document.getElementsByTagName("script")[i]); // remove it so it can be added again
	}
//	var newScript = document.createElement('script');
//	newScript.setAttribute('type', 'text/javascript');
//	newScript.setAttribute('src', fileName);
//	head.appendChild(newScript);
	
}

function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(200);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}


/*
jQuery(function($) { 
		//$('.galleria_unstyled').addClass('galleria'); // need to work this one out
		
		$('ul.galleria').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : false, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				// try and set the max size of the image based on proportions
				var ratio = $(image).height()/$(image).width();
				if($(image).height() > $(image).width()) {
					 image.css('height','300px');
					 image.css('width', $(image).height()/ratio);
				} else {
					image.css('width', '300px');
					image.css('height', $(image).width()*ratio);
				}
				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(100);
				}
				caption.css('display','none').fadeIn(1);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				//_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				//thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Item Page >>');
				
				image.wrap($(document.createElement('a')).attr('href',thumb.attr('alt')));
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				//var _fadeTo = _li.is('.active') ? '1' : '0.3';
				var _fadeTo = '1';
				// fade in the thumbnail when finished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(150);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',100); },
					function() { _li.not('.active').children('img').fadeTo('fast',1); } // don't fade out if the parent is active
				) 
			} 
		});
 });

$(document).ready(function(){
	mainmenu();
	$("ul.galleria li:first").addClass('active');
});

*/   

