
$.extend({
	getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	getUrlVar: function(name){
		return $.getUrlVars()[name];
	}
});

$(document).ready(function() {


	//jgueryui error box setup

	$( "#errors" ).dialog({
		autoOpen: false,
		show: {effect: "fade", duration: 300},
		hide: {effect: "explode", duration: 250},
		width: 700,
		height: 210,
		resizable: false

	});

	$('.lang_block .lang_bar img').click(function(){
		$('.lang_item').hide();
		$('#lang_' + $(this).attr('id')).show();
	})


	


});


function replaceURLWithHTMLLinks(text) {
	var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
	return text.replace(exp,"<a href='$1' target='_blank'>$1</a>"); 
}



function Stringify(jsonData) {
    var strJsonData = '{';
    var itemCount = 0;
    for (var item in jsonData) {
        if (itemCount > 0) {
            strJsonData += ', ';
        }
    temp = jsonData[item];
    if (typeof(temp) == 'object') {
        s =  Stringify(temp);   
    } else {
        s = '"' + temp + '"';
    }   
    strJsonData += '"' + item + '":' + s;
        itemCount++;
    }
    strJsonData += '}';
    return strJsonData;
}

