function open_login() {
    //$('#loginForm').modal({onOpen: modalOpen});
	$('#loginForm').modal();
	$('#user_name').focus();
}
function open_newMessages() {
if ($('#newMessagesCount').html()!=null && $('#newMessagesCount').html()!=0) {
		$('#newMessages').modal({
			containerCss: {
				height: '320px'
			}
		});		
	}
}
function modalOpen (dialog) {
	dialog.overlay.fadeIn('slow', function () {	    
		dialog.container.fadeIn('slow', function () {
			dialog.data.hide().slideDown('slow');
            			
		});
	});
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}

function strpos( haystack, needle, offset){    // Find position of first occurrence of a string
    var i = haystack.indexOf( needle, offset ); // returns -1
    return i >= 0 ? i : false;
}
function substr( f_string, f_start, f_length ) {    // Return part of a string
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}