var FACEBOOK_VARS = {
	js_url: 'http://connect.facebook.net/ro_RO/all.js'
}
jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
function pb_alert(text){
	$('#pb_box_message > .content').html(text);
	$('#pb_box_message').fadeIn('fast');
	return false;
}


$(document).ready(
	function(){
		
		var cache = jQuery.ajaxSettings.cache; 
				jQuery.ajaxSettings.cache = true;
				jQuery.getScript(FACEBOOK_VARS.js_url, function() {
					FB.init({appId: FB_API, status: true, cookie: true, xfbml: true});
				});
				jQuery.ajaxSettings.cache = cache;
	
		$("#pbfooter-bar").jixedbar();
		$('.empty_on_focus').focus(
			function(){
				//alert($(this).css('color'));
				if ($(this).css('color')!='rgb(0, 0, 0)'){
					$(this).val('');
					//alert($(this).css('color'));
					$(this).addClass('focus_input');
					$(this).css({'color':'#000'});
					$(this).removeClass('empty_on_focus');
				}
			
				
			}
		);
	
	}
	
);

function report_item(item_type,id){
	$.post(SITE_URL+'/ajax.html', { 
			'action': 'report_item',
			'item_id' : id, 
			'item_type' : item_type
		},
	   function(data){
		if (data.error==''){
				pb_alert('Unul din operatori nostrii va verifica continutul raportat!<br /> Multumim!');
		}else{
				pb_alert(data.error);
		}
	     
	   }, "json");
	return false;
}

function insertAtCaret(areaId,text) { var txtarea = document.getElementById(areaId); var scrollPos = txtarea.scrollTop; var strPos = 0; var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); strPos = range.text.length; } else if (br == "ff") strPos = txtarea.selectionStart; var front = (txtarea.value).substring(0,strPos); var back = (txtarea.value).substring(strPos,txtarea.value.length); txtarea.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); range.moveStart ('character', strPos); range.moveEnd ('character', 0); range.select(); } else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); } txtarea.scrollTop = scrollPos; return false;} 

