    function getURLParam(strParamName){
      var strReturn = "";
      var strHref = window.location.href;
      if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
          if (
    aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
            var aParam = aQueryString[iParam].split("=");
            strReturn = aParam[1];
            break;
          }
        }
      }
      return unescape(strReturn);
    }





var clinician_login = false;
//Login Function
function submitLoginForm(){
	var data = $('login_users').serialize();
	var url = 'ajax_login.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			if(json.is_error == true){
			$('errors_messages').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="errors" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				$('errors_messages').innerHTML = errors_str;
			    var login = $('login').value;
			    $('login_users').reset();
			    $('login').value = login;
			    $('main_conteiner_errors_ok').style.display= 'none';
			    $('main_conteiner_errors').style.display= 'none';

			}else{
				if(json.target){
					location = json.target;
				}
				var cmd 			= getURLParam('cmd');
				var page_id 	= getURLParam('page_id');
				if(cmd != null && page_id != null){
					var url_question = 'ajax_user_questions.php?cmd='+cmd+'&page_id='+page_id;
					var requestData_Question = new Ajax.Request(url_question,{
					method: 'get',
						onSuccess: function(transport) {
							$('users_questions').innerHTML = transport.responseText;
						}
					});
				}
				clinician_login = true;
				$('login_box').style.display = 'none';
				$('errors_messages').style.display = 'none';
				$('login_user_box').style.display = '';
				$('login_user_box').innerHTML = '<span class="text_grey_10">Welcome, <span>'+json.first_name+'</span><br /><a href="blogs.php" class="text_orange_10">Manage Blogs</a> <br /> Now you are logged in&nbsp;|&nbsp;<a href="logout.php" class="text_orange_10">Logout</a> <br /> <input type="image" style="padding-top:5px;" src="images/btn_editaccount.gif" onclick="getEditAccount(true); return false;" />';
				if($('main_conteiner_errors_ok')){
					$('main_conteiner_errors_ok').style.display = 'none';
				}
				if($('main_conteiner_errors')){
					$('main_conteiner_errors').style.display = 'none';
				}
				if($('right_box_question_id')){
					$('right_box_question_id').style.display = 'none';
				}

			}
		}
	});
}

function submitLoginFormModal(){
	var data = $('login_users_modal').serialize();
	var url = 'ajax_login.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			if(json.is_error == true){
			$('login_errors_box').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="errors" style="width: 380px;">	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				if(i ==1){
					var new_height = 150 + 120;
					var new_height_2 = 125 + 120;
				}else{
					var new_height = 150 + (i*70);
					var new_height_2 = 125 + (i*70);
				}
				$('outBox_modal').style.height = new_height+'px';
				$('innerBox_modal').style.height = new_height_2+'px';

				$('login_errors_box').innerHTML = errors_str;
			    var login = $('login_modal').value;
			    $('login_users_modal').reset();
			    $('login_modal').value = login;
			    $('main_conteiner_errors_ok').style.display= 'none';
			    $('main_conteiner_errors').style.display= 'none';
			}else{
				if(json.target){
					location = json.target;
				}
				var cmd 			= getURLParam('cmd');
				var page_id 	= getURLParam('page_id');
				if(cmd != null && page_id != null){
					var url_question = 'ajax_user_questions.php?cmd='+cmd+'&page_id='+page_id;
					var requestData_Question = new Ajax.Request(url_question,{
					method: 'get',
						onSuccess: function(transport) {
							$('users_questions').innerHTML = transport.responseText;
						}
					});
				}
				clinician_login = true;
				$('login_box').style.display = 'none';
				$('errors_messages').style.display = 'none';
				$('login_user_box').style.display = '';
				$('login_user_box').innerHTML = '<span class="text_grey_10">Welcome, <span class="text_orange_10">'+json.username+'</span><br /><a href="blogs.php" class="text_orange_10">Manage Blogs</a> <br /> Now you are logged in&nbsp;|&nbsp;<a href="logout.php" class="text_orange_10">Logout</a> <br /> <input type="image" style="padding-top:5px;" src="images/btn_editaccount.gif" onclick="getEditAccount(true); return false;" />';
				if($('main_conteiner_errors_ok')){
					$('main_conteiner_errors_ok').style.display = 'none';
				}
				if($('main_conteiner_errors')){
					$('main_conteiner_errors').style.display = 'none';
				}
				if($('right_box_question_id')){
					$('right_box_question_id').style.display = 'none';
				}
				getLoginWindowErr(false, null);
			}
		}
	});
}


