function custom_var_dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];

  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}

// IE flicker fix - DPO
$(document).ready(function(){
    try {
      document.execCommand("BackgroundImageCache", false, true);
    } catch(e) {}
});

// attach confirmations to links
$(document).ready(function(){
    if (jQuery("a.delete-link").length > 0) {
        $("a.delete-link").bind("click", function(){
            return confirm("Sunteti sigur ca doriti sa stergeti?");
        });
    }
    
    if (jQuery("a.activate-link").length > 0) {
        $("a.activate-link").bind("click", function(){
            return confirm("Sunteti sigur ca doriti sa activati?");
        });
    }
    
    if (jQuery("a.deactivate-link").length > 0) {
        $("a.deactivate-link").bind("click", function(){
            return confirm("Sunteti sigur ca doriti sa dezactivati?");
        });
    }

});

var visibleDiv = "1";
function changeDivView(id){
	$("#box"+visibleDiv).slideUp()
	$("#boxTitle"+visibleDiv).removeClass('open')
	$("#boxTitle"+visibleDiv).addClass('closed')
	visibleDiv = id
	$("#box"+visibleDiv).slideDown('slow')
	$("#boxTitle"+visibleDiv).removeClass('closed')
	$("#boxTitle"+visibleDiv).addClass('open')
}

var login_active_url = '/magazin_online/';
function alertLogin (destination_url, show_close) {
    var close_div = "";

	if ( destination_url == login_active_url ){
		var class_register = 'closed';
		var class_login = 'open';
		var display_register = 'none';
		var display_login = '';
	}
	else{
		var class_register = 'open';
		var class_login = 'closed';
		var display_register = '';
		var display_login = 'none';
	}

    if (typeof show_close == "undefined" || show_close != false) {
        close_div = '<div class="close"><a href="javascript:void(0);" onclick="$.unblockUI();"></a></div>';
    }


    if (typeof destination_url != "undefined" && destination_url != "") {
        destination_url = '<input type="hidden" name="destination_url" value="'+ destination_url +'"/>';
    } else {
        destination_url = "";
    }


    var form = ''
	form += '	<div class="inregistrare login popup">'
	form += close_div
	form += '		<div class="top"></div>'
	form += '		<div class="middle accordion">'
	form += '		<div class="box_neutru">'
	form += '			<div class="padd_10">'
	form += '				PaginaFarmacistilor.ro se adreseaza profesionistilor din domeniul farmaceutic. Pentru a vizualiza aceasta pagina este obligatoriu sa ai cont.'
	form += '			</div>'
	form += '		</div>'
	form += '		<div class="content">'
	form += '			<div class="heading"><div id="boxTitle1" class="'+class_register+'"><a href="javascript:void(0)" onclick="changeDivView(1)">Inregistrare</a></div></div>'
	form += '			<div class="accordion_box" id="box1" style="display:'+display_register+';">'
	form += '				<div class="wrapper">'
	form += '					<h2 class="center">Nu esti membru in PaginaFarmacistilor.ro? <br />Creeaza-ti gratuit un cont!</h2>'
	form += '					<p class="padd_20">Ai acces la comunitatea online a farmacistilor, pastrezi legatura cu colegi de breasla si esti la curent cu toate stirile importante din domeniul farmaceutic.</p>'
	form += '				</div>'
	form += '				<div class="toolbar">'
	form += '					<div class="button_1"><a href="/utilizator/ContNou/"><span>Deschide cont</span></a></div>'
	form += '					<div class="link">sau <a href="javascript:void(0)" onclick="changeDivView(2)">autentifica-te</a></div>'
	form += '				</div>'
	form += '			</div>'
	form += '		</div>'
	form += '		<div class="content" style="margin-bottom:0;">'
	form += '			<div class="heading"><div id="boxTitle2" class="'+class_login+'"><a href="javascript:void(0)" onclick="changeDivView(2)">Autentificare</a></div></div>'
	form += '			<div class="accordion_box" id="box2" style="display:'+display_login+';">'
	form += '				<div class="wrapper">'
	form += '					<form action="/utilizator/login/" method="post" id="loginFrm" name="loginFrm">'
	form += destination_url
	form += '					<table class="form_1">'
	form += '						<tr>'
	form += '							<td colspan="2">'
	form += '								<label>Email:</label>'
	form += '								<input type="text" class="required" id="pesuname" name="pesuname" />'
	form += '							</td>'
	form += '						</tr>'
	form += '						<tr>'
	form += '							<td colspan="2">'
	form += '								<label>Parola:</label>'
	form += '								<input type="password" class="required" id="pesupass" name="pesupass" />'
	form += '							</td>'
	form += '						</tr>'
	form += '						<tr>'
	form += '							<td colspan="2">'
	form += '								<div class="error_box"><label class="error">Verifica daca ai introdus corect datele!</label></div>'
	form += '							</td>'
	form += '						</tr>'
	form += '						<tr class="links">'
	form += '							<td class="gri"><input class="checkbox_1" type="checkbox" name="remembe_me_status" checked="checked" /> Tine-ma minte</td>'
	form += '							<td style="text-align:right;"><a href="/utilizator/am-uitat-parola/">Ai uitat parola?</a></td>'
	form += '						</tr>'
	form += '					</table>'
	form += '					<input type="submit" style="display:none;">'
	form += '					</form>'
	form += '				</div>'
	form += '				<div class="toolbar">'
	form += '					<div class="button_4"><a id="autentificate_te_ma" href="javascript:void(0);"><span>Autentifica-te</span></a></div>'
	form += '					<div class="link">sau <a href="/utilizator/ContNou/">inregistreaza-te</a></div>'
	form += '				</div>'
	form += '			</div>'
	form += '		</div>'
	form += '	</div>'
	form += '		<div class="bottom"></div>'
	var width=$(window).width();var height=$(window).height();var left=parseInt((width-480)/2);var top=parseInt((height-430)/2);$.blockUI({css:{width:"480px",left:left+"px",top:top+"px",cursor:"auto",border:"none"},
        overlayCSS: { cursor: "auto" },
        message: form
    });



    $("#autentificate_te_ma").click(function(){
        $("#loginFrm").validate({
		  groups: {
			username: "pesuname pesupass"
		  },
		  errorPlacement: function(error, element) {
			 if (element.attr("name") == "pesuname"
						 || element.attr("name") == "pesupass" )
			   error.insertAfter("#pesupass");
			 else
			   error.insertAfter(element);
		   }
		 })
		 $("#loginFrm").submit()
    });
}

