﻿var j = jQuery.noConflict();
j(
	function(){
		var menu = j("#menu td");
		var dot = j('<td><img src="/images/menu/dot.gif" alt="" width="16" heigth="28" /></td>');
		menu.each(function(i){
			var item = j(this);
			if(i < (menu.length - 1)){
				var next = j(menu[i + 1]);
				if(!item.is(".Yes") && !next.is(".Yes")){
					item.after(j('<td><img src="/images/menu/dot.gif" alt="" width="16" heigth="28" /></td>'));
				}
			}
			
		});
	}
);
function go(u){
	document.location = u;
}

function refresh(){
    document.location.reload( false );
}
function viewState(i,v){
	if(!i)
		i = 0;
	if(!v)
		v = "#views > div";
	j(j(v).hide()[i]).show();
	j(window).scrollTop(0);
}

function submitForm(form, callback, error){
	if(!callback)
		var callback = function(){};
	if(!error)
		var error = function(){};
	if(Spry.Widget.Form.validate(form)){
		Spry.Utils.submitForm(form, function(req){
			var r = req.xhRequest.responseText;
			if(parseFloat(r)){
				callback(r);
			}
			else {
				error(r);
			}
		});
	}
	return false;
}


String.prototype.get = function() {
	var r = {};
	var s = this;
	var q = s.substring(s.indexOf('?') + 1); // remove everything up to the ?
	q = q.replace(/\&$/, ''); // remove the trailing &
	jQuery.each(q.split('&'), function() {
		var splitted = this.split('=');
		var key = splitted[0];
		if(splitted.length > 1)
			var val = splitted[1];
		else
			var val = "";
		if (/^[0-9.]+$/.test(val)) val = parseFloat(val); 	// convert floats
		if (typeof val == 'number' || val.length > 0) r[key] = val; // ignore empty values
	});
	return r;
};
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}