function submitContactFrm() {
	$('#contactfrmloading').show();
	$('#contactusfrm').ajaxSubmit({
		data : {

		},
		success : function(data) {
			$('#contactfrmloading').hide();
			alert(data);
		},
		error : function() {
			$('#contactfrmloading').hide();
			alert('Problem contacting server.');
		}
	});
	
	
}

function updateStack(target,isfirst) {
	$('.stackbtn').removeClass('current');
	$(target).addClass('current');
	
	$('.stackpanel').each(function() {
		var $this = $(this);
		if (target!=$this) {
			$this.hide();
		}
	});
	$('#'+target.attr('stackpanelid')).show();
	
	if (!isfirst) window.document.location.hash = target.attr('panelname');
}

$(document).ready(function(){
	$('.stackbtn').bind('click',function() {
		var target = $(this);
		updateStack(target);
	});
	
	// use the url hash to select the current stack
	var defaultStack = window.document.location.hash;//urlParams.p;
	defaultStack = defaultStack.substring(1, defaultStack.length);
	var f = $('.stackbtn[panelname="'+defaultStack+'"]');
	if (f.length==0) f = $('.stackbtn:first');
	if (f.length>0) updateStack(f,true);

	
	// check if there's a field which needs the current path filled into
	$('.stitch_frm_currentpath').val(window.location.pathname);
});

/**
 * A simple querystring parser.
 * Example usage: var q = $.parseQuery(); q.fooreturns  "bar" if query contains "?foo=bar"; multiple values are added to an array. 
 * Values are unescaped by default and plus signs replaced with spaces, or an alternate processing function can be passed in the params object .
 * http://actingthemaggot.com/jquery
 *
 * Copyright (c) 2008 Michael Manning (http://actingthemaggot.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/
jQuery.parseQuery = function(qs,options) {
	var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
	jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
		p = p.split('=');
		p[1] = o.f(p[1]);
		params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1],params[p[0]])):[params[p[0]],p[1]]):p[1];
	});
	return params;
};

var urlParams = jQuery.parseQuery();

function log(o) {
	if (typeof(console)!='undefined') console.log(o);
}

function loadjscssfile(filename, filetype) {
	if (filetype == "js") { // if filename is a external JavaScript file
		var fileref = document.createElement('script');
		fileref.setAttribute("type", "text/javascript");
		fileref.setAttribute("src", filename);
	} else if (filetype == "css") { // if filename is an external CSS file
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename);
	}
	if (typeof fileref != "undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref);
	}
}

loadjscssfile("/sbres/jquery/js/jquery.form.js", "js");
loadjscssfile("/sbres/jquery/ui/cycle/jquery.cycle.all.min.js", "js");

//loadjscssfile("mystyle.css", "css") // //dynamically load and add this .css file