function getLoginWindowErr(show, url){
	$('errors_messages').style.display = 'none';
	if(clinician_login == false){
		if(show == true){
			$('hide_all').style.display = 'block';
			$('hide_all_2').style.height = '1200px'; //document.height+'px';
			$('hide_all_2').style.display = 'block';

		//	$('hide_all').style.width = '100%';
		//	$('hide_all').style.height = '100%';
		    $('forgot_password_box').style.display = '';
			new Ajax.Updater('forgot_password_box', 'ajax_login.php?cmd=get_login_error_form'	);
		}else{
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
			$('forgot_password_box').innerHTML = '';
			$('forgot_password_box').style.display = 'none';
		}
	}else{
		if(url != null){
			location = url;
		}else{
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
			$('forgot_password_box').innerHTML = '';
			$('forgot_password_box').style.display = 'none';
		}
	}
}

// Login For Clinicians page ----- Not working
var index_of = 0;
var opened_login_windows = new Array();
var setting_back_url = '';
function getLoginWindow(back_url, page_id){
	setting_back_url = back_url;
	if(!opened_login_windows[index_of] || opened_login_windows[index_of] == page_id){
		opened_login_windows[index_of] = page_id;
	}else{
		index_of++;
		opened_login_windows[index_of] =  page_id;
	}
	var gopa = 0;
	for(var index = 0; index < opened_login_windows.length; ++index){
		gopa = opened_login_windows[index];
		if(gopa != page_id){
			$('clinicians_login_id_'+gopa).style.display = 'none';
		}
	}
	$('clinicians_login_id_'+page_id).style.display = 'block';
}
//Login Function
function submitLoginFormClin(page_id){
	var login_form = 'login_users_clin_'+page_id
	var data = $(login_form).serialize();
	var url = 'ajax_login.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			if(json.is_error == true){
			$('errors_messages').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="errors" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				$('errors_messages').innerHTML = errors_str;
			    var login = $('login').value;
			    $(login_form).reset();
			    $('login').value = login;
			    $('main_conteiner_errors_ok').innerHTML= '';
			    $('main_conteiner_errors').innerHTML = 'none';

			}else{
				if(setting_back_url != ''){
					location = setting_back_url;
				}
				$('login_box').style.display = 'none';
				$('errors_messages').style.display = 'none';
				$('login_user_box').style.display = '';
				$('login_user_box').innerHTML = '<span class="text_grey_10">Welcome, <span class="text_orange_10">'+json.username+'</span><br /><a href="blogs.php" class="text_orange_10">Manage Blogs</a> <br /> Now you are logged in&nbsp;|&nbsp;<a href="logout.php" class="text_orange_10">Logout</a> <br /> <input type="image" style="padding-top:5px;" src="images/btn_editaccount.gif" onclick="getEditAccount(true); return false;" />';
				$('main_conteiner_errors_ok').innerHTML = 'none';
				$('main_conteiner_errors').innerHTML = 'none';

			}
		}
	});
}
// --------------------------------------------