function alertCustomisable (html, show_close) {

    var close_div = "";
    if (typeof show_close == "undefined" || show_close != false) {
        close_div = '<div class="x_inchide"><a href="javascript:void(0);" onclick="$.unblockUI();"><img src="/theme/images/x.gif" alt="Inchide" /></a></div>';
    }

    var form = html;
    var width = $(window).width();
    var height = $(window).height();
    var left = parseInt((width - 700) / 2);
    var top = parseInt((height - 500) / 2);

    $.blockUI({
        css: { width: "400px", height: "300px", left: left+"px", backgroundColor: '', border: 'none', top: top+"px", cursor: "auto"},
        overlayCSS: { cursor: "auto" },
        message: form
    });
}


function mouseOver(id, img) {
	$("#"+ id).attr("src", "/theme/images/butoane/" + img);
}

function mouseOut(id, img) {
	$("#"+ id).attr("src", "/theme/images/butoane/" + img);
}

//from http://techpatterns.com/downloads/javascript_cookies.php
function Set_Cookie( name, value, expires, path, domain, secure ) {
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );
    
    /*
    if the expires variable is set, make the correct
    expires time, the current script below will set
    it for x number of days, to make it for hours,
    delete * 24, for minutes, delete * 60 * 24
    */
    if ( expires ) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );
    
    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ ) {
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
        
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
        
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name ) {
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 ) {
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) {
		return null;
	}
}

function Delete_Cookie( name, path, domain ) {
    if ( Get_Cookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function number_format(number, decimals, dec_point, thousands_sep) {
    // Formats a number with grouped thousands
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);
    // *     returns 9: '1'
    // *    example 10: number_format('1.20', 2);
    // *    returns 10: '1.20'    // *    example 11: number_format('1.20', 4);
    // *    returns 11: '1.2000'
    // *    example 12: number_format('1.2000', 3);
    // *    returns 12: '1.200'
    // *    example 13: number_format('1 000,50', 2, '.', ' ');    // *    returns 13: '100 050.00'
    number = (number+'').replace(',', '').replace(' ', '');
    var n = !isFinite(+number) ? 0 : +number,
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }    return s.join(dec);
}

