function mngl_request_friend( mingle_url, user_id, friend_id, friend_requested_text )
{
  mngl_replace_id_with_loading_indicator('friend_request_button-' + friend_id);
  jQuery.ajax( {
    type: "POST",
    url: mingle_url,
    data: "controller=friends&action=friend_request&user_id=" + user_id + "&friend_id=" + friend_id,
    success: function(html) {
      jQuery("#friend_request_button-" + friend_id ).replaceWith( friend_requested_text );
    }
  });
}

function mngl_escape(message)
{
  // escape problematic characters -- don't escape utf8 chars
  return message.replace(/&/g,'%26').replace(/=/g,'%3D').replace(/ /g, '%20').replace(/\?/g, '%3F');
}

function mngl_post_to_board( mingle_url, owner_id, author_id, message, controller )
{  
  var mnglparams = jQuery('#mngl-board-post-button').attr('mnglparams');
  mngl_replace_id_with_loading_indicator('mngl-board-post-button');
  
  if(mnglparams==undefined)
  {
    mnglparams = '';
  }

  jQuery.ajax( {
    type: "POST",
    url: mingle_url,
    data: "controller=" + controller + "&action=post&owner_id=" + owner_id + "&author_id=" + author_id + "&message=" + mngl_escape(message) + mnglparams,
    success: function(html) {
      jQuery('.mngl-board').replaceWith('<div class="mngl-board">'+html+'</div>');
      mngl_load_growables();
    }
  });
}

function mngl_clear_status(user_id)
{
  mngl_replace_id_with_loading_indicator('mngl-clear-status-button');
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=boards&action=clear_status&u=" + user_id,
    success: function(html) {
      jQuery('.mngl-profile-status').slideUp();
    }
  });
}

function mngl_show_older_posts( pagenum, loc, screenname )
{
  mngl_replace_id_with_loading_indicator('mngl-older-posts');
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=boards&action=older_posts&mdp=" + pagenum + "&loc=" + loc + "&u=" + screenname,
    success: function(html) {
      jQuery('#mngl-older-posts').replaceWith(html);
      mngl_load_growables();
    }
  });
}

function mngl_comment_on_post( mingle_url, author_id, board_post_id, message, controller )
{
  mngl_replace_id_with_loading_indicator('mngl-comment-button-' + board_post_id);
  jQuery.ajax( {
    type: "POST",
    url: mingle_url,
    data: "controller=" + controller + "&action=comment&author_id=" + author_id + "&board_post_id=" + board_post_id + "&message=" + mngl_escape(message),
    success: function(html) {
      jQuery('#mngl-comment-form-wrap-'+board_post_id).replaceWith(html);
      mngl_load_growables();
      jQuery("#mngl-board-comment-list-" + board_post_id).show();
      jQuery("#mngl-fake-board-comment-" + board_post_id).show();
    }
  });
}

function mngl_delete_board_post( mingle_url, board_post_id, controller )
{
  if(confirm("Are you sure you want to delete this post?"))
  {
    jQuery.ajax( {
      type: "POST",
      url: mingle_url,
      data: "controller=" + controller + "&action=delete_post&board_post_id=" + board_post_id,
      success: function(html) {
        jQuery('#mngl-board-comment-list-' + board_post_id).slideUp();
        jQuery('.mngl-board-post-' + board_post_id).slideUp();
      }
    });
  }
}

function mngl_delete_board_comment( mingle_url, board_comment_id, controller )
{
  if(confirm("Are you sure you want to delete this comment?"))
  {
    jQuery.ajax( {
      type: "POST",
      url: mingle_url,
      data: "controller=" + controller + "&action=delete_comment&board_comment_id=" + board_comment_id,
      success: function(html) {
        jQuery('#mngl-board-comment-' + board_comment_id).slideUp();
      }
    });
  }
}

function mngl_toggle_comment_form( update_id )
{
  jQuery('#mngl-board-comment-list-' + update_id).show();
  jQuery('#mngl-comment-form-' + update_id).toggle();
  jQuery('#mngl-fake-board-comment-' + update_id).toggle();
  jQuery('#mngl-board-comment-input-' + update_id).focus();
}

function mngl_show_board_post_form()
{
  jQuery('#mngl-fake-board-post-form').toggle();
  jQuery('#mngl-board-post-form').toggle();
  jQuery('#mngl-board-post-input').focus();
}

function mngl_toggle_hidden_comments(board_post_id)
{
  jQuery('.mngl-hidden-comment-'+board_post_id).show();
  jQuery('#mngl-show-hidden-comments-'+board_post_id).hide();
}

function mngl_delete_friend( mingle_url, user_id, friend_id )
{
  if(confirm("Are you sure you want to delete this friend?"))
  {
    jQuery.ajax( {
      type: "POST",
      url: mingle_url,
      data: "controller=friends&action=delete_friend&user_id=" + user_id + "&friend_id=" + friend_id,
      success: function(html) {
        jQuery('#mngl-friend-'+friend_id).slideUp();
      }
    });
  }
}

function mngl_accept_friend_request( mingle_url, request_id, requestor_name )
{
  mngl_replace_id_with_loading_indicator('request-' + request_id);
  jQuery.ajax( {
    type: "POST",
    url: mingle_url,
    data: "controller=friends&action=accept_friend&request_id=" + request_id,
    success: function(html) {
      jQuery( '#request-' + request_id ).replaceWith( 'You\'re now friends with ' + requestor_name );
    }
  });
}

function mngl_ignore_friend_request( mingle_url, request_id )
{
  mngl_replace_id_with_loading_indicator('request-' + request_id);
  jQuery.ajax( {
    type: "POST",
    url: mingle_url,
    data: "controller=friends&action=ignore_friend&request_id=" + request_id,
    success: function(html) {
      jQuery( '#request-' + request_id ).slideUp();
    }
  });
}

function mngl_search_directory( search_query )
{
  mngl_replace_id_with_loading_indicator('mngl-profile-results');
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "&controller=profile&action=search&q=" + search_query,
    success: function(html) {
      jQuery( '#mngl-profile-results' ).replaceWith(html);
      if( search_query != '' )
      {
        jQuery( '.mngl-search-reset-button' ).show();
      }
      else
      {
        jQuery( '.mngl-search-reset-button' ).hide();
      }
    }
  });
}

function mngl_search_friends( search_query, page_params )
{
  mngl_replace_id_with_loading_indicator('mngl-friends-directory');
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "&controller=friends&action=search&q=" + search_query + page_params,
    success: function(html) {
      jQuery( '#mngl-friends-directory' ).replaceWith(html);
    }
  });
}
function mngl_delete_profile_avatar( mingle_url, user_id )
{
  if(confirm("Are you sure you want to delete your avatar?"))
  {
    jQuery.ajax( {
      type: "POST",
      url: mingle_url,
      data: "controller=profile&action=delete_avatar&user_id=" + user_id,
      success: function(html) {
        jQuery('#mngl-avatar-edit-display').replaceWith(html);
      }
    });
  }
}

function mngl_toggle_two_ids( first_id, second_id )
{
  jQuery(first_id).toggle();
  jQuery(second_id).toggle();
}

function mngl_show_search_form()
{
  jQuery('#mngl-fake-search-form').hide();
  jQuery('#mngl-search-form').show();
  jQuery('#mngl-search-input').focus();
}

function mngl_remove_tag( html_tag )
{
  jQuery( html_tag ).remove();
}

function mngl_add_default_user()
{
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=options&action=add_default_user",
    success: function(html) {
      jQuery('.mngl-default-friends-table').append(html);
    }
  });
}

function mngl_replace_id_with_loading_indicator(tagname)
{
  jQuery('#'+tagname).replaceWith('<img id="' + tagname + '" src="http://tooserious.net/wp-content/plugins/mingle/images/ajax-loader.gif" alt="Loading..." />');
}

function mngl_replace_class_with_loading_indicator(tagname)
{
  jQuery('.'+tagname).replaceWith('<img class="' + tagname + '" src="http://tooserious.net/wp-content/plugins/mingle/images/ajax-loader.gif" alt="Loading..." />');
}

function mngl_load_growables()
{
  jQuery(".mngl-growable-hidden").show();
  jQuery(".mngl-growable").elastic();
  jQuery(".mngl-growable-hidden").hide();
}

function mngl_show_tooltip( tooltip_content, tooltip_element )
{
  jQuery(tooltip_element).qtip({
    content: tooltip_content
  });
}

function mngl_set_active_tab( tab )
{
  jQuery('#mngl-profile-tab-control li').removeClass('mngl-active-profile-tab');
  jQuery('#mngl-' + tab + '-tab-button').addClass('mngl-active-profile-tab');
  jQuery('.mngl-profile-tab').hide();
  jQuery('#mngl-' + tab + '-tab').show();
}

function mngl_mailer_options()
{
  if( jQuery('#mngl_mailer-type').val() == 'smtp' )
  {
    jQuery('#mngl-sendmail-form').slideUp( 'normal', function() {
      jQuery('#mngl-smtp-form').slideDown();
    } );
  }
  else if( jQuery('#mngl_mailer-type').val() == 'sendmail' )
  {
    jQuery('#mngl-smtp-form').slideUp( 'normal', function() {
      jQuery('#mngl-sendmail-form').slideDown();
    } );
  }
  else
  {
    jQuery('#mngl-sendmail-form').slideUp();
    jQuery('#mngl-smtp-form').slideUp();
  }
}

function mngl_center_image( curr_obj )
{
  var obj_height = jQuery( curr_obj ).height();
  var img_height = jQuery( curr_obj ).find('img').height();
  
  var img_tb_margin = (obj_height - img_height) / 2;
  
  //alert( "obj height: " + obj_height + " img height: " + img_height + " img_tb_margin " + img_tb_margin );
  
  jQuery( curr_obj ).find('img').css('margin-top', img_tb_margin);
  jQuery( curr_obj ).find('img').css('margin-bottom', img_tb_margin);
}

function mngl_add_field( field_index )
{
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=options&action=add_custom_field&index=" + field_index,
    success: function(html) {
      jQuery('#mngl-add-button').replaceWith(html);
    }
  });
}

function mngl_add_field_option( field_index, option_index )
{
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=options&action=add_custom_field_option&field_index=" + field_index + "&option_index=" + option_index,
    success: function(html) {
      jQuery('#mngl-add-option-button-' + field_index).replaceWith(html);
    }
  });
}

function mngl_show_field_options( field_index, type )
{
  if(type == 'dropdown')
  {
    jQuery('#mngl_field_options_wrapper_' + field_index).show();
  }
  else
  {
    jQuery('#mngl_field_options_wrapper_' + field_index).hide();
  }
}

function mngl_reply_to_message( thread_id, message )
{
  jQuery('#mngl_reply_button').toggle();
  jQuery('#mngl_reply_loading').toggle();
  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=messages&action=mngl_process_reply_form&mngl_thread_id=" + thread_id + "&mngl_reply=" + mngl_escape(message),
    success: function(html) {
      jQuery('#mngl_messages_table').append(html);
      jQuery('#mngl_reply').val(''); // clear the textarea
      jQuery('#mngl_reply').elastic();
      jQuery('#mngl_reply_button').toggle();
      jQuery('#mngl_reply_loading').toggle();
    }
  });
}

