try
{
function get_select_value(id){

	return $('#'+id).val();
}

// json default
if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?'0'+n:n}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key)}if(typeof rep==='function'){value=rep.call(holder,key,value)}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null'}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null'}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v)}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' '}}else if(typeof space==='string'){indent=space}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify')}return str('',{'':value})}}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j}throw new SyntaxError('JSON.parse')}}}());

// btoa atob
if(typeof btoa=='undefined'){function btoa(str){var chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';var encoded=[];var c=0;while(c<str.length){var b0=str.charCodeAt(c++);var b1=str.charCodeAt(c++);var b2=str.charCodeAt(c++);var buf=(b0<<16)+((b1||0)<<8)+(b2||0);var i0=(buf&(63<<18))>>18;var i1=(buf&(63<<12))>>12;var i2=isNaN(b1)?64:(buf&(63<<6))>>6;var i3=isNaN(b2)?64:(buf&63);encoded[encoded.length]=chars.charAt(i0);encoded[encoded.length]=chars.charAt(i1);encoded[encoded.length]=chars.charAt(i2);encoded[encoded.length]=chars.charAt(i3)}return encoded.join('')}}if(typeof atob=='undefined'){function atob(str){var chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';var invalid={strlen:(str.length%4!=0),chars:new RegExp('[^'+chars+']').test(str),equals:(/=/.test(str)&&(/=[^=]/.test(str)||/={3}/.test(str)))};if(invalid.strlen||invalid.chars||invalid.equals)throw new Error('Invalid base64 data');var decoded=[];var c=0;while(c<str.length){var i0=chars.indexOf(str.charAt(c++));var i1=chars.indexOf(str.charAt(c++));var i2=chars.indexOf(str.charAt(c++));var i3=chars.indexOf(str.charAt(c++));var buf=(i0<<18)+(i1<<12)+((i2&63)<<6)+(i3&63);var b0=(buf&(255<<16))>>16;var b1=(i2==64)?-1:(buf&(255<<8))>>8;var b2=(i3==64)?-1:(buf&255);decoded[decoded.length]=String.fromCharCode(b0);if(b1>=0)decoded[decoded.length]=String.fromCharCode(b1);if(b2>=0)decoded[decoded.length]=String.fromCharCode(b2)}return decoded.join('')}}


function unobfuscate(input){
	input = input.replace('%','/');
	input = input.replace('-','+');
	input = input.replace('!','=');
	input = atob(input);
	try{
		input = JSON.parse(input);
		return input;
	}catch(e){
		return input;		
	}
}
function obfuscate(input){
	if(typeof(input) != 'string')
		input = JSON.stringify(input);
	input = btoa(input);
	input = input.replace('/','%');
	input = input.replace('+','-');
	input = input.replace('=','!');
	return input;
}

