

//this function initializes the httpxml object
var http;
function ajax_init()
{
//window.onload = function(){ alert("welcome"); }
jQuery(document).ready(function()
{
  jQuery("abbr.timeago").timeago();
});

}//init()




        //this function tokenizes a string and return a token at a certain index
        function  getTokenAt(input,token_at,delim,numtokens)
    { 
             //input= new Array();
             input = input.split(delim,numtokens);

             var token = input[token_at];
            // alert(" gettoken returns"+token);
            
             return token;
    }//getTokenAt()


//this function shows the spinner
function showSpinner(div_id)
{
    /*new Spinner(div_id,
    {
      radii:     [12, 22],
      color:     '#ed145b',
      dashWidth: 1,
      dashes:    35,
      opacity:   .8,
      speed:     .7
    }).play();*/
    
$('#'+div_id).
    html("<div id='div_spinner'></div>");

    new Spinner('div_spinner',
    {
      radii:     [12, 22],
      dashWidth: 1,
      dashes:    35,
      opacity:   .8,
      speed:     .7
    }).play();

}//showSpinner


       //this function clears the date field when it is clicked
function clearField(control_name,field_text)
{  //alert("Compare "+document.getElementById(control_name).value+" and "+field_text);
    if (document.getElementById(control_name).value==field_text)
     {
         document.getElementById(control_name).value="";
     }
}//clearDateField()

//this function clears the date field when it is clicked
function unClearField(control_name,field_text)
{
     if (""==document.getElementById(control_name).value)
      document.getElementById(control_name).value=field_text;
}//unClearDateField()

//this function clears content from a div
function clearDiv(div)
{ 
    document.getElementById(div).innerHTML='';
}//clearDiv()


//this function clears content from a div
function closeDialog(div)
{
   $( "#"+div).hide( "fade" );
   $( "#"+div).dialog( "close" );

}//clearDiv()


//this function adds suggestions for a specific input box/item
function common_addSuggestions(control_name,availableTags)
{
      //alert(availableTags.length);
      //for(var i=0; i<availableTags.length; i++)
      // alert(availableTags[i]);    
	$(function()
        {		                
		$( "#"+control_name).autocomplete
                ({
			source: availableTags
		});
	});
	
}//common_addSuggestions

//this function shows on the timeline the timestamp difference
function showTimelineTimeAgo(timeago_class)
{
  //window.onload = function(){ alert("welcome"); }
jQuery(document).ready(function()
{
  jQuery("abbr."+timeago_class).timeago();
});

  // $("#"+div_showTimelineTimeStampDiff).html(timestamp_diff);
}//showTimelineTimeStampDiff()


//this function creates an accordion
function showAccordion(control_name)
{
     var icons = {
			header: "ui-icon-circle-arrow-e",
			headerSelected: "ui-icon-circle-arrow-s"
		};
    $(function()
    {
          $( "#"+control_name).accordion({
			autoHeight: false,
			navigation: true
		});


    });

  $( "#"+control_name).accordion({
            icons: icons
    });
		              
}//showAccordion()


function checkAllBoxes(class_name)
{
    $(":checkbox."+class_name).map(function ()
    {
     this.checked = true;
    }).get();
}

function unCheckAllBoxes(class_name)
{
    $(":checkbox."+class_name).map(function ()
    {
     this.checked = false;
    }).get();
}


function reloadSite(reload_link)
{
    window.location = reload_link;
}

function updateWindowTitle(title_text)
{
   document.title = title_text;

}


function common_closeDivSlow(div)
{
    $("#"+div).hide("slow");
}


function common_closeDivFast(div)
{
    $("#"+div).hide("slow");
}


function common_showWidgetSortable(div)
{
    $(function()
    {
        $("#"+div).sortable();        
        $("#"+div).enableSelection();
    });
}


//this function reset the accomodation reservation form
function common_resetControlValue(control_id,value)
{
    $("#"+control_id).val(value);
}//common_resetControlValue


//this function reset the accomodation reservation form
function common_resetTextEditorValue(control_id,value)
{
     $('#'+control_id).html(value);
}//common_resetControlValue()