function mngl_delete_thread( thread_id )
{
  if(confirm('Are you sure you want to delete this message?'))
  {
    jQuery.ajax( {
      type: "POST",
      url: 'http://tooserious.net/index.php?plugin=mingle',
      data: "controller=messages&action=delete_thread&t=" + thread_id,
      success: function(html) {
        jQuery('#mngl_thread_' + thread_id).fadeOut('slow');
      }
    });
  }
}

function mngl_bulk_action()
{
  var action = jQuery('#mngl_message_actions').val();
  
  if(action == 'delete_threads')
  {
    if(!confirm('Are you sure you want to delete these messages?'))
    {
      return;
    }
  }

  var thread_ids = jQuery(".mngl_message_checkbox:checked").map(function(){
                     return jQuery(this).val();
                   }).get();

  jQuery.ajax( {
    type: "POST",
    url: 'http://tooserious.net/index.php?plugin=mingle',
    data: "controller=messages&action=" + action + "&ts=" + thread_ids.join(","),
    success: function(html) {
      if(action=='delete_threads')
      {
        jQuery('.mngl_message_checkbox:checked').parent().parent().fadeOut('slow');
      }
      else if(action=='mark_unread')
      {
        jQuery('.mngl_message_checkbox:checked').parent().parent().children().css('background-color','lightgray');
      }
      else if(action=='mark_read')
      {
        jQuery('.mngl_message_checkbox:checked').parent().parent().children().css('background-color','white');
      }
      
      jQuery('.mngl_message_checkbox:checked').removeAttr('checked');
    }
  });
}

function mngl_toggle_message_composer()
{
  jQuery('#mngl_message_composer').slideToggle();
}

jQuery(document).ready(function() {
  mngl_load_growables();


  jQuery(".mngl-datepicker").datepicker({ dateFormat: 'MM d, yy', changeMonth: true, changeYear: true, firstDay: 0, monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'], monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'], dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], isRTL: false, minDate: '-100y', maxDate: '+5y', yearRange: '-100y:+5y' });
  
  // By suppling no content attribute, the library uses each elements title attribute by default

  jQuery('.mngl-grid-cell a').each(function()
  {
    jQuery(this).qtip({
      content: {
        text: jQuery(this).parent().attr('rel')
      },
      position: {
        corner: {
          target: 'bottomMiddle',
          tooltip: 'topMiddle'
        }
      },
      style: {
        border: {
            width: 5,
            radius: 5
        },
        padding: 5, 
        textAlign: 'center',
        tip: true
      }
    });
  });
});

	/*
   Plugin Name: Comment Rating
	Plugin URI: http://wealthynetizen.com/wordpress-plugin-comment-rating/
	Description: Allows visitors to rate the comments on your blog in a Like vs. Dislike fashion.  Clickable images and ratings are automatically inserted into each comment.  Comments disliked too much by readers will be hidden in a click-to-show link. 
	Author: Bob King
	Author URI: http://wealthynetizen.com
	Version: 2.3.2
	*/ 

	/*
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	*/

function ckratingcreateXMLHttpRequest(){
    var xmlhttp = null;
    try {
        // Moz supports XMLHttpRequest. IE uses ActiveX.
        // browser detction is bad. object detection works for any browser
        xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
        // browser doesn’t support ajax. handle however you want
        //document.getElementById("errormsg").innerHTML = "Your browser doesnt support XMLHttpRequest.";
        // This won't help ordinary users.  Turned off
        // alert("Your browser does not support the XMLHttpRequest Object!");
    }
    return xmlhttp;
}

var ckratingXhr = ckratingcreateXMLHttpRequest();

function ckratingKarma(id, action, path, imgIndex){
    ckratingXhr.open('get', 'http\://'+ path +'ck-processkarma.php?id='+ id +'&action='+ action +'&path='+ path +'&imgIndex='+imgIndex);
    ckratingXhr.onreadystatechange = ckratingHandleResponse;
    ckratingXhr.send(null);
}

function ckratingHandleResponse(){
    if(ckratingXhr.readyState == 4){
        var response = ckratingXhr.responseText.split('|');
        
        if(response[0] == 'done'){
            if(response[1]){
                //Changes the thumbs to dull gray and disable the action
                if (response[4] == 'down') {
                  if ( document.getElementById("down-"+response[1]) != null ) { 
                      document.getElementById("down-"+response[1]).src = "http://"+response[3]+'images/'+response[6]+'checkmark.png';
                  }
                }
                else {
                  if ( document.getElementById("down-"+response[1]) != null ) {
                      document.getElementById("down-"+response[1]).src = "http://"+response[3]+'images/'+response[6]+'gray_down.png';
                  }
                }
                if ( document.getElementById("down-"+response[1]) != null ) {
                   document.getElementById("down-"+response[1]).onclick    = '';
                }
                if (response[4] == 'up') {
                   if ( document.getElementById("up-"+response[1]) != null ) {
                      document.getElementById("up-"+response[1]).src   = "http://"+response[3]+'images/'+response[6]+'checkmark.png';
                   }
                }
                else {
                   if ( document.getElementById("up-"+response[1]) != null ) {
                      document.getElementById("up-"+response[1]).src   = "http://"+response[3]+'images/'+response[6]+'gray_up.png';
                   }
                }
                if ( document.getElementById("up-"+response[1]) != null ) {
                   document.getElementById("up-"+response[1]).onclick      = '';
                }
                //Update the karma number display
                if(!response[2]){
                	alert("Response has no value");
                }
                var karmanumber = response[2];
                //The below line is commented out because there is no karma number atm.
                if (document.getElementById("karma-"+response[1]+"-"+response[4]) != null) {
                   document.getElementById("karma-"+response[1]+"-"+response[4]).innerHTML = karmanumber;
                }
                // deal with the single value total
                if (document.getElementById("karma-"+response[1]+"-total") != null) {
                   document.getElementById("karma-"+response[1]+"-total").innerHTML = response[5];
                }
            } else {
                alert("WTF ?");
            }
        }
        else if(response[0] == 'error')
        {
            var error = 'Error: '+response[1];
            alert(error);
        } else {
           /*  This causes unnecessary error messages when the icon
            *  is double clicked.
        	   alert("Reponse: "+response[0]);
            alert("Karma not changed, please try again later.");
            */
        }
    }
}

var crToggleComment = 0;

function crSwitchDisplay(id) {
   if (crToggleComment % 2 == 0) { crShowdiv(id); }
   else { crHidediv(id); }
   crToggleComment++;
}

// hide <div id='a2' style="display:none;"> tagged div ID blocks
function crHidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

// show <div id='a2' style="display:none;"> tagged div ID blocks
// <a href="javascript:crShowdiv('a2');">show a2</a>

function crShowdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

	/*
   Plugin Name: Comment Rating
	Plugin URI: http://wealthynetizen.com/wordpress-plugin-comment-rating/
	Description: Allows visitors to rate the comments on your blog in a Like vs. Dislike fashion.  Clickable images and ratings are automatically inserted into each comment.  Comments disliked too much by readers will be hidden in a click-to-show link. 
	Author: Bob King
	Author URI: http://wealthynetizen.com
	Version: 2.3.2
	*/ 

	/*
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	*/

function ckratingcreateXMLHttpRequest(){
    var xmlhttp = null;
    try {
        // Moz supports XMLHttpRequest. IE uses ActiveX.
        // browser detction is bad. object detection works for any browser
        xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
        // browser doesn’t support ajax. handle however you want
        //document.getElementById("errormsg").innerHTML = "Your browser doesnt support XMLHttpRequest.";
        // This won't help ordinary users.  Turned off
        // alert("Your browser does not support the XMLHttpRequest Object!");
    }
    return xmlhttp;
}

var ckratingXhr = ckratingcreateXMLHttpRequest();

function ckratingKarma(id, action, path, imgIndex){
    ckratingXhr.open('get', 'http\://'+ path +'ck-processkarma.php?id='+ id +'&action='+ action +'&path='+ path +'&imgIndex='+imgIndex);
    ckratingXhr.onreadystatechange = ckratingHandleResponse;
    ckratingXhr.send(null);
}

function ckratingHandleResponse(){
    if(ckratingXhr.readyState == 4){
        var response = ckratingXhr.responseText.split('|');
        
        if(response[0] == 'done'){
            if(response[1]){
                //Changes the thumbs to dull gray and disable the action
                if (response[4] == 'down') {
                  if ( document.getElementById("down-"+response[1]) != null ) { 
                      document.getElementById("down-"+response[1]).src = "http://"+response[3]+'images/'+response[6]+'checkmark.png';
                  }
                }
                else {
                  if ( document.getElementById("down-"+response[1]) != null ) {
                      document.getElementById("down-"+response[1]).src = "http://"+response[3]+'images/'+response[6]+'gray_down.png';
                  }
                }
                if ( document.getElementById("down-"+response[1]) != null ) {
                   document.getElementById("down-"+response[1]).onclick    = '';
                }
                if (response[4] == 'up') {
                   if ( document.getElementById("up-"+response[1]) != null ) {
                      document.getElementById("up-"+response[1]).src   = "http://"+response[3]+'images/'+response[6]+'checkmark.png';
                   }
                }
                else {
                   if ( document.getElementById("up-"+response[1]) != null ) {
                      document.getElementById("up-"+response[1]).src   = "http://"+response[3]+'images/'+response[6]+'gray_up.png';
                   }
                }
                if ( document.getElementById("up-"+response[1]) != null ) {
                   document.getElementById("up-"+response[1]).onclick      = '';
                }
                //Update the karma number display
                if(!response[2]){
                	alert("Response has no value");
                }
                var karmanumber = response[2];
                //The below line is commented out because there is no karma number atm.
                if (document.getElementById("karma-"+response[1]+"-"+response[4]) != null) {
                   document.getElementById("karma-"+response[1]+"-"+response[4]).innerHTML = karmanumber;
                }
                // deal with the single value total
                if (document.getElementById("karma-"+response[1]+"-total") != null) {
                   document.getElementById("karma-"+response[1]+"-total").innerHTML = response[5];
                }
            } else {
                alert("WTF ?");
            }
        }
        else if(response[0] == 'error')
        {
            var error = 'Error: '+response[1];
            alert(error);
        } else {
           /*  This causes unnecessary error messages when the icon
            *  is double clicked.
        	   alert("Reponse: "+response[0]);
            alert("Karma not changed, please try again later.");
            */
        }
    }
}

var crToggleComment = 0;

function crSwitchDisplay(id) {
   if (crToggleComment % 2 == 0) { crShowdiv(id); }
   else { crHidediv(id); }
   crToggleComment++;
}

// hide <div id='a2' style="display:none;"> tagged div ID blocks
function crHidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

// show <div id='a2' style="display:none;"> tagged div ID blocks
// <a href="javascript:crShowdiv('a2');">show a2</a>

function crShowdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