//Forgot password window
function forgotPasswordWindow(show){
	$('errors_messages').style.display = 'none';
	if($('fmpContainer1')){
		$('fmpContainer1').style.display = 'none';
	}
	if($('audioplayer')){
		$('audioplayer').style.display = 'none';
	}
	if(show == true){
		$('hide_all').style.display = 'block';
		$('hide_all_2').style.height = '1200px'; //document.height+'px';
		$('hide_all_2').style.display = 'block';

	//	$('hide_all').style.width = '100%';
	//	$('hide_all').style.height = '100%';
	    $('forgot_password_box').style.display = '';
		new Ajax.Updater('forgot_password_box', 'ajax_login.php?cmd=get_forgot_password_form'	);
	}else{
		$('hide_all').style.display = 'none';
		$('hide_all_2').style.display = 'none';
		$('forgot_password_box').innerHTML = '';
		$('forgot_password_box').style.display = 'none';
		if($('audioplayer')){
			$('audioplayer').style.display = 'block';
		}
		if($('fmpContainer1')){
			$('fmpContainer1').style.display = 'block';
		}
	}
}

// Submit Forgot Password form
function submitForgotPasswordForm(){
    var data = $('reset_password').serialize();
	var url = 'ajax_login.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			$('outBox').style.height = '260px';
			$('innerBox').style.height ='236px';
			if(json.is_error == true){
			    $('errors_messages_forgot').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="errors" style="width:400px;" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				$('errors_messages_forgot').innerHTML = errors_str;
			}else{
				$('errors_messages_forgot').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="ok_message" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				$('errors_messages_forgot').innerHTML = errors_str;
			}
		}
	});
}


// Edit Account Functionality
function getEditAccount(show){
	$('errors_messages').style.display = 'none';
	if(show == true){
			if($('fmpContainer1')){
				$('fmpContainer1').style.display = 'none';
			}
			if($('audioplayer')){
				$('audioplayer').style.display = 'none';
			}
		$('hide_all').style.display = 'block';
		$('hide_all_2').style.display = 'block';
		$('hide_all_2').style.height =  '1200px';//document.height+'px';
		$('edit_account_box').style.display = 'block';
		new Ajax.Updater('edit_account_box', 'edit_account.php?cmd=get_form'	);
	}else{
		$('hide_all').style.display = 'none';
		$('hide_all_2').style.display = 'none';
		$('edit_account_box').innerHTML = '';
		$('edit_account_box').style.display = 'none';
		if($('fmpContainer1')){
			$('fmpContainer1').style.display = 'block';
		}
		if($('audioplayer')){
			$('audioplayer').style.display = 'block';
		}
	}
}


function submitEditAccountBox(){
	var data = $('edit_account_form').serialize();
	var url = 'edit_account.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			if(json.is_error == true){
				var errors_str = '';
				var i = 0;
				for(i; i < json.count ; i++){
					 errors_str += '<div class="errors" style="width:250px;" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				var outBox 		= 380 + i*65;
				var innerBox 	= 356 + i*65;
				$('outBox').style.height = outBox+'px';
				$('innerBox').style.height = innerBox+'px';
			    $('errors_messages_edit_account').style.display = '';
				$('errors_messages_edit_account').innerHTML = errors_str;
			}else{
				$('errors_messages_edit_account').style.display = 'block';
				var errors_str = '';
				var i = 0;
				 errors_str = '<div class="ok_message" style="width:250px;">	'+json.messages+'</div><div style="height:5px;">&nbsp;</div>';
				var outBox 		= 380 + 60;
				var innerBox 	= 356 + 60;
				$('outBox').style.height = outBox+'px';
				$('innerBox').style.height = innerBox+'px';
				$('errors_messages_edit_account').innerHTML = errors_str;
			}
		}
	});
}


//Submit a Question functionality