function select_redirect(id){

	var select_value = get_select_value(id);
	window.location = select_value;
}
function click_clear(t, defaulttext){ 
	if ($(t).val() == defaulttext){ 
		$(t).val("");
	}else if($(t).val().length == 0){
		$(t).val(defaulttext);
	}
}
function submit_form(formid){

	$('#'+formid).submit();

}
function rw_root(){

	return rw_root_url;
}
function set_view(id){
/*
	if(id==null){
		return false;
	}
	var meta = $('#view-'+id+' .view-meta').val();
	var href = "";
	$('#view-'+id+' a').each(function(){
		href = $(this).attr('href');
		if(href.substr(0, 4)=='view'){
			$(this).attr('href', '#rw');
			$(this).attr('onclick',
				//"alert('"+rw_root()+href+'/meta='+meta+"');"
				"url_to_id('#view-"+id+"','"+rw_root()+href+'/meta='+meta+"');"+
				"set_view(id);"
			);
		}
	});*/
	return false;
}
function make_popup(input, height, width){

	close_popup();
	
	var contents = '';
	if($(input).length == 0){
		contents = input;
	}else{
		contents = '<span class="hidden" id="rw-popup-selector">'+input+'</span>'+$(input).html();
		$(input).html('');		
	}
	
	if(width === undefined)
		var width = 'auto';
	
	if(height === undefined)
		var height = 'auto';

	$('#html-body').append( 
		'<div id="rw-popup-background" onclick="close_popup();"></div>' +
		'<div id="rw-popup">'+
			'<a href="#" class="make-block close-popup-link" onclick="close_popup();">&times;</a>'+
			'<div class="body"><div class="body-inner" id="rw-popup-body-inner">'+ contents +'</div></div>'+
		'</div>'
	);

	$('#rw-popup-background').css({'width':$(window).width(),'height':$(document).height(),'opacity':0.75});
	$('#rw-popup-background').show();
	$('#rw-popup').css({
		'width':width+40,
		'height':height+40
	});
	var margin_left = ($(window).width()-$('#rw-popup').width()+40)/2;
	var margin_top = ($(window).height()-$('#rw-popup').height()+40)/2;
	if(margin_top<=0) margin_top = 50;
	$('#rw-popup').css({
		'margin-left':margin_left,
		'margin-top':margin_top
	});

	$('#rw-popup').show();

}
function close_popup(){
	
	if($('#rw-popup-body-inner').length > 0)
	$($('#rw-popup-selector').text()).html($('#rw-popup-body-inner').html());	
	$('#rw-popup').remove();
	$('#rw-popup-background').remove();

};
function valid_email(email){
	return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email);	
}
function insert_media(type, filename, description){

	alert(type);
	if(type == 'images'){
		var string = '<img src="assets/media/' +  type + '/' + filename + '" alt="' + description + '"  />';
	}

	if(type == 'other'){

		var string = '<a href="assets/media/' +  type + '/' + filename + '" class="' + ext + '-link">' + description + '</a>';

	}

	tinyMCE.execCommand('mceInsertContent',false,string);
}
function url_to_id(selector, url_string){

	if(selector == null || url_string == null){
		return false;
	}

	$.ajax({
		url:  url_string,
		cache: false,
		success: function(html){
			$(selector).html(html);
		}
	});

}
function chr_to_ord(characters){

	if(characters==null){
	   	return null;
	}
	var characters_array = new Array();
	characters_array = characters.split("");
	var ords = '';
	var ord = '';
	for (x in characters_array){
		characters = characters_array[x];
		ord = characters.charCodeAt(0)+'';
		while(ord.length<3){
			ord = '0'+ord;
		}
		ords+=ord;
	}
	return ords;

}
function urlencode(str) {
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
function add_alert_note(color, string){

	$('.alerts-notes').html('<div class="a-n a-n-'+color+'" id="alert_note">'+string+'</div>');
	$('#alert_note').click(function () {
		$('#alert_note').fadeOut('slow');
	});
	setTimeout("$('#alert_note').fadeOut('slow')",5000);

}
var blank = new Image();
 blank.src = 'images/blank.gif';
 
 $(document).ready(function() {
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
 });
function fixPng(png) {
	// get src
	var src = png.src;
	// set width and height
	if (!png.style.width) { png.style.width = $(png).width(); }
	if (!png.style.height) { png.style.height = $(png).height(); }
	// replace by blank image
	png.onload = function() { };
	png.src = blank.src;
	// set filter (display original image)
	png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}
function translate(lang){
	window.location = 'http://translate.google.com/translate?hl=en&sl=en&tl='+lang+'&u='+location.href;
}
function confirm_go(confirm_message, url){
	
	if(confirm_message == undefined || url == undefined)
		return false;
	
	if (confirm(confirm_message))
		window.location = url;
	
}
function site_search(selector, url){

	if(selector == null || selector.length == 0) selector = '#site-search';
	if(url == null || url.length == 0) url = 'search';

	if($(selector).length == 0 || $(selector).val().replace(' ','').length == 0) return false;

	window.location=rw_root_url+url+'='+$(selector).val();
	return false;

}
function countdown_redirect(url, selector){

	if($(selector).length == 0 || url == undefined)
		return false;
	
	var time_left = $(selector).text()*1;
	
	if(time_left == 0) return false;
	
	if(time_left == 1){
		window.location=url;
		return false;
	}
	
	$(selector).text(time_left-1);
	setTimeout("countdown_redirect('"+url+"','"+selector+"');",time_left*100);
}
$(document).ready(function() {

	if($('#rw-admin-footer').length > 0){

	

	}

});
}catch(e){
	alert("ERROR:" + e);
}