/*!
* jquery.qtip. The jQuery tooltip plugin
*
* Copyright (c) 2009 Craig Thompson
* http://craigsworks.com
*
* Licensed under MIT
* http://www.opensource.org/licenses/mit-license.php
*
* Launch  : February 2009
* Version : 1.0.0-rc3
* Released: Tuesday 12th May, 2009 - 00:00
* Debug: jquery.qtip.debug.js
*/
eval(
function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('"6n 6m";(h($){$(3Q).3J(h(){U i;$(27).1K(\'3S 3V\',h(r){1Q(i=0;i<$.1j.g.N.Q;i++){U V=$.1j.g.N[i];c(V&&V.T&&V.T.1b&&V.8.o.17!==\'2b\'&&(V.8.o.1e.3V&&r.17===\'3V\'||V.8.o.1e.3S&&r.17===\'3S\')){V.26(r,G)}}});$(3Q).1K(\'5l.g\',h(r){c($(r.s).5p(\'12.g\').Q===0){$(\'.g[3p]\').1L(h(){U V=$(w).g(\'V\');c($(w).30(\':2x\')&&V&&V.T&&!V.T.1Y&&$(r.s).2h(V.d.s).Q>1){V.C(r)}})}})});h 2H(u){c(!u){B p}w.x=5U(u).2P(/5Z/i,\'1g\').62(/P|21|1g/i)[0].2F();w.y=5U(u).2P(/5Z/i,\'1g\').62(/L|24|1g/i)[0].2F();w.1s={P:0,L:0};w.2J=(u.2y(0).6f(/^(t|b)/)>-1)?\'y\':\'x\';w.1z=h(){B(w.2J===\'y\')?w.y+w.x:w.x+w.y}}h 4r(u,k,F){U 1O={5S:[[0,0],[k,F],[k,0]],5J:[[0,0],[k,0],[0,F]],5I:[[0,F],[k,0],[k,F]],64:[[0,0],[0,F],[k,F]],6j:[[0,F],[k/2,0],[k,F]],6h:[[0,0],[k,0],[k/2,F]],6s:[[0,0],[k,F/2],[0,F]],6K:[[k,0],[k,F],[0,F/2]]};1O.6v=1O.5S;1O.6P=1O.5J;1O.6N=1O.5I;1O.6F=1O.64;B 1O[u]}h 3Z(E){U 2t;c($(\'<1c />\').1q(0).1G){2t={3R:[E,E],3Y:[0,E],4k:[E,0],3T:[0,0]}}D c($.14.1d){2t={3R:[-2Q,2Q,0],3Y:[-2Q,2Q,-E],4k:[2Q,5R,0],3T:[2Q,5R,-E]}}B 2t}h 2z(e,40){U 2R,i;2R=$.2s(G,{},e);1Q(i 67 2R){c(40===G&&(/(f|1f)/i).28(i)){3x 2R[i]}D c(!40&&(/(k|H|f|R|1f|4O)/i).28(i)){3x 2R[i]}}B 2R}h 4A(e){c(O e.f!==\'18\'){e.f={u:e.f}}c(O e.f.M!==\'18\'){e.f.M={k:e.f.M,F:e.f.M}}c(O e.H!==\'18\'){e.H={k:e.H}}c(O e.k!==\'18\'){e.k={39:e.k}}c(O e.k.1J===\'1z\'){e.k.1J=1y(e.k.1J.2P(/([0-9]+)/i,"$1"),10)}c(O e.k.2f===\'1z\'){e.k.2f=1y(e.k.2f.2P(/([0-9]+)/i,"$1"),10)}c(O e.f.M.x===\'2g\'){e.f.M.k=e.f.M.x;3x e.f.M.x}c(O e.f.M.y===\'2g\'){e.f.M.F=e.f.M.y;3x e.f.M.y}B e}h 4z(){U 7,i,3w,2j,1B,1S;7=w;3w=[G,{}];1Q(i=0;i<44.Q;i++){3w.5s(44[i])}2j=[$.2s.68($,3w)];6E(O 2j[0].1V===\'1z\'){2j.5O(4A($.1j.g.32[2j[0].1V]))}2j.5O(G,{1f:{j:\'g-\'+(44[0].1V||\'33\')}},$.1j.g.32.33);1B=$.2s.68($,2j);1S=($.14.1d)?1:0;1B.f.M.k+=1S;1B.f.M.F+=1S;c(1B.f.M.k%2>0){1B.f.M.k+=1}c(1B.f.M.F%2>0){1B.f.M.F+=1}c(1B.f.u===G){c(7.8.o.u.j===\'1g\'&&7.8.o.u.s===\'1g\'){1B.f.u=p}D{1B.f.u=7.8.o.u.j}}B 1B}h 43(1c,X,E,I){U 1n=1c.1q(0).1G(\'2d\');1n.4U=I;1n.59();1n.3m(X[0],X[1],E,0,1t.6G*2,p);1n.4R()}h 5z(){U 7,i,k,E,I,X,1M,M,45,2i,37,35,47,4l,4i;7=w;7.d.1u.1H(\'.g-35, .g-37\').3l();k=7.8.e.H.k;E=7.8.e.H.E;I=7.8.e.H.I||7.8.e.f.I;X=3Z(E);1M={};1Q(i 67 X){1M[i]=\'<12 1T="\'+i+\'" e="\'+((/6O/).28(i)?\'P\':\'21\')+\':0; \'+\'o:2X; F:\'+E+\'19; k:\'+E+\'19; 2k:1E; 2L-F:0.1F; 31-M:1F">\';c($(\'<1c />\').1q(0).1G){1M[i]+=\'<1c F="\'+E+\'" k="\'+E+\'" e="4c-3t: L"></1c>\'}D c($.14.1d){M=E*2+3;1M[i]+=\'<v:3m 5f="p" 3A="\'+I+\'" 6M="\'+X[i][0]+\'" 6L="\'+X[i][1]+\'" \'+\'e="k:\'+M+\'19; F:\'+M+\'19; 2l-L:\'+((/24/).28(i)?-2:-1)+\'19; \'+\'2l-P:\'+((/6H/).28(i)?X[i][2]-3.5:-1)+\'19; \'+\'4c-3t:L; 2a:5i-4b; 3P:1x(#2S#3L)"></v:3m>\'}1M[i]+=\'</12>\'}45=7.3b().k-(1t.1J(k,E)*2);2i=\'<12 1I="g-2i" e="F:\'+E+\'19; k:\'+45+\'19; \'+\'2k:1E; 1r-I:\'+I+\'; 2L-F:0.1F; 31-M:1F;">\';37=\'<12 1I="g-37" 4a="48" e="F:\'+E+\'19; \'+\'2l-P:\'+E+\'19; 2L-F:0.1F; 31-M:1F; 2O:0;">\'+1M.3R+1M.3Y+2i;7.d.1u.3D(37);35=\'<12 1I="g-35" 4a="48" e="F:\'+E+\'19; \'+\'2l-P:\'+E+\'19; 2L-F:0.1F; 31-M:1F; 2O:0;">\'+1M.4k+1M.3T+2i;7.d.1u.4X(35);c($(\'<1c />\').1q(0).1G){7.d.1u.1H(\'1c\').1L(h(){47=X[$(w).3v(\'[1T]:1U\').W(\'1T\')];43.S(7,$(w),47,E,I)})}D c($.14.1d){7.d.j.4X(\'<v:3I e="3P:1x(#2S#3L);"></v:3I>\')}4l=1t.1J(E,(E+(k-E)));4i=1t.1J(k-E,0);7.d.1A.J({H:\'6i 3s \'+I,6J:4i+\'19 \'+4l+\'19\'})}h 4q(1c,X,I){U 1n=1c.1q(0).1G(\'2d\');1n.4U=I;1n.59();1n.6I(X[0][0],X[0][1]);1n.4S(X[1][0],X[1][1]);1n.4S(X[2][0],X[2][1]);1n.4R()}h 4F(u){U 7,1S,25,4p,4o,3n;7=w;c(7.8.e.f.u===p||!7.d.f){B}c(!u){u=2v 2H(7.d.f.W(\'1T\'))}1S=25=($.14.1d)?1:0;7.d.f.J(u[u.2J],0);c(u.2J===\'y\'){c($.14.1d){c(1y($.14.38.2y(0),10)===6){25=u.y===\'L\'?-3:1}D{25=u.y===\'L\'?1:2}}c(u.x===\'1g\'){7.d.f.J({P:\'50%\',6D:-(7.8.e.f.M.k/2)})}D c(u.x===\'P\'){7.d.f.J({P:7.8.e.H.E-1S})}D{7.d.f.J({21:7.8.e.H.E+1S})}c(u.y===\'L\'){7.d.f.J({L:-25})}D{7.d.f.J({24:25})}}D{c($.14.1d){25=(1y($.14.38.2y(0),10)===6)?1:(u.x===\'P\'?1:2)}c(u.y===\'1g\'){7.d.f.J({L:\'50%\',3W:-(7.8.e.f.M.F/2)})}D c(u.y===\'L\'){7.d.f.J({L:7.8.e.H.E-1S})}D{7.d.f.J({24:7.8.e.H.E+1S})}c(u.x===\'P\'){7.d.f.J({P:-25})}D{7.d.f.J({21:25})}}4p=\'2O-\'+u[u.2J];4o=7.8.e.f.M[u.2J===\'x\'?\'k\':\'F\'];7.d.j.J(\'2O\',0).J(4p,4o);c($.14.1d&&1y($.14.38.2y(0),6)===6){3n=1y(7.d.f.J(\'2l-L\'),10)||0;3n+=1y(7.d.A.J(\'2l-L\'),10)||0;7.d.f.J({3W:3n})}}h 4e(u){U 7,I,X,3C,2n,f;7=w;c(7.d.f!==1w){7.d.f.3l()}I=7.8.e.f.I||7.8.e.H.I;c(7.8.e.f.u===p){B}D c(!u){u=2v 2H(7.8.e.f.u)}X=4r(u.1z(),7.8.e.f.M.k,7.8.e.f.M.F);7.d.f=\'<12 1I="\'+7.8.e.1f.f+\'" 4a="48" 1T="\'+u.1z()+\'" e="o:2X; \'+\'F:\'+7.8.e.f.M.F+\'19; k:\'+7.8.e.f.M.k+\'19; \'+\'2l:0 5K; 2L-F:0.1F; 31-M:1F;"></12>\';7.d.j.3D(7.d.f);c($(\'<1c />\').1q(0).1G){f=\'<1c F="\'+7.8.e.f.M.F+\'" k="\'+7.8.e.f.M.k+\'"></1c>\'}D c($.14.1d){3C=7.8.e.f.M.k+\',\'+7.8.e.f.M.F;2n=\'m\'+X[0][0]+\',\'+X[0][1];2n+=\' l\'+X[1][0]+\',\'+X[1][1];2n+=\' \'+X[2][0]+\',\'+X[2][1];2n+=\' 6Q\';f=\'<v:3B 3A="\'+I+\'" 5f="p" 6g="G" 2n="\'+2n+\'" 3C="\'+3C+\'" \'+\'e="k:\'+7.8.e.f.M.k+\'19; F:\'+7.8.e.f.M.F+\'19; \'+\'2L-F:0.1F; 2a:5i-4b; 3P:1x(#2S#3L); \'+\'4c-3t:\'+(u.y===\'L\'?\'24\':\'L\')+\'"></v:3B>\';f+=\'<v:3I e="3P:1x(#2S#3L);"></v:3I>\';7.d.1A.J(\'o\',\'4f\')}7.d.f=7.d.j.1H(\'.\'+7.8.e.1f.f).6q(0);7.d.f.2m(f);c($(\'<1c  />\').1q(0).1G){4q.S(7,7.d.f.1H(\'1c:1U\'),X,I)}c(u.y===\'L\'&&$.14.1d&&1y($.14.38.2y(0),10)===6){7.d.f.J({3W:-4})}4F.S(7,u)}h 5G(){U 7=w;c(7.d.R!==1w){7.d.R.3l()}7.d.j.W(\'3z-6o\',\'g-\'+7.Z+\'-R\');7.d.R=$(\'<12 Z="g-\'+7.Z+\'-R" 1I="\'+7.8.e.1f.R+\'"></12>\').J(2z(7.8.e.R,G)).J({2c:($.14.1d)?1:0}).5m(7.d.1A);c(7.8.A.R.1v){7.5T.S(7,7.8.A.R.1v)}c(7.8.A.R.1k!==p&&O 7.8.A.R.1k===\'1z\'){7.d.1k=$(\'<a 1I="\'+7.8.e.1f.1k+\'" 5r="1k" e="6u:21; o: 4f"></a>\').J(2z(7.8.e.1k,G)).2m(7.8.A.R.1k).5m(7.d.R).5k(h(r){c(!7.T.1Y){7.C(r)}})}}h 57(){U 7,3f,2o,3M;7=w;3f=7.8.q.K.s;2o=7.8.C.K.s;c(7.8.C.2W){2o=2o.2h(7.d.j)}3M=[\'5k\',\'6t\',\'5l\',\'79\',\'4E\',\'4J\',\'7G\',\'7F\',\'2Y\'];h 3K(r){c(7.T.1Y===G){B}2e(7.1D.1X);7.1D.1X=46(h(){$(3M).1L(h(){2o.1R(w+\'.g-1X\');7.d.A.1R(w+\'.g-1X\')});7.C(r)},7.8.C.2N)}c(7.8.C.2W===G){7.d.j.1K(\'2Y.g\',h(){c(7.T.1Y===G){B}2e(7.1D.C)})}h 42(r){c(7.T.1Y===G){B}c(7.8.C.K.r===\'1X\'){$(3M).1L(h(){2o.1K(w+\'.g-1X\',3K);7.d.A.1K(w+\'.g-1X\',3K)});3K()}2e(7.1D.q);2e(7.1D.C);c(7.8.q.2N>0){7.1D.q=46(h(){7.q(r)},7.8.q.2N)}D{7.q(r)}}h 3X(r){c(7.T.1Y===G){B}c(7.8.C.2W===G&&(/1N(7I|7K)/i).28(7.8.C.K.r)&&$(r.7J).5p(\'12.g[Z^="g"]\').Q>0){r.7E();r.7D();2e(7.1D.C);B p}2e(7.1D.q);2e(7.1D.C);7.d.j.3o(G,G);7.1D.C=46(h(){7.C(r)},7.8.C.2N)}c((7.8.q.K.s.2h(7.8.C.K.s).Q===1&&7.8.q.K.r===7.8.C.K.r&&7.8.C.K.r!==\'1X\')||7.8.C.K.r===\'3p\'){7.1i.2M=0;3f.1K(7.8.q.K.r+\'.g\',h(r){c(7.1i.2M===0){42(r)}D{3X(r)}})}D{3f.1K(7.8.q.K.r+\'.g\',42);c(7.8.C.K.r!==\'1X\'){2o.1K(7.8.C.K.r+\'.g\',3X)}}c((/(2W|2X)/).28(7.8.o.17)){7.d.j.1K(\'2Y.g\',7.2E)}c(7.8.o.s===\'1N\'&&7.8.o.17!==\'2b\'){3f.1K(\'4E.g\',h(r){7.1i.1N={x:r.4N,y:r.4D};c(7.T.1Y===p&&7.8.o.1e.1N===G&&7.8.o.17!==\'2b\'&&7.d.j.J(\'2a\')!==\'2V\'){7.26(r)}})}}h 20(){U 7,2m,2p;7=w;2p=7.3b();2m=\'<7w 1I="g-20" 7M="0" 7A="-1" 4K="7C:p" \'+\'e="2a:4b; o:2X; z-3E:-1; 4P:7L(3u=\\\'0\\\'); H: 1F 3s 4G; \'+\'F:\'+2p.F+\'19; k:\'+2p.k+\'19" />\';7.d.20=7.d.1u.3D(2m).2A(\'.g-20:1U\')}h 4v(){U 7,A,1x,16,2B;7=w;7.5c.S(7);7.T.1b=2;7.d.j=\'<12 g="\'+7.Z+\'" Z="g-\'+7.Z+\'" 5r="j" \'+\'3z-7P="g-\'+7.Z+\'-A" 1I="g \'+(7.8.e.1f.j||7.8.e)+\'" \'+\'e="2a:2V; -6R-H-E:0; -7V-H-E:0; H-E:0; o:\'+7.8.o.17+\';"> \'+\'  <12 1I="g-1u" e="o:4f; 2k:1E; 1v-3t:P;"> \'+\'    <12 1I="g-1A" e="2k:1E;"> \'+\'       <12 Z="g-\'+7.Z+\'-A" 1I="g-A \'+7.8.e.1f.A+\'"></12> \'+\'</12></12></12>\';7.d.j=$(7.d.j);7.d.j.5V(7.8.o.3O);7.d.j.16(\'g\',{3c:0,N:[7]});7.d.1u=7.d.j.2A(\'12:1U\');7.d.1A=7.d.1u.2A(\'12:1U\');7.d.A=7.d.1A.2A(\'12:1U\').J(2z(7.8.e));c($.14.1d){7.d.1u.2h(7.d.A).J({2c:1})}c(7.8.C.K.r===\'3p\'){7.d.j.W(\'3p\',G)}c(O 7.8.e.k.39===\'2g\'){7.4C()}c($(\'<1c />\').1q(0).1G||$.14.1d){c(7.8.e.H.E>0){5z.S(7)}D{7.d.1A.J({H:7.8.e.H.k+\'19 3s \'+7.8.e.H.I})}c(7.8.e.f.u!==p){4e.S(7)}}D{7.d.1A.J({H:7.8.e.H.k+\'19 3s \'+7.8.e.H.I});7.8.e.H.E=0;7.8.e.f.u=p}c((O 7.8.A.1v===\'1z\'&&7.8.A.1v.Q>0)||(7.8.A.1v.4x&&7.8.A.1v.Q>0)){A=7.8.A.1v}D c(7.d.s.W(\'R\')){7.1i.W=[\'R\',7.d.s.W(\'R\')];A=7.1i.W[1].2P(/\\n/5x,\'<5w />\')}D c(7.d.s.W(\'4m\')){7.1i.W=[\'4m\',7.d.s.W(\'4m\')];A=7.1i.W[1].2P(/\\n/5x,\'<5w />\')}D{A=\' \'}c(7.8.A.R.1v!==p){5G.S(7)}7.4B(A,p);57.S(7);c(7.8.q.3J===G){7.q()}c(7.8.A.1x!==p){1x=7.8.A.1x;16=7.8.A.16;2B=7.8.A.2B||\'1q\';7.61(1x,16,2B)}7.T.1b=G;7.5b.S(7)}h 65(s,8,Z){U 7=w;7.Z=Z;7.8=8;7.T={4n:p,1b:p,1Y:p,3q:p};7.d={s:s.4T(7.8.e.1f.s),j:1w,1u:1w,A:1w,1A:1w,R:1w,1k:1w,f:1w,20:1w};7.1i={W:1w,1N:{},2M:0,2k:{P:p,L:p}};7.1D={};$.2s(7,7.8.V,{q:h(r){U 1a,1W;c(!7.T.1b){B p}c(7.d.j.J(\'2a\')!==\'2V\'){B 7}c(7.1i.W){7.d.s.7W(7.1i.W[0])}7.d.j.3o(G,p);1a=7.5g.S(7,r);c(1a===p){B 7}h 2K(){7.d.j.W(\'3z-1E\',G);c(7.8.o.17!==\'2b\'){7.2E()}7.5B.S(7,r);c($.14.1d){7.d.j.1q(0).e.7R(\'4P\')}7.d.j.J({3u:\'\'})}7.1i.2M=1;c(7.8.o.17!==\'2b\'){7.26(r,(7.8.q.Y.Q>0&&7.1b!==2))}c(O 7.8.q.1W===\'18\'){1W=$(7.8.q.1W)}D c(7.8.q.1W===G){1W=$(\'12.g\').5M(7.d.j)}c(1W){1W.1L(h(){c($(w).g(\'V\').T.1b===G){$(w).g(\'V\').C()}})}c(O 7.8.q.Y.17===\'h\'){7.8.q.Y.17.S(7.d.j,7.8.q.Y.Q);7.d.j.54(h(){2K();$(w).56()})}D{49(7.8.q.Y.17.2F()){23\'3G\':7.d.j.7Q(7.8.q.Y.Q,2K);1C;23\'58\':7.d.j.7O(7.8.q.Y.Q,h(){2K();c(7.8.o.17!==\'2b\'){7.26(r,G)}});1C;23\'52\':7.d.j.q(7.8.q.Y.Q,2K);1C;2S:7.d.j.q(1w,2K);1C}7.d.j.4T(7.8.e.1f.3F)}B 7},C:h(r){U 1a;c(!7.T.1b){B p}D c(7.d.j.J(\'2a\')===\'2V\'){B 7}c(7.1i.W){7.d.s.W(7.1i.W[0],7.1i.W[1])}2e(7.1D.q);7.d.j.3o(G,p);1a=7.5A.S(7,r);c(1a===p){B 7}h 2T(){7.d.j.W(\'3z-1E\',G);7.d.j.J({3u:\'\'});7.5D.S(7,r)}7.1i.2M=0;c(O 7.8.C.Y.17===\'h\'){7.8.C.Y.17.S(7.d.j,7.8.C.Y.Q);7.d.j.54(h(){2T();$(w).56()})}D{49(7.8.C.Y.17.2F()){23\'3G\':7.d.j.7z(7.8.C.Y.Q,2T);1C;23\'58\':7.d.j.7u(7.8.C.Y.Q,2T);1C;23\'52\':7.d.j.C(7.8.C.Y.Q,2T);1C;2S:7.d.j.C(1w,2T);1C}7.d.j.73(7.8.e.1f.3F)}B 7},2M:h(r,3a){U 4Y=/75|2g/.28(O 3a)?3a:!7.d.j.30(\':2x\');7[4Y?\'q\':\'C\'](r);B 7},26:h(r,4h){c(!7.T.1b){B p}U 22=8.o,s=$(22.s),2D=7.d.j.4L(),2C=7.d.j.4H(),1m,1l,o,1o=22.u.j,2G=22.u.s,1a,11,i,41,29,4j={P:h(){U 3g=$(27).4g(),3j=$(27).k()+$(27).4g(),2I=1o.x===\'1g\'?2D/2:2D,2w=1o.x===\'1g\'?1m/2:1m,2u=(1o.x===\'1g\'?1:2)*7.8.e.H.E,1s=-2*22.1e.x,3i=o.P+2D,1h;c(3i>3j){1h=1s-2I-2w+2u;c(o.P+1h>3g||3g-(o.P+1h)<3i-3j){B{1e:1h,f:\'21\'}}}c(o.P<3g){1h=1s+2I+2w-2u;c(3i+1h<3j||3i+1h-3j<3g-o.P){B{1e:1h,f:\'P\'}}}B{1e:0,f:1o.x}},L:h(){U 3e=$(27).4d(),3d=$(27).F()+$(27).4d(),2I=1o.y===\'1g\'?2C/2:2C,2w=1o.y===\'1g\'?1l/2:1l,2u=(1o.y===\'1g\'?1:2)*7.8.e.H.E,1s=-2*22.1e.y,3h=o.L+2C,1h;c(3h>3d){1h=1s-2I-2w+2u;c(o.L+1h>3e||3e-(o.L+1h)<3h-3d){B{1e:1h,f:\'24\'}}}c(o.L<3e){1h=1s+2I+2w-2u;c(3h+1h<3d||3h+1h-3d<3e-o.L){B{1e:1h,f:\'L\'}}}B{1e:0,f:1o.y}}};c(r&&8.o.s===\'1N\'){2G={x:\'P\',y:\'L\'};1m=1l=0;o={L:r.4D,P:r.4N}}D{c(s[0]===3Q){1m=s.k();1l=s.F();o={L:0,P:0}}D c(s[0]===27){1m=s.k();1l=s.F();o={L:s.4d(),P:s.4g()}}D c(s.30(\'70\')){11=7.8.o.s.W(\'11\').6U(\',\');1Q(i=0;i<11.Q;i++){11[i]=1y(11[i],10)}41=7.8.o.s.3v(\'6T\').W(\'1V\');29=$(\'4M[6S="#\'+41+\'"]:1U\').1s();s.o={P:1t.3U(29.P+11[0]),L:1t.3U(29.L+11[1])};49(7.8.o.s.W(\'3B\').2F()){23\'6Z\':1m=1t.66(1t.69(11[2]-11[0]));1l=1t.66(1t.69(11[3]-11[1]));1C;23\'6Y\':1m=11[2]+1;1l=11[2]+1;1C;23\'7a\':1m=11[0];1l=11[1];1Q(i=0;i<11.Q;i++){c(i%2===0){c(11[i]>1m){1m=11[i]}c(11[i]<11[0]){o.P=1t.3U(29.P+11[i])}}D{c(11[i]>1l){1l=11[i]}c(11[i]<11[1]){o.L=1t.3U(29.L+11[i])}}}1m=1m-(o.P-29.P);1l=1l-(o.L-29.L);1C}1m-=2;1l-=2}D{1m=s.4L();1l=s.4H();o=s.1s()}o.P+=2G.x===\'21\'?1m:2G.x===\'1g\'?1m/2:0;o.L+=2G.y===\'24\'?1l:2G.y===\'1g\'?1l/2:0}o.P+=22.1e.x+(1o.x===\'21\'?-2D:1o.x===\'1g\'?-2D/2:0);o.L+=22.1e.y+(1o.y===\'24\'?-2C:1o.y===\'1g\'?-2C/2:0);c(7.8.e.H.E>0){c(1o.x===\'P\'){o.P-=7.8.e.H.E}D c(1o.x===\'21\'){o.P+=7.8.e.H.E}c(1o.y===\'L\'){o.L-=7.8.e.H.E}D c(1o.y===\'24\'){o.L+=7.8.e.H.E}}c(22.1e.5d){(h(){U 2Z={x:0,y:0},2q={x:4j.P(),y:4j.L()},f=2v 2H(8.e.f.u);c(7.d.f&&f){c(2q.y.1e!==0){o.L+=2q.y.1e;f.y=2Z.y=2q.y.f}c(2q.x.1e!==0){o.P+=2q.x.1e;f.x=2Z.x=2q.x.f}7.1i.2k={P:2Z.x===p,L:2Z.y===p};c(7.d.f.W(\'1T\')!==f.1z()){4e.S(7,f)}}}())}c(!7.d.20&&$.14.1d&&1y($.14.38.2y(0),10)===6){20.S(7)}1a=7.5e.S(7,r);c(1a===p){B 7}c(8.o.s!==\'1N\'&&4h===G){7.T.4n=G;7.d.j.3o().4h(o,7p,\'7q\',h(){7.T.4n=p})}D{7.d.j.J(o)}7.5h.S(7,r);B 7},4C:h(1p){c(!7.T.1b||(1p&&O 1p!==\'2g\')){B p}U 1E=7.d.1A.7s().2h(7.d.f).2h(7.d.1k),2c=7.d.1u.2h(7.d.1A.2A()),j=7.d.j,1J=7.8.e.k.1J,2f=7.8.e.k.2f;c(!1p){c(O 7.8.e.k.39===\'2g\'){1p=7.8.e.k.39}D{7.d.j.J({k:\'5K\'});1E.C();j.k(1p);c($.14.1d){2c.J({2c:\'\'})}1p=7.3b().k;c(!7.8.e.k.39){1p=1t.2f(1t.1J(1p,2f),1J)}}}c(1p%2){1p+=1}7.d.j.k(1p);1E.q();c(7.8.e.H.E){7.d.j.1H(\'.g-2i\').1L(h(i){$(w).k(1p-(7.8.e.H.E*2))})}c($.14.1d){2c.J({2c:1});7.d.1u.k(1p);c(7.d.20){7.d.20.k(1p).F(7.3b.F)}}B 7},7l:h(1V){U f,2t,1n,u,X;c(!7.T.1b||O 1V!==\'1z\'||!$.1j.g.32[1V]){B p}7.8.e=4z.S(7,$.1j.g.32[1V],7.8.4O.e);7.d.A.J(2z(7.8.e));c(7.8.A.R.1v!==p){7.d.R.J(2z(7.8.e.R,G))}7.d.1A.J({7k:7.8.e.H.I});c(7.8.e.f.u!==p){c($(\'<1c />\').1q(0).1G){f=7.d.j.1H(\'.g-f 1c:1U\');1n=f.1q(0).1G(\'2d\');1n.5Y(0,0,3y,3y);u=f.3v(\'12[1T]:1U\').W(\'1T\');X=4r(u,7.8.e.f.M.k,7.8.e.f.M.F);4q.S(7,f,X,7.8.e.f.I||7.8.e.H.I)}D c($.14.1d){f=7.d.j.1H(\'.g-f [5X="3B"]\');f.W(\'3A\',7.8.e.f.I||7.8.e.H.I)}}c(7.8.e.H.E>0){7.d.j.1H(\'.g-2i\').J({7c:7.8.e.H.I});c($(\'<1c />\').1q(0).1G){2t=3Z(7.8.e.H.E);7.d.j.1H(\'.g-1u 1c\').1L(h(){1n=$(w).1q(0).1G(\'2d\');1n.5Y(0,0,3y,3y);u=$(w).3v(\'12[1T]:1U\').W(\'1T\');43.S(7,$(w),2t[u],7.8.e.H.E,7.8.e.H.I)})}D c($.14.1d){7.d.j.1H(\'.g-1u [5X="3m"]\').1L(h(){$(w).W(\'3A\',7.8.e.H.I)})}}B 7},4B:h(A,5W){U 2U,34,4u;h 4s(){7.4C();c(5W!==p){c(7.8.o.17!==\'2b\'){7.26(7.d.j.30(\':2x\'),G)}c(7.8.e.f.u!==p){4F.S(7)}}}c(!7.T.1b||!A){B p}2U=7.5t.S(7,A);c(O 2U===\'1z\'){A=2U}D c(2U===p){B}c($.14.1d){7.d.1A.2A().J({2c:\'7i\'})}c(A.4x&&A.Q>0){A.5L(G).5V(7.d.A).q()}D{7.d.A.2m(A)}34=7.d.A.1H(\'4M[7j=p]\');c(34.Q>0){4u=0;34.1L(h(i){$(\'<4M 4K="\'+$(w).W(\'4K\')+\'" />\').7g(h(){c(++4u===34.Q){4s()}})})}D{4s()}7.5a.S(7);B 7},61:h(1x,16,2B){U 1a;h 4y(A){7.5v.S(7);7.4B(A)}c(!7.T.1b){B p}1a=7.5u.S(7);c(1a===p){B 7}c(2B===\'60\'){$.60(1x,16,4y)}D{$.1q(1x,16,4y)}B 7},5T:h(A){U 1a;c(!7.T.1b||!A){B p}1a=7.4Q.S(7);c(1a===p){B 7}c(7.d.1k){7.d.1k=7.d.1k.5L(G)}7.d.R.2m(A);c(7.d.1k){7.d.R.3D(7.d.1k)}7.53.S(7);B 7},2E:h(r){U 4w,3r,3k,1a;c(!7.T.1b||7.8.o.17===\'2b\'){B p}4w=1y(7.d.j.J(\'z-3E\'),10);3r=7r+$(\'12.g[Z^="g"]\').Q-1;c(!7.T.3q&&4w!==3r){1a=7.4Z.S(7,r);c(1a===p){B 7}$(\'12.g[Z^="g"]\').5M(7.d.j).1L(h(){c($(w).g(\'V\').T.1b===G){3k=1y($(w).J(\'z-3E\'),10);c(O 3k===\'2g\'&&3k>-1){$(w).J({5Q:1y($(w).J(\'z-3E\'),10)-1})}$(w).g(\'V\').T.3q=p}});7.d.j.J({5Q:3r});7.T.3q=G;7.5H.S(7,r)}B 7},3H:h(3a){c(!7.T.1b){B p}7.T.1Y=3a?G:p;B 7},36:h(){U i,1a,N;1a=7.4V.S(7);c(1a===p){B 7}c(7.T.1b){7.8.q.K.s.1R(\'4E.g\',7.26);7.8.q.K.s.1R(\'4J.g\',7.C);7.8.q.K.s.1R(7.8.q.K.r+\'.g\');7.8.C.K.s.1R(7.8.C.K.r+\'.g\');7.d.j.1R(7.8.C.K.r+\'.g\');7.d.j.1R(\'2Y.g\',7.2E);7.d.j.3l()}D{7.8.q.K.s.1R(7.8.q.K.r+\'.g-\'+7.Z+\'-4I\')}c(O 7.d.s.16(\'g\')===\'18\'){N=7.d.s.16(\'g\').N;c(O N===\'18\'&&N.Q>0){1Q(i=0;i<N.Q-1;i++){c(N[i].Z===7.Z){N.5P(i,1)}}}}$.1j.g.N.5P(7.Z,1);c(O N===\'18\'&&N.Q>0){7.d.s.16(\'g\').3c=N.Q-1}D{7.d.s.7n(\'g\')}7.51.S(7);B 7.d.s},7o:h(){U q,1s;c(!7.T.1b){B p}q=(7.d.j.J(\'2a\')!==\'2V\')?p:G;c(q){7.d.j.J({3N:\'1E\'}).q()}1s=7.d.j.1s();c(q){7.d.j.J({3N:\'2x\'}).C()}B 1s},3b:h(){U q,2p;c(!7.T.1b){B p}q=(!7.d.j.30(\':2x\'))?G:p;c(q){7.d.j.J({3N:\'1E\'}).q()}2p={F:7.d.j.4H(),k:7.d.j.4L()};c(q){7.d.j.J({3N:\'2x\'}).C()}B 2p}})}$.1j.g=h(8,4t){U i,Z,N,1Z,2r,1P,15,V;c(O 8===\'1z\'){c($(w).16(\'g\')){c(8===\'V\'){B $(w).16(\'g\').N[$(w).16(\'g\').3c]}D c(8===\'N\'){B $(w).16(\'g\').N}}D{B $(w)}}D{c(!8){8={}}c(O 8.A!==\'18\'||(8.A.4x&&8.A.Q>0)){8.A={1v:8.A}}c(O 8.A.R!==\'18\'){8.A.R={1v:8.A.R}}c(O 8.o!==\'18\'){8.o={u:8.o}}c(O 8.o.u!==\'18\'){8.o.u={s:8.o.u,j:8.o.u}}c(O 8.q!==\'18\'){8.q={K:8.q}}c(O 8.q.K!==\'18\'){8.q.K={r:8.q.K}}c(O 8.q.Y!==\'18\'){8.q.Y={17:8.q.Y}}c(O 8.C!==\'18\'){8.C={K:8.C}}c(O 8.C.K!==\'18\'){8.C.K={r:8.C.K}}c(O 8.C.Y!==\'18\'){8.C.Y={17:8.C.Y}}c(O 8.e!==\'18\'){8.e={1V:8.e}}8.e=4A(8.e);1Z=$.2s(G,{},$.1j.g.33,8);1Z.e=4z.S({8:1Z},1Z.e);1Z.4O=$.2s(G,{},8)}B $(w).1L(h(){c(O 8===\'1z\'){1P=8.2F();N=$(w).g(\'N\');c(O N===\'18\'){c(4t===G&&1P===\'36\'){1Q(i=N.Q-1;i>-1;i--){c(\'18\'===O N[i]){N[i].36()}}}D{c(4t!==G){N=[$(w).g(\'V\')]}1Q(i=0;i<N.Q;i++){c(1P===\'36\'){N[i].36()}D c(N[i].T.1b===G){c(1P===\'q\'){N[i].q()}D c(1P===\'C\'){N[i].C()}D c(1P===\'2E\'){N[i].2E()}D c(1P===\'3H\'){N[i].3H(G)}D c(1P===\'6V\'){N[i].3H(p)}D c(1P===\'71\'){N[i].26()}}}}}}D{15=$.2s(G,{},1Z);15.C.Y.Q=1Z.C.Y.Q;15.q.Y.Q=1Z.q.Y.Q;c(15.o.3O===p){15.o.3O=$(3Q.77)}c(15.o.s===p){15.o.s=$(w)}c(15.q.K.s===p){15.q.K.s=$(w)}c(15.C.K.s===p){15.C.K.s=$(w)}15.o.u.j=2v 2H(15.o.u.j);15.o.u.s=2v 2H(15.o.u.s);Z=$.1j.g.N.Q;1Q(i=0;i<Z;i++){c(O $.1j.g.N[i]===\'5N\'){Z=i;1C}}2r=2v 65($(w),15,Z);$.1j.g.N[Z]=2r;c(O $(w).16(\'g\')===\'18\'&&$(w).16(\'g\')){c(O $(w).W(\'g\')===\'5N\'){$(w).16(\'g\').3c=$(w).16(\'g\').N.Q}$(w).16(\'g\').N.5s(2r)}D{$(w).16(\'g\',{3c:0,N:[2r]})}c(15.A.5C===p&&15.q.K.r!==p&&15.q.3J!==G){15.q.K.s.1K(15.q.K.r+\'.g-\'+Z+\'-4I\',{g:Z},h(r){V=$.1j.g.N[r.16.g];V.8.q.K.s.1R(V.8.q.K.r+\'.g-\'+r.16.g+\'-4I\');V.1i.1N={x:r.4N,y:r.4D};4v.S(V);V.8.q.K.s.72(V.8.q.K.r)})}D{2r.1i.1N={x:15.q.K.s.1s().P,y:15.q.K.s.1s().L};4v.S(2r)}}})};$.1j.g.N=[];$.1j.g.7S={7T:h(){B w}};$.1j.g.7Y={};$.1j.g.33={A:{5C:p,1v:p,1x:p,16:1w,R:{1v:p,1k:p}},o:{s:p,u:{s:\'3T\',j:\'3R\'},1e:{x:0,y:0,1N:G,5d:p,3V:G,3S:G},17:\'2X\',3O:p},q:{K:{s:p,r:\'2Y\'},Y:{17:\'3G\',Q:5o},2N:7y,1W:p,3J:p},C:{K:{s:p,r:\'4J\'},Y:{17:\'3G\',Q:5o},2N:0,2W:p},V:{5c:h(){},5b:h(){},5e:h(){},5h:h(){},5g:h(){},5B:h(){},5A:h(){},5D:h(){},5t:h(){},5a:h(){},5u:h(){},5v:h(){},4Q:h(){},53:h(){},4V:h(){},51:h(){},4Z:h(){},5H:h(){}}};$.1j.g.32={33:{1r:\'5q\',I:\'#6k\',2k:\'1E\',6c:\'P\',k:{2f:0,1J:6z},2O:\'6x 6C\',H:{k:1,E:0,I:\'#6B\'},f:{u:p,I:p,M:{k:13,F:13},3u:1},R:{1r:\'#7e\',6y:\'6w\',2O:\'6A 6e\'},1k:{6r:\'6d\'},1f:{s:\'\',f:\'g-f\',R:\'g-R\',1k:\'g-1k\',A:\'g-A\',3F:\'g-3F\'}},5j:{H:{k:3,E:0,I:\'#6l\'},R:{1r:\'#6p\',I:\'#5n\'},1r:\'#7H\',I:\'#5n\',1f:{j:\'g-5j\'}},5E:{H:{k:3,E:0,I:\'#7x\'},R:{1r:\'#7B\',I:\'#5F\'},1r:\'5q\',I:\'#5F\',1f:{j:\'g-5E\'}},4W:{H:{k:3,E:0,I:\'#7N\'},R:{1r:\'#7X\',I:\'#55\'},1r:\'#7U\',I:\'#55\',1f:{j:\'g-4W\'}},4G:{H:{k:3,E:0,I:\'#74\'},R:{1r:\'#76\',I:\'#6b\'},1r:\'#7v\',I:\'#6b\',1f:{j:\'g-4G\'}},63:{H:{k:3,E:0,I:\'#78\'},R:{1r:\'#6W\',I:\'#6a\'},1r:\'#6X\',I:\'#6a\',1f:{j:\'g-63\'}},5y:{H:{k:3,E:0,I:\'#7b\'},R:{1r:\'#7m\',I:\'#7t\'},1r:\'#7f\',I:\'#7d\',1f:{j:\'g-5y\'}}}}(7h));',62,495,'|||||||self|options||||if|elements|style|tip|qtip|function||tooltip|width||||position|false|show|event|target||corner||this||||content|return|hide|else|radius|height|true|border|color|css|when|top|size|interfaces|typeof|left|length|title|call|status|var|api|attr|coordinates|effect|id||coords|div||browser|config|data|type|object|px|returned|rendered|canvas|msie|adjust|classes|center|adj|cache|fn|button|targetHeight|targetWidth|context|my|newWidth|get|background|offset|Math|wrapper|text|null|url|parseInt|string|contentWrapper|finalStyle|break|timers|hidden|1px|getContext|find|class|max|bind|each|containers|mouse|tips|command|for|unbind|ieAdjust|rel|first|name|solo|inactive|disabled|opts|bgiframe|right|posOptions|case|bottom|positionAdjust|updatePosition|window|test|imagePos|display|static|zoom||clearTimeout|min|number|add|betweenCorners|styleExtend|overflow|margin|html|path|hideTarget|dimensions|adapted|obj|extend|borders|borderAdjust|new|atOffset|visible|charAt|jQueryStyle|children|method|elemHeight|elemWidth|focus|toLowerCase|at|Corner|myOffset|precedance|afterShow|line|toggle|delay|padding|replace|90|styleObj|default|afterHide|parsedContent|none|fixed|absolute|mouseover|adjusted|is|font|styles|defaults|images|borderBottom|destroy|borderTop|version|value|state|getDimensions|current|bottomEdge|topEdge|showTarget|leftEdge|pBottom|pRight|rightEdge|elemIndex|remove|arc|newMargin|stop|unfocus|focused|newIndex|solid|align|opacity|parent|styleArray|delete|300|aria|fillcolor|shape|coordsize|prepend|index|active|fade|disable|image|ready|inactiveMethod|VML|inactiveEvents|visiblity|container|behavior|document|topLeft|resize|bottomRight|floor|scroll|marginTop|hideMethod|topRight|calculateBorders|sub|mapName|showMethod|drawBorder|arguments|betweenWidth|setTimeout|borderCoord|ltr|switch|dir|block|vertical|scrollTop|createTip|relative|scrollLeft|animate|vertWidth|adapt|bottomLeft|sideWidth|alt|animated|paddingSize|paddingCorner|drawTip|calculateTip|afterLoad|blanket|loadedImages|construct|curIndex|jquery|setupContent|buildStyle|sanitizeStyle|updateContent|updateWidth|pageY|mousemove|positionTip|red|outerHeight|create|mouseout|src|outerWidth|img|pageX|user|filter|beforeTitleUpdate|fill|lineTo|addClass|fillStyle|beforeDestroy|dark|append|condition|beforeFocus||onDestroy|grow|onTitleUpdate|queue|f3f3f3|dequeue|assignEvents|slide|beginPath|onContentUpdate|onRender|beforeRender|screen|beforePositionUpdate|stroked|beforeShow|onPositionUpdate|inline|cream|click|mousedown|prependTo|A27D35|100|parents|white|role|push|beforeContentUpdate|beforeContentLoad|onContentLoad|br|gi|blue|createBorder|beforeHide|onShow|prerender|onHide|light|454545|createTitle|onFocus|topright|bottomleft|auto|clone|not|undefined|unshift|splice|zIndex|270|bottomright|updateTitle|String|appendTo|reposition|nodeName|clearRect|middle|post|loadContent|match|green|topleft|QTip|ceil|in|apply|abs|58792E|9C2F2F|textAlign|pointer|12px|search|filled|bottomcenter|0px|topcenter|111|F9E98E|strict|use|labelledby|F0DE7D|eq|cursor|rightcenter|dblclick|float|lefttop|bold|5px|fontWeight|250|7px|d3d3d3|9px|marginLeft|while|rightbottom|PI|Right|moveTo|borderWidth|leftcenter|endangle|startangle|leftbottom|Left|righttop|xe|moz|usemap|map|split|enable|b9db8c|CDE6AC|circle|rect|area|update|trigger|removeClass|CE6F6F|boolean|f28279|body|A9DB66|mouseup|poly|ADD9ED|backgroundColor|4D9FBF|e1e1e1|E5F6FE|load|jQuery|normal|complete|borderColor|updateStyle|D0E9F5|removeData|getPosition|200|swing|15000|siblings|5E99BD|slideUp|F79992|iframe|E2E2E2|140|fadeOut|tabindex|f1f1f1|javascript|preventDefault|stopPropagation|mouseleave|mouseenter|FBF7AA|out|relatedTarget|leave|alpha|frameborder|303030|slideDown|describedby|fadeIn|removeAttribute|log|error|505050|webkit|removeAttr|404040|constants'.split('|'),0,{}))