function submitQuestion(){
	if($('submit_question_btn')){
		$('submit_question_btn').disabled = true;
	}
	var errors = '';
//	if($('from_name').value == ''){
//		errors += '<div class="errors" style="width:180px;" >	Name must be entered.</div><div style="height:5px;">&nbsp;</div>';
//	}
	if($('from_email').value == ''){
			errors += '<div class="errors" style="width:180px;" >	Email must be entered.</div><div style="height:5px;">&nbsp;</div>';
	}
	var email_format = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if ($('from_email').value.search(email_format)== -1){
			errors += '<div class="errors" style="width:180px;" >	Email has incorrect format.</div><div style="height:5px;">&nbsp;</div>';
    }
	if($('qusetion').value == ''){
			errors += '<div class="errors" style="width:180px;" >	Question must be entered.</div><div style="height:5px;">&nbsp;</div>';
	}
	if($('qusetion').value.length > 255){
			errors += '<div class="errors" style="width:180px;" >	Question text should be within 255 symbols.</div><div style="height:5px;">&nbsp;</div>';
	}
	if(errors == ''){
		$('errors_question').innerHTML = '';
		$('errors_question').style.display = 'none';
		var data = $('question_form').serialize();
		var url = 'ajax_questions.php?'+data;
		var requestData = new Ajax.Request(url,{
		method: 'get',
			onSuccess: function(transport, json) {
				if(json.is_error == false){
					$('errors_question').style.display = 'block';
					var errors_str = '';
					var i = 0;
					 errors_str = '<div class="ok_message" style="width:180px;">	'+json.messages+'</div><div style="height:5px;">&nbsp;</div>';
					$('errors_question').innerHTML = errors_str;
					$('question_form').reset();
				}
					if($('submit_question_btn')){
						$('submit_question_btn').disabled = false;
					}
			}
		});
	}else{
		$('errors_question').innerHTML = '';
		$('errors_question').innerHTML = errors;
		if($('submit_question_btn')){
			$('submit_question_btn').disabled = false;
		}
	}
}


// Blogs functionality
var send_comment = false;
function submitComment(){
	if($('comment').value.length > 255){
			$('errors_messages').style.display = '';
			$('errors_messages').innerHTML = '<div class="errors" >	Comment text should be within 255 symbols. </div><div style="height:5px;">&nbsp;</div>';
	}else{
		if($('comment').value == ''){
			$('errors_messages').style.display = '';
			$('errors_messages').innerHTML = '<div class="errors" >	Comment must be entered. </div><div style="height:5px;">&nbsp;</div>';
		}else{
			if(send_comment == false){
				send_comment = true;
				var data = $('comments_form').serialize();
				var url = 'ajax_blogs.php?'+data;
				var requestData = new Ajax.Request(url,{
				method: 'get',
					onSuccess: function(transport, json) {

							$('no_comments').style.display = 'none';
							$('errors_messages').innerHTML = '';
							$('errors_messages').style.display = 'block';
							if(json.is_error == true){
								$('header_button_back').style.display = 'block';
								var errors_str = '';
								 errors_str = '<div class="errors" style="width:180px;">	Blog has been closed. </div><div style="height:5px;">&nbsp;</div>';
								$('main_comments_container').style.display = 'none';
								$('errors_messages').innerHTML = errors_str;
								$('additional_comments').innerHTML = '';
								$('comments_form').reset();
								$('comments_panel').style.display = 'none';
								var comments = '<div><div class="table_blogs_cont_user"> <div class="title_3_no_user">'+json.data.username+'&nbsp;<span class="text_grey_10">wrote: </span></div>'+'<div class="comment_body">'+json.data.answer.replace(/\n/g,"<br />" )+'</div></div><div class="page_dev_blog"></div></div>';
								$('additional_comments').innerHTML = comments;
								send_comment = false;

							}else{
								var errors_str = '';
								var comment_id = json.data;
								var i = 0;
								 errors_str = '<div class="ok_message" style="width:180px;">	Your comment has been added. </div><div style="height:5px;">&nbsp;</div>';
								$('errors_messages').innerHTML = errors_str;
								var old_comments = $('additional_comments').innerHTML;
								old_comments += '<div id="'+comment_id+'"><div class="table_blogs_cont_user"> <div class="title_3_no_user">'+$('username').value+'&nbsp;<span class="text_grey_10">wrote: </span></div> <div class="delete_comment"><a href="#" onclick="if(confirm(\'Are you sure to delete this comment?\') == true){deleteComment('+comment_id+');}" ><img src="images/pic_trash.gif" alt="delete" /></a></div></div>'+'<div class="comment_body">'+$('comment').value.replace(/\n/g,"<br />" )+'</div></div><div class="page_dev_blog"></div></div>';
								$('additional_comments').innerHTML = old_comments;
								$('comments_form').reset();
								send_comment = false;
							}
						$('comment').select();
					}
				});
			}
		}
	}

}

