 $(document).ready(function()
{
  $("#usual1").idTabs(); });


/**
 * Simple Water Mark
 * July 18, 2009
 * Corey Hart @ http://www.codenothing.com
 */
/**
 * @mainCSS: Default CSS class used if no metadata found
 */
;(function($){
    $.fn.simpleWaterMark = function(mainCSS){
        if (!mainCSS) mainCSS = 'non-404';
        return this.each(function(){
            var $obj = $(this), title = this.title, css = $.metadata && $obj.metadata().watermark ? $obj.metadata().watermark : mainCSS;

            // Add watermark to begin with
            if ($obj.val() == '' && title && title != '')
                $obj.addClass(css).val(title);

            // Run operations
            $obj.focus(function(){
                if ($obj.hasClass(css))
                    $obj.removeClass(css).val('');
            }).blur(function(){
                if ($obj.val() == '' && title && title != '')
                    $obj.addClass(css).val(title);
            }).parents('form').eq(0).submit(function(){
                if ($obj.hasClass(css))
                    $obj.val('');
            });

            // Clear fields on page unload
            $(window).unload(function(){
                if ($obj.hasClass(css))
                    $obj.removeClass(css).val('');
            });
        });
    };
})(jQuery);




/*
 * runOnLoad.js: portable registration for onload event handlers.
 *
 * This module defines a single runOnLoad() function for portably registering
 * functions that can be safely invoked only when the document is fully loaded
 * and the DOM is available.
 *
 * Functions registered with runOnLoad() will not be passed any arguments when
 * invoked. They will not be invoked as a method of any meaningful object, and
 * the this keyword should not be used.  Functions registered with runOnLoad()
 * will be invoked in the order in which they were registered.  There is no
 * way to deregister a function once it has been passed to runOnLoad().
 *
 * In old browsers that do not support addEventListener() or attachEvent(),
 * this function relies on the DOM Level 0 window.onload property and will not
 * work correctly when used in documents that set the onload attribute
 * of their <body> or <frameset> tags.
 */
function runOnLoad(f) {
    if (runOnLoad.loaded) f();    // If already loaded, just invoke f() now.
    else runOnLoad.funcs.push(f); // Otherwise, store it for later
}

runOnLoad.funcs = []; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.

// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run() more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad() to register another function.
runOnLoad.run = function() {
    if (runOnLoad.loaded) return;  // If we've already run, do nothing

    for(var i = 0; i < runOnLoad.funcs.length; i++) {
        try { runOnLoad.funcs[i](); }
        catch(e) { /* An exception in one function shouldn't stop the rest */ }
    }

    runOnLoad.loaded = true; // Remember that we've already run once.
    delete runOnLoad.funcs;  // But don't remember the functions themselves.
    delete runOnLoad.run;    // And forget about this function too!
};

// Register runOnLoad.run() as the onload event handler for the window
if (window.addEventListener)
    window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;


/*  div hide and show */
 $(document).ready(function(){
$("li.menu").click(function () {
      $("ul.menu").show("slow");
    });       });


/*  tooltip */
$(document).ready(function(){
		$("a#tip").tooltip();
        $("option#option-tip").tooltip({
          xOffset: 45,
	      yOffset: 0,
	});
        $("a#help").tooltip({
          xOffset: 15,
	      yOffset: 10,
		tooltipId: "tooltip-help"
	});

	});

    $(document).ready(function(){

    // This example only specifies a URL to handle the POST request to
    // the server, and tells the script to show the save / cancel buttons
    $(".editme1").editInPlace({
        url: "./journal_mini.php",
        bg_over: "#fefefe",
        field_type: "textarea",
        default_text: "Here you can write to your daily micro journal. Just click here to start!",
        textarea_rows: "1",
        value_required: "true",
        textarea_cols: "70",
        show_buttons: false,
        saving_image: "./images/ajax-loader.gif"
    });

    // This example shows how to call the function and display a textarea
    // instead of a regular text box. A few other options are set as well,
    // including an image saving icon, rows and columns for the textarea,
    // and a different rollover color.
    $(".editme2").editInPlace({
        url: "./server.php",
        bg_over: "#cff",
        field_type: "textarea",
        textarea_rows: "15",
        textarea_cols: "35",
        saving_image: "./images/ajax-loader.gif"
    });

    // A select input field so we can limit our options
    $(".editme3").editInPlace({
        url: "./server.php",
        field_type: "select",
        select_options: "Change me to this, No way:no"
    });

    // Using a callback function to update 2 divs
    $(".editme4").editInPlace({
        url: "./server.php",
        callback: function(original_element, html, original){
            $("#updateDiv1").html("The original html was: " + original);
            $("#updateDiv2").html("The updated text is: " + html);
            return(html);
        }
    });
});

$(document).ready(function() {
      
        $('#login').focus();  
      
   });

$(document).ready(function(){
	$('input[type=text], textarea').simpleWaterMark('watermark');
});

 $(document).ready(function() {

        $('#contact').click(function() {
          $.blockUI({ message: $('#popupContact'),
          focusInput: false,
            overlayCSS:  {
		backgroundColor: '#000',
		opacity:	  	 0.1},
           css: {
       width: '366px',
       top: '80px'}
       });
        });



        $('#send').click(function() {
           $.unblockUI({
            message: "<h1>Message is sended</h1>" });
        });


	//CLOSING POPUP
	//Click the x event!
       	$("#popupClose").click(function(){
		$.unblockUI();
	});

    });


    var default_content="";

$(document).ready(function(){

	checkURL();
	$('ul li a').click(function (e){

			checkURL(this.hash);

	});

	//filling in the default content
	default_content = $('#pageContent').html();


	setInterval("checkURL()",250);

});

var lasturl="";

function checkURL(hash)
{
	if(!hash) hash=window.location.hash;

	if(hash != lasturl)
	{
		lasturl=hash;

		// FIX - if we've used the history buttons to return to the homepage,
		// fill the pageContent with the default_content

		if(hash=="")
		$('#pageContent').html(default_content);

		else
		loadPage(hash);
	}
}


function loadPage(url)
{
	url=url.replace('#page','');

	$('#loading').css('visibility','visible');

	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: 'page='+url,
		dataType: "html",
		success: function(msg){

			if(parseInt(msg)!=0)
			{
				$('#pageContent').html(msg);
				$('#loading').css('visibility','hidden');
			}
		}

	});

}