var myBox = new Object();
myBox.onInit = function() {}
//////////////////////////////////
// Generic onload by Brothercake
// http://www.brothercake.com/
////////////////////////////////
if(typeof window.addEventListener != 'undefined') {
	//.. gecko, safari, konqueror and standard
	window.addEventListener('load', initJavaScript, false);
}
else if(typeof document.addEventListener != 'undefined') {
	//.. opera 7
	document.addEventListener('load', initJavaScript, false);
}
else if(typeof window.attachEvent != 'undefined') {
	//.. win/ie
	window.attachEvent('onload', initJavaScript);
}
function jal_apply_filters(s) {
	return filter_smilies(make_links((s)));
}
function make_links (s) {
	target="";
	if(var_XHTML==0) if (s.indexOf(this.location.href)==-1) target=' target="_blank"';
	var re = /((http|https|ftp):\/\/[^ ]*)/gi;	
	text = s.replace(re,"<a href=\"$1\""+target+">&laquo;"+Sht_Link+"&raquo;</a>");
	return text;
}

function filter_smilies(s) {
	for (var i = 0; i < smilies.length; i++) {
		var replace = '<img src="'+PathToSmiley + smilies[i][1] + '" class="wp-smiley" alt="[smiley]" />';
		var search = smilies[i][0].replace(/(\(|\)|\$|\?|\*|\+|\^|\[|\.|\|)/gi, "\\$1");
		re = new RegExp(search, 'gi');
		s = s.replace(re, replace);
	}
	var re =/([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+(\.[-a-z0-9]+)*\.[a-z]{2,6})/gi;
	s = s.replace(re,"<a href=\"mailto:$1\">&laquo;"+Sht_Email+"&raquo;</a>");
	return s;
}

// XHTML live Chat
// author: alexander kohlhofer
// version: 1.0
// http://www.plasticshore.com
// http://www.plasticshore.com/projects/chat/
// please let the author know if you put any of this to use
// XHTML live Chat (including this script) is published under a creative commons license
// license: http://creativecommons.org/licenses/by-nc-sa/2.0/

var dateExp = new Date();
dateExp.setTime(dateExp.getTime()+2592000000);
var DateExpires = dateExp.toGMTString();

var oldval, is_new=1;
var jal_loadtimes, jal_timeout;
var httpReceiveChat, httpSendChat;
var jalSound, shoutboxname, shoutboxU, chatbarText, jal_lastID, outputList, shout_theme;

function initJavaScript() {
shoutboxname=document.getElementById('shoutboxname');
shoutboxU=document.getElementById('shoutboxU');
chatbarText=document.getElementById('chatbarText');
jal_lastID=document.getElementById('jal_lastID');
outputList=document.getElementById("outputList");
shout_theme=document.getElementById('shout_theme');
jal_timeout = jal_org_timeout;
ChangeBoxSize(2);

	if (!chatbarText) { return; }
	if(shout_theme) shout_theme.style.display="";
//this non standard attribute prevents firefox' autofill function to clash with this script
	document.forms['chatForm'].elements['chatbarText'].setAttribute('autocomplete','off');

	checkStatus('');
	checkName();
	checkUrl();
	jalSound = (jal_getCookie("jalSound")==null || jal_getCookie("jalSound")==1) ? 1 : 0;
	jal_loadtimes = 1;

// initiates the two objects for sending and receiving data
	httpReceiveChat = getHTTPObject();
	httpSendChat = getHTTPObject();

	setTimeout('receiveChatText()', jal_timeout); //initiates the first data query

	shoutboxname.onblur = checkName;
	shoutboxU.onblur = checkUrl;
	chatbarText.onfocus = function () { checkStatus('active'); }	
	chatbarText.onblur = function () { checkStatus(''); }
	document.getElementById('submitchat').onclick = sendComment;
	document.getElementById('chatForm').onsubmit = function () { return false; }
// When user mouses over shoutbox
	document.getElementById('chatoutput').onmouseover = ResetChrono;
	
	var obj = "";
	if(show_smiley==1) {
		ActualSmile="", style="", lib="-";
		if (jal_getCookie("jalSmiley")==1) {
			style="display:none";
			lib="+"
		}
		obj+="<a href=\"javascript:ShowHide('SmileyParent','SmileyChild')\" id=\"SmileyParent\" ";
		obj+="title=\""+Sht_Expand+"\">"+lib+"</a> Smileys :";
		obj+="<div id='SmileyChild' style=\""+style+"\">";
		for (var i = 0; i < smilies.length; i++) {
			if(ActualSmile!=smilies[i][1]) {
				obj+="<a href=\"javascript:appendSmiley('"+smilies[i][0].replace("'","\\'")+"')\">";
				obj+="<img src=\""+PathToSmiley+smilies[i][1]+"\" alt=\"\" class=\"wp-smiley\"/></a> ";
			}
			ActualSmile=smilies[i][1];
		}
		obj+="</div>"	
		if(document.getElementById("SmileyList")) document.getElementById("SmileyList").innerHTML=obj;
	}
}

function ResetChrono() {
	if (jal_loadtimes > 9) {
		jal_loadtimes = 1;
		receiveChatText();
	}
	jal_timeout = jal_org_timeout;
}

function appendSmiley(text) {
	chatbarText.value+=' '+text;
	chatbarText.focus();
}
	
function ShowHide(parent, enfant) {
	txtParent=document.getElementById(parent).innerHTML;
	etatEnfant=document.getElementById(enfant).style.display;
	document.getElementById(parent).innerHTML=(txtParent=="+") ? "-" : "+";
	document.getElementById(enfant).style.display=(etatEnfant=="none") ? "" : "none";
	jalSmiley = (jal_getCookie("jalSmiley")==1) ? 0 : 1;
	document.cookie = "jalSmiley="+jalSmiley+";expires="+DateExpires+";path=/;";
}

//initiates the first data query
function receiveChatText() {
	lastID = parseInt(jal_lastID.value)-1;
	MyCat=encodeURIComponent(document.getElementById("shout_cat").value);

	if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
		httpReceiveChat.open("GET",GetChaturl+'&jal_lastID='+lastID+'&shout_cat='+MyCat+'&rand='+Math.floor(Math.random() * 1000000), true);
		httpReceiveChat.onreadystatechange = handlehHttpReceiveChat; 
		httpReceiveChat.send(null);
		jal_loadtimes++;
		if (jal_loadtimes > 9) jal_timeout = jal_timeout * 5 / 4;
	}
	setTimeout('receiveChatText()',jal_timeout);
}

//deals with the servers' reply to requesting new content
function handlehHttpReceiveChat() {
	if (httpReceiveChat.readyState == 4) {
		firstarray = httpReceiveChat.responseText.split('\n');
		if (firstarray.length == 2) { // if != 2, it failed, we should skip the processing part
			results = firstarray[0].split('---');
			replaceUserOnline(results[0],results[1]);
			results = firstarray[1].split('---'); //the fields are seperated by ---
			if (results.length > 4) {
				for(i=0;i < (results.length-1);i=i+8) { //goes through the result one message at a time
				insertNewContent(results[i+1],results[i+2],results[i+3], results[i], results[i+4], results[i+5], results[i+6]);
				jal_lastID.value = parseInt(results[i])+1;
				}
				jal_timeout = jal_org_timeout;
				jal_loadtimes = 1;
			}
			else if(results.length==3) {
				insertNewContent(results[1], results[2], "", parseInt(results[0])+1,"","");
				jal_lastID.value = parseInt(results[0])+1;
			}
			//is_new=1;
		}
	}
}

function setSound() {
jalSound = (jal_getCookie("jalSound")=="" || jal_getCookie("jalSound")==0) ? 1 : 0;
document.cookie = "jalSound="+jalSound+";expires="+DateExpires+";path=/;";
document.getElementById('JalSound').src=(jalSound==1) ? pathToImg+"sound_1.gif": pathToImg+"sound_0.gif";
}

//inserts the new content into the page
function insertNewContent(liName, liText, liUrl, liId, liUser, liEmail, liTime) {
var myClass="";
if(liUser==1) myClass="jal_user ";
myClass+=liName.replace(" ","");
verif=true;
	if (liText.substr(0,2)=="@@") {
		verif=false;
		PosSpace=liText.indexOf(" ");
		To=liText.substr(2,PosSpace-2);
		Deb=2+(To.length);
		shout_user=shout_user.toLowerCase();
		if(shout_user==To.toLowerCase() || isAdmin==true || shout_user==liName.toLowerCase()) {
			verif=true;
			liText="<span class='InfoUser'>"+Sht_Chaine+" "+To+":</span>"+liText.substr(Deb); 
		}
	}
if (verif==true) {
	if(document.getElementById("TheBox") && jalSound==1 && is_new==1) {
		document.getElementById("TheBox").SetVariable("method:setUrl", pathToMP3);
		document.getElementById("TheBox").SetVariable("method:play", "");
	}
	oLi = document.createElement('li');
	oLi.setAttribute('id','comment-new'+liId);
	
	if (show_avatar==1) {
		if(liEmail!="") {
			avatar = 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s='+avatar_size;
			oDiv = document.createElement('div');
			oDiv.setAttribute('class','ps_'+avatar_position);
			oDiv.setAttribute('className','ps_'+avatar_position);
			oImg = document.createElement('img');
			oImg.setAttribute('src','http://www.gravatar.com/avatar.php?gravatar_id='+liEmail+'&default='+avatar+'&size='+ avatar_size);
			oDiv.appendChild(oImg);
			oLi.appendChild(oDiv);
		}
	}

	oSpan = document.createElement('span');
	oSpan.setAttribute('class',myClass);
	oSpan.setAttribute('title',liTime);

	oName = document.createTextNode(liName);

	if (liUrl != "http://" && liUrl != '') {
		oURL = document.createElement('a');
		oURL.href = liUrl;
		if(var_XHTML==0) if (liUrl.indexOf(this.location.href)==-1) oURL.setAttribute('target','_blank');
		oURL.appendChild(oName);
	} else {
		oURL = oName;
	}

	oSpan.appendChild(oURL);
	oSpan.appendChild(document.createTextNode(' : '));
	oLi.appendChild(oSpan);
	oLi.innerHTML += jal_apply_filters(liText);

	if(isAdmin==true) {
		oSpan = document.createElement('span');
		oSpan.setAttribute('class','delShout');
		oSpan.setAttribute('className','delShout');
		oSpan.setAttribute('title',Sht_Delete);
		oSpan.onclick = function () { deleteComment(liId); }
		oSpan.appendChild(document.createTextNode('x'));
		oLi.appendChild(oSpan);
	}

	outputList.insertBefore(oLi, outputList.firstChild);
	if(is_new==1) 
		Fat.fade_element("comment-new"+liId, 30, fade_length, "#"+fade_from, "#"+fade_to);
	}
}

function MasqueSelect() {
	mabox=document.getElementById('shoutboxOp');
	posEgal=mabox.options[0].text.indexOf("=");
	if(mabox.options[mabox.selectedIndex].value==eval(mabox.options[0].text.substr(0,posEgal)))
	document.getElementById('shoutbox_captcha').style.display="none";
}
//stores a new comment on the server
function sendComment() {
	currentChatText = chatbarText.value;
	currentUrl = shoutboxU.value;
	currentName = shoutboxname.value;
	shoutboxOp = document.getElementById('shoutboxOp').value;
	shoutboxControl= document.getElementById('shoutboxControl').value;
	MyCat=document.getElementById('shout_cat').value;

	if (currentChatText == '') return;
	if(CheckSpam(currentName+' '+currentChatText, currentUrl)) {
		if (httpSendChat.readyState == 4 || httpSendChat.readyState == 0) {
			param = 'n='+ encodeURIComponent(currentName)+'&c='+ encodeURIComponent(currentChatText) +'&u='+ encodeURIComponent(currentUrl)+'&shoutboxOp='+encodeURIComponent(shoutboxOp)+'&shoutboxControl='+encodeURIComponent(shoutboxControl)+'&shout_cat='+encodeURIComponent(MyCat);	
			httpSendChat.open("POST", SendChaturl, true);
			httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			httpSendChat.onreadystatechange = receiveChatText;
			httpSendChat.send(param);
			chatbarText.value = '';
		}
	}
}

function deleteComment(id) {
	theHTML=document.getElementById('comment-new'+id).innerHTML;
	var HtmlText = theHTML.replace(/<[a-zA-Z\/][^>]*>x?/g, "");
	AlertMsg=Sht_Alert1+" \n"+ HtmlText+"\n\n";
	AlertMsg+=Sht_Alert2;
	if(confirm(AlertMsg)) {
		if (httpSendChat.readyState == 4 || httpSendChat.readyState == 0) {
			param = 'mode=del&id='+ encodeURIComponent(id);
			httpSendChat.open("POST", SendChaturl, true);
			httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			httpSendChat.onreadystatechange = receiveChatText;
			httpSendChat.send(param);
			Fat.fade_element('comment-new'+id,30,1000,"#FF0000");
			setTimeout('delChild('+id+')',1000);
		}
	}
}

function delChild(id) {
	var enfant = document.getElementById("comment-new"+id); 
	var anciennoeud = outputList.removeChild(enfant);
}

// Piece of code from "TinyMCE Advanced" plugin. Thanks to -> Andrew Ozz : http://www.laptoptips.ca/
function onBlurEditableSelectInput () {
MyCat=document.getElementById("shout_cat_theme");
	if (MyCat.previousSibling.value != '') {
		var o = new Option(MyCat.previousSibling.value, MyCat.previousSibling.value);
		MyCat.options[MyCat.options.length] = o;
		optionvalue=MyCat.previousSibling.value
	}
	else optionvalue=oldval;
	
	for (var i=0; i<MyCat.options.length; i++) {
		var option = MyCat.options[i];
		if (option.value ==optionvalue )
			option.selected = true;
		else
			option.selected = false;
	}

	MyCat.style.display = 'inline';
	MyCat.parentNode.removeChild(MyCat.previousSibling);
	chatbarText.focus();
	CleanBox();
}

function onKeyDown(e) {
	e = e || window.event;
	if (e.keyCode == 13)
		onBlurEditableSelectInput();
}

function CleanBox() {
var new_val;

document.getElementById("shout_cat").value=document.getElementById("shout_cat_theme").value;

MyCat=document.getElementById("shout_cat_theme");
if (MyCat.options[MyCat.selectedIndex].value == 'add_custom') {
	new_val = document.createElement("input");
	new_val.id = MyCat.id + "_custom";
	new_val.name = MyCat.name + "_custom";
	new_val.type = "text";

	new_val.style.width = MyCat.offsetWidth + 'px';
	MyCat.parentNode.insertBefore(new_val, MyCat);
	MyCat.style.display = 'none';
	new_val.focus();
	new_val.onblur = onBlurEditableSelectInput;
	new_val.onkeydown = onKeyDown;
}
else {
	if(MyCat.value != oldval) {
		mycook=encodeURIComponent(MyCat.value);
		document.cookie = "jalCombo="+mycook+";expires="+DateExpires+";path=/;"
		jal_lastID.value=0;
		is_new=0;
		while (outputList.firstChild) {
			outputList.removeChild(outputList.firstChild);
		}
		receiveChatText();
	}
}
}

// http://www.codingforums.com/showthread.php?t=63818
function pressedEnter(field,event) {
	var theCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (theCode == 13) {
		is_new=1;
		sendComment();
		return false;
	} 
	else return true;
}

//does clever things to the input and submit
function checkStatus(focusState) {
	oSubmit = document.forms['chatForm'].elements['submit'];
	if (chatbarText.value != '' || focusState == 'active') {
		oSubmit.disabled = false;
	} else {
		oSubmit.disabled = true;
	}
}

function jal_getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(decodeURI(dc.substring(begin + prefix.length, end)));
}