function deleteComment(comment_id){
		var url = 'ajax_blogs.php?cmd=delete_comment&comment_id='+comment_id;
		var requestData = new Ajax.Request(url,{
		method: 'get',
			onSuccess: function(transport) {
					document.getElementById(comment_id).style.display = 'none';
					$('errors_messages').innerHTML = '';
					$('errors_messages').style.display = 'block';
					var errors_str = '';
					var i = 0;
					 errors_str = '<div class="ok_message" style="width:180px;">	Comment has been deleted. </div><div style="height:5px;">&nbsp;</div>';
					$('errors_messages').innerHTML = errors_str;
			}
		});
}


// Donations Functionality
function showDonationForm(show, don_id, amount){
	if(show == 'on'){
		$('donation_container').style.display = "none";
		$('donation_form').style.display = "block";
		if(amount){
			var url = 'donations.php?cmd=get_form&donation_id='+don_id+'&amount='+amount;
		}else{
			var url = 'donations.php?cmd=get_form&donation_id='+don_id;
		}
			var requestData = new Ajax.Request(url,{
			method: 'get',
				onSuccess: function(transport, json) {
					$('donation_form').innerHTML = json.data;
				}
			});
	}else{
		$('donation_container').style.display = "block";
		$('donation_form').style.display = "none";
	}
	$('errors_messages').style.display = "none";
}
function submitDonation(){
				var data = $('payment_form').serialize();
				var url 	    = 'donations.php?'+data;
				var requestData = new Ajax.Request(url,{
				method: 'get',
					onSuccess: function(transport, json) {
						$('errors_messages').style.display = "block";
						var errors_str ='';
						if(json.is_error == true){
							for(var i =0; i < json.messages.size() ; i++){
								 errors_str += '<div class="errors" >	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
							}
							$('errors_messages').innerHTML = errors_str;
						}else{
							$('errors_messages').style.display = "block";
							 errors_str = '<div class="ok_message">	'+json.messages[0]+'</div><div style="height:5px;">&nbsp;</div>';
							$('donation_container').style.display = "block";
							$('donation_form').style.display = "none";
							$('errors_messages').innerHTML = errors_str;
						}
					}
				});
}

// Blog User login by link
function getLoginWindowErrBlog(show){
	$('errors_messages').style.display = 'none';
	if(clinician_login == false){
		if(show == 'show'){
			$('hide_all').style.display = 'block';
			$('hide_all_2').style.height = '1200px'; //document.height+'px';
			$('hide_all_2').style.display = 'block';
			$('content_view_blog').style.display = 'none';
		    $('forgot_password_box').style.display = '';
			new Ajax.Updater('forgot_password_box', 'ajax_login.php?cmd=get_login_error_form_blog'	);
		}
		if(show == 'close'){
			location = 'index.php';
		}
		if(show == 'hide'){
			$('content_view_blog').style.display = 'block';
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
			$('forgot_password_box').innerHTML = '';
			$('forgot_password_box').style.display = 'none';
		}
	}else{
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
			$('forgot_password_box').innerHTML = '';
			$('forgot_password_box').style.display = 'none';
			$('content_view_blog').style.display = 'block';
	}
}

