var hasFlash = DetectFlashVer(7,0,0);

sub_path = "";
im1 = new Image(); im1.src = sub_path + "/common/im/wait_msg.gif"

function show_wait_msg(x)
{
  image_name = "wait_msg" + x
  document.images[image_name].src = sub_path + "/common/im/wait_msg.gif"
}

buttons1 = new Array('but_home', 'but_about', 'but_contact', 'but_links', 'but_clients')
submitted = 0;
function sub ()
{
	if (submitted) return;
	
	act = arguments[0]; //action
	conf = arguments[1]; //confirmation - set to 1 if requiring confirmation. else don't set it at all.
	
	OK = 0;
	if (conf == 1)
	{
		OK = confirm('Are you sure?');
	}
	
	if (OK || !isset(conf))
	{
		df = document.form1;
		df.act.value = act;
		df.action = location.href;
		df.submit();
		submitted = 1;
	}
}

function do_load() 
{
//	jload(buttons1);
}

function isset(variable) {
    return typeof(variable) != "undefined" && variable !== null;
}

var win1

function newWin(url,w,h) {
if (win1 && win1.open || win1 && !win1.closed){win1.close()}
win1 = window.open(url,"win1","width="+w+",height="+h+",toolbar=no,location=no,menubar=no,status=no,scrollbars=no,resizable=yes")
}

function jload(arr)
{
	im = new Array()
	for (n=0; n<arr.length; n++)
	{
		im[n] = new Image()
		im[n].src = im_path + arr[n] + "_f2.jpg"
	}
}
$(document).ready(function() {
	div_slider1();
	expand_div();
	toggle_preview_menu();
});

//Search stuff --------------------------------

//im1 = new Image(); im1.src = sub_path + "/im_cms/but_search_ani.gif"

var search_box_focus = 0;

function submitSearch()
{
	if (document.searchform.searchfield1.value.length > 2)
	{
		document.getElementById('searchButton').src = "/im_cms/but_search_ani.gif";
		search_box_focus = 1;
		return true;
	}
	else
	{
		document.searchform.searchfield1.focus();
		search_box_focus = 1;
		return false;
	}
}

function show_search() {
	
	$('#searchDivInner').hide();
	
	$('#searchfield1').focus(
		function () {
			search_box_focus = 1;
		}
	);
	
	$('a.showSearch').mouseover(
		function() {
			$('#searchDivInner').fadeIn();
		}
	);
	$('div#searchDivInner').mouseleave( 
			function() { 
				if (!search_box_focus) {
					$('#searchDivInner').fadeOut();
				}
			}		
	);
}

//end search stuff ---------------------------
//preview menu stuff ------------------------
function toggle_preview_menu () {
	$('a#but_pm_show_hide').click( 
		function () {
		 	if ($.cookie("pm_toggle") == "hide") //switch to showing div
			{
				$.cookie("pm_toggle", "show", { expires: 30 });
				$('#preview_menu').addClass("preview_menu_show");
				$('#preview_menu').removeClass("preview_menu_hide");
			}
			else
			{
				$.cookie("pm_toggle", "hide", { expires: 30 });
				$('#preview_menu').addClass("preview_menu_hide");
				$('#preview_menu').removeClass("preview_menu_show");
			}
			this.blur();
		 }
	);
}

//end pm stuff --------------------------------

function expand_div() {	
    $('.slideContent').hide(); //hide all these slides initially
	//expand div if title clicked
	$('a.slideTitle').click(
		function() {
			$(this).blur();
			if(!$(this).next().is(':visible')) var openThis = 1;
			//close all sliders
			$('.slideTitle').removeClass("slideTitleBold");
			$('.slideContent:visible').slideUp('fast');
			$('.slideContentOpen:visible').slideUp('fast');
			$.cookie("slides", "closed", { path: '/' });
			//open this one
			if (openThis) {
                $(this).addClass("slideTitleBold");
				$(this).next().slideDown('fast');
				$.cookie("slides", "open", { path: '/' });
			}
			return false;
		}
	);
	//on close click close all open (i.e. just this div)
	$('a.slideClose').click(
		function() {
			$('.slideTitle').removeClass("slideTitleBold");
			$('.slideContent:visible').slideUp('slow');
			$('.slideContentOpen:visible').slideUp('slow');
			$.cookie("slides", "closed", { path: '/' });
			return false;
		}
	);
}

function hide_slide_divs() {
	$('.slideContent').hide(); //hide all slideable divs
}