//autoasigns a random name to a new user
//If the user has chosen a name, use that
function checkName() {
	jalCookie = jal_getCookie("jalUserName");
	shout_user=shoutboxname.value;
	if (jalCookie && shoutboxname.value == '') {
		shoutboxname.value = jalCookie.replace("+"," ");
	}
	else {
		if(shout_user=='') shoutboxname.value=Old_Sname; 
		else Old_Sname=shout_user;
		}
}

function checkUrl() {
	if(shoutboxU.style.display!="none") {
		document.cookie = "jalUrl="+shoutboxU.value+";expires="+DateExpires+";path=/;"
		return;
	}
}

function ChangeBoxSize(MyInt) {
	if(document.getElementById('chatoutput')) {
		var obj=document.getElementById('chatoutput');
		if(MyInt==1) {
			obj.style.height=(obj.offsetHeight+20)+'px';
			document.cookie = "jalHeight="+(obj.offsetHeight-14)+";expires="+DateExpires+";path=/;"
		}
		else if(MyInt==0) {
			hauteur=(obj.offsetHeight-48);
			if(parseInt(hauteur)>0) obj.style.height=hauteur+'px';
			document.cookie = "jalHeight="+(obj.offsetHeight-14)+";expires="+DateExpires+";path=/;"
		}
		else {
			if(jal_getCookie("jalHeight")) obj.style.height=jal_getCookie("jalHeight")+'px';
		}
	}
}
// This script file contains 2 major sections, one for the AJAX chat, and one for the FAT
// technique. The AJAX chat script part is below the FAT part
// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1
// @author    Adam Michela
var Fat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	fade_all : function ()
	{
		var a = document.getElementsByTagName("*");
		for (var i = 0; i < a.length; i++) 
		{
			var o = a[i];
			var r = /fade-?(\w{3,6})?/.exec(o.className);
			if (r)
			{
				if (!r[1]) r[1] = "";
				if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
			}
		}
	},
	fade_element : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 30;
		if (!duration) duration = 3000;
		if (!from || from=="#") from = "#FFFF33";
		if (!to) to = this.get_bgcolor(id);

		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;

		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);

		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);
		var r,g,b,h;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);
		
			setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);

			frame++;
			delay = interval * frame; 
		}
		setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		if(o) o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	}
}
function ChangeURL(id,href,param) {
cat=document.getElementById('shout_cat').value;
if(cat!='') href+=param
document.getElementById(id).href=href+encodeURIComponent(cat);
}

//initiates the XMLHttpRequest object as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function replaceUserOnline(chrono,useronlinetext) {
if(useronlinetext!="") {
	document.getElementById("usersOnline").innerHTML=useronlinetext;
}
document.getElementById("responseTime").innerHTML=chrono;
}

 /*
 * Version 1.0
 */

var $rp_timer = 0;

function rp_timer_click()
{
	rp_change_text(window.rp_current_post + 1);
	rp_start_timer();
}

function rp_start_timer()
{
	$rp_timer = setTimeout("rp_timer_click()", window.rp_timer_sec * 1000);
	document.getElementById("rp_nav_pause").onclick = rp_stop_timer;
	document.getElementById("rp_nav_pause_normal").style.display = "inline";
	document.getElementById("rp_nav_pause_pressed").style.display = "none";
}

function rp_stop_timer()
{
	clearTimeout($rp_timer);
	document.getElementById("rp_nav_pause").onclick = rp_restart_timer;
	document.getElementById("rp_nav_pause_normal").style.display = "none";
	document.getElementById("rp_nav_pause_pressed").style.display = "inline";
}

function rp_restart_timer()
{
	rp_timer_click();
}

function rp_change_text($rp_current)
{
	rp_stop_timer();

	if ($rp_current < 0)
	{
		$rp_current = window.rp_number_posts - 1;
	}
	$rp_current = $rp_current % window.rp_number_posts;

	window.rp_current_post = $rp_current;

	for (i = 0; i < window.rp_number_posts; i++)
	{
		if (i == $rp_current)
		{
			document.getElementById('rp_post' + i).style.display = "block";
			document.getElementById('rp_nav_thumbnail' + i).className = "rp_nav_thumbnail_on";
		}
		else
		{
			document.getElementById('rp_post' + i).style.display = "none";
			document.getElementById('rp_nav_thumbnail' + i).className = "rp_nav_thumbnail_off";
		}
	}
}



$(document).ready(function(){
  $("#content-slider").slider({
    animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });
});

function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
}


/*
 * jQuery Form Tips 1.2.2
 * By Manuel Boy (http://www.manuelboy.de)
 * Copyright (c) 2010 Manuel Boy
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
jQuery.fn.formtips = function(options) {
	
	// handle options
	settings = jQuery.extend({
		tippedClass: "tipped"
	}, options);
	
	return this.each(function() {
		
		jQuery(this).each(function() {
			
			// prepare input elements an textareas
			var e = jQuery(this);
			
			// do not apply form tips to inputs of type file, radio or checkbox
			var type = jQuery(e).attr('type');
			if(type == 'file' || type == 'checkbox' || type == 'radio') { return false; }
			
			// handle focus event
			jQuery(e).bind('focus', function() {
				var lv = jQuery(this).attr('title');
				if(jQuery(this).val() == lv) {
					jQuery(this).val('').removeClass(settings.tippedClass);
				}
				return false;
			});
			
			// handle blur event
			jQuery(e).bind('blur', function() {
				var lv = jQuery(this).attr('title');
				if(jQuery(this).val() == '') {
					jQuery(this).val(lv).addClass(settings.tippedClass);
				}
				return false;
			});
			
			// handle initial text
			var lv = jQuery(e).attr('title');
			if(jQuery(e).val() == '' || jQuery(e).val() == jQuery(this).attr('title')) {
				jQuery(e).val(lv).addClass(settings.tippedClass);
			} else {
				jQuery(e).removeClass(settings.tippedClass);
			}
			
			// handle removal of default value
			jQuery(e).parentsUntil('form').parent().submit(function() {
				var lv = jQuery(e).attr('title');
				if(jQuery(e).val() == lv) {
					jQuery(e).val('').removeClass(settings.tippedClass);
				}
			});
			
		});
		
	});
};