function submitLoginFormModalBlog(){
	var data = $('login_users_modal').serialize();
	var url = 'ajax_login.php?'+data;
	var requestData = new Ajax.Request(url,{
	method: 'get',
		onSuccess: function(transport, json) {
			if(json.is_error == true){
			$('login_errors_box').style.display = '';
				var errors_str = '';
				var i = 0;
				for(i; i < json.messages.size() ; i++){
					 errors_str += '<div class="errors" style="width: 380px;">	'+json.messages[i]+'</div><div style="height:5px;">&nbsp;</div>';
				}
				if(i ==1){
					var new_height = 150 + 120;
					var new_height_2 = 125 + 120;
				}else{
					var new_height = 150 + (i*70);
					var new_height_2 = 125 + (i*70);
				}
				$('outBox_modal').style.height = new_height+'px';
				$('innerBox_modal').style.height = new_height_2+'px';

				$('login_errors_box').innerHTML = errors_str;
			    var login = $('login_modal').value;
			    $('login_users_modal').reset();
			    $('login_modal').value = login;
			    $('main_conteiner_errors_ok').style.display= 'none';
			    $('main_conteiner_errors').style.display= 'none';
			}else{
				if(json.target){
					location = json.target;
				}
				var cmd 			= getURLParam('cmd');
				var page_id 	= getURLParam('page_id');
				if(cmd != null && page_id != null){
					var url_question = 'ajax_user_questions.php?cmd='+cmd+'&page_id='+page_id;
					var requestData_Question = new Ajax.Request(url_question,{
					method: 'get',
						onSuccess: function(transport) {
							$('users_questions').innerHTML = transport.responseText;
						}
					});
				}
				clinician_login = true;
				$('login_box').style.display = 'none';
				$('errors_messages').style.display = 'none';
				$('login_user_box').style.display = '';
				$('login_user_box').innerHTML = '<span class="text_grey_10">Welcome, <span class="text_orange_10">'+json.username+'</span><br /><a href="blogs.php" class="text_orange_10">Manage Blogs</a> <br /> Now you are logged in&nbsp;|&nbsp;<a href="logout.php" class="text_orange_10">Logout</a> <br /> <input type="image" style="padding-top:5px;" src="images/btn_editaccount.gif" onclick="getEditAccount(true); return false;" />';
				if($('main_conteiner_errors_ok')){
					$('main_conteiner_errors_ok').style.display = 'none';
				}
				if($('main_conteiner_errors')){
					$('main_conteiner_errors').style.display = 'none';
				}
				if($('right_box_question_id')){
					$('right_box_question_id').style.display = 'none';
				}
				getLoginWindowErrBlog('hide');
			}
		}
	});
}


// Add New Blog Window
function getWindowAddBlog(show, type, page_id){
	//	alert(h);
	if(show == true){
			if($('fmpContainer1')){
				$('fmpContainer1').style.display = 'none';
			}
			if($('audioplayer')){
				$('audioplayer').style.display = 'none';
			}
			var h = $('my_body').getHeight();
			$('my_body').scrollTo();
			$('hide_all').style.display = 'block';
			$('hide_all_2').style.height = h+'px';
			$('hide_all_2').style.display = 'block';
		    $('forgot_password_box').style.display = '';
			new Ajax.Updater('forgot_password_box', 'ajax_blogs.php?cmd=get_form_blog&type='+type+'&page_id='+page_id);
	}else{
				if($('fmpContainer1')){
				$('fmpContainer1').style.display = 'block';
			}
			if($('audioplayer')){
				$('audioplayer').style.display = 'block';
			}
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
		    $('forgot_password_box').style.display = 'none';
		    $('right_box_question').scrollTo();

	}
}

function addNewBlog(){

	if($('comment').value.length > 255){
			$('outBox').style.height = 275+'px';
			$('innerBox').style.height = 250+'px';
			$('errors_messages_add_blog').style.display = '';
			$('errors_messages_add_blog').innerHTML = '<div class="errors" style="width:280px;">	Question/Title text should be within 255 symbols. </div><div style="height:5px;">&nbsp;</div>';
	}else{
		if($('comment').value == ''){
			$('outBox').style.height = 275+'px';
			$('innerBox').style.height = 250+'px';
			$('errors_messages_add_blog').style.display = '';
			$('errors_messages_add_blog').innerHTML = '<div class="errors" style="width:280px;">	Question/Title must be entered. </div><div style="height:5px;">&nbsp;</div>';
		}else{
				var data = $('add_new_blog_form').serialize();
				var url = 'ajax_blogs.php?'+data;
				var requestData = new Ajax.Request(url,{
				method: 'get',
					onSuccess: function(transport, json) {
							if(json.is_error == true){
								$('outBox').style.height = 275+'px';
								$('innerBox').style.height = 250+'px';

								$('errors_messages_add_blog').style.display = '';
								$('errors_messages_add_blog').innerHTML = '<div class="errors" style="width:280px;">'+json.data.messages+'</div>';
							}else{
								getWindowAddBlog(false, null, null);
								if($('no_questions')){
									$('no_questions').style.display = 'none';
								}
								$('errors_messages_add_blog').innerHTML = '';
								$('errors_messages_add_blog').style.display = 'none';
								var height = $('right_box_question').getHeight();
								height = height+100;
								$('right_box_question').style.height = height+'px';

								var height = $('right_box_question_1').getHeight();
								height = height+100;
								$('right_box_question_1').style.height = height+'px';

								var height = $('right_box_question_2').getHeight();
								height = height+60;
								$('right_box_question_2').style.height = height+'px';

			//					var height = $('right_box_question_3').getHeight();
			//					height = height+60;
			//					$('right_box_question_3').style.height = height+'px';

				//				var height = $('right_box_question_4').getHeight();
				//				height = height+60;
				//				$('right_box_question_4').style.height = height+'px';

								var old_blogs = $('additional_question').innerHTML;
								$('additional_question').innerHTML = old_blogs+ '<div style="width:190px; float:left;">'+json.data.question+'</div><div style="width: 80px; float:right; text-align:center;"><a href="view_blog.php?blog_id='+json.data.blog_id+'&page_id='+json.data.page_id+'&type='+json.data.type+'&question_id='+json.data.question_id+'">View Blog</a></div><div style="padding-top:40px;" class="del_4"></div>';
							}
					}
				});
		}
	}

}


// Add New EVENT Window
function getWindowAddEvent(show, eid){
	//	alert(h);
	if(show == true){
			$('errors_messages').style.display = 'none';
			if($('fmpContainer1')){
				$('fmpContainer1').style.display = 'none';
			}
			if($('audioplayer')){
				$('audioplayer').style.display = 'none';
			}
			$('hide_all').style.display = 'block';
			$('hide_all_2').style.height = 1000+'px';
			$('hide_all_2').style.display = 'block';
		    $('event_box').style.display = '';
			new Ajax.Updater('event_box', 'ajax_user_event.php?cmd=get_event_form&eid='+eid);
	}else{
				if($('fmpContainer1')){
				$('fmpContainer1').style.display = 'block';
			}
			if($('audioplayer')){
				$('audioplayer').style.display = 'block';
			}
			$('hide_all').style.display = 'none';
			$('hide_all_2').style.display = 'none';
		    $('event_box').style.display = 'none';
		 //   $('right_box_question').scrollTo();

	}
}


function submitEvent(){
	var data = $('ajax_event_form').serialize();
				var url = 'ajax_user_event.php?'+data;
				var requestData = new Ajax.Request(url,{
				method: 'get',
					onSuccess: function(transport, json) {
							if(json.is_error == true){
								var errors = '';
								for(var i=0; i<json.count; i++){
									errors +='<div class="errors" style="width:280px;">'+json.messages[i]+'</div><div style="height:5px;"></div>';
								}
								var out_height = 490+i*65;
								var in_height = 466+i*65;
								$('errors_messages').style.display = '';
								$('errors_messages').innerHTML = errors;
							}else{
								$('errors_messages').innerHTML = '';
								$('errors_messages').style.display = 'none';
								errors_str = '<div class="ok_message" >	Your request has been sent. </div><div style="height:5px;">&nbsp;</div>';
								$('errors_messages').style.display = 'block';
								$('errors_messages').innerHTML = errors_str;
								$('ajax_event_form').reset();
								//getWindowAddEvent(false);
						}
					}
			});
}