
function Inint_AJAX()
{
  try
  {
    return new ActiveXObject( "Msxml2.XMLHTTP" ); //IE
  }
  catch( e )
  {
  }
  try
  {
    return new ActiveXObject( "Microsoft.XMLHTTP" ); //IE
  }
  catch( e )
  {
  }
  try
  {
    return new XMLHttpRequest(); //Native Javascript
  }
  catch( e )
  {
  }
  alert( "XMLHttpRequest not supported" );
  return null;
};
function loadcalendar1( query )
{
		 document.getElementById( 'calendar' ).innerHTML ="Loading calendar...";

		//jQuery("#mnt").html("¡ÓÅÑ§âËÅ´....");
	var req = Inint_AJAX();
  req.open( "POST" , "calendar.php" , true );
  req.onreadystatechange = function()
  {

	 
    if ( req.readyState == 4 )
    {
     if ( req.status == 200 )
     {

		
       document.getElementById( 'calendar' ).innerHTML = req.responseText;
     };
    };
  };
  req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
  req.send( query );
};




 function CreateBookmarkLink() {

 var title = "Plant Maintenance Technology Center"; 
  
var  url = "http://www.tgipmt.com";
  

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

 function subscribe()
{

jQuery('#submit_bt').hide();
	jQuery('#sub_ajax_loading').show();
	var str = jQuery('#subscrfrm').serialize();  
	jQuery.ajax({  
    type: "POST",
    url: "/authentication_helper.php",  // Send the login info to this page
    data: str,  
    success: function(msg){  
  
		jQuery("#subscr_input").ajaxComplete(function(event, request, settings){  
			 
			jQuery('.errorTip').remove();
			jQuery('#submit_bt').show();
			jQuery('#sub_ajax_loading').hide();  
			var arz =msg.split("^");
			
			jQuery('#subresult').hide();
			if ( arz[0] =="error"){
				var arx =arz[1].split("|");
				for (i=0;i< arx.length;i++)
				{
					var ary=arx[i].split(":");

					if (document.getElementById( ary[0])!=null){
						jQuery('input[type=text]').each(function(){
						var elem = jQuery(this);
						
						var id = elem.attr('id');
						if(id==ary[0])showTooltip(elem,ary[1]);
												
						});
					}
	
				}
			}else{

				jQuery('#subresult').show();
					
					document.getElementById("name").value="";
					document.getElementById("email").value="";

					jQuery('#subresult').html(arz[0]);
				
			}

		});

	}


});


	

}


// Helper function that creates an error tooltip:
function showTooltip(elem,txt)
{
	// elem is the text box, txt is the error text
	jQuery('<div class="errorTip">').html(txt).appendTo(elem.closest('.wrapper'));
	 
}





jQuery(function(){
	jQuery("ul#navi_containTab > li").eq(0).addClass('navactive');
	jQuery("ul#navi_containTab > li").click(function(event){
			var menuIndex=jQuery(this).index();
			jQuery("ul#navi_containTab > li").removeClass('navactive');
			jQuery("ul#navi_containTab > li").eq(menuIndex).addClass('navactive');
			
			jQuery("ul#detail_containTab > li:visible").hide();			
			jQuery("ul#detail_containTab > li").eq(menuIndex).fadeIn(1000);
	});
});





function loadcalendar( query )
{
  var req = Inint_AJAX();
  req.open( "POST" , "/calendar.php" , true );
  req.onreadystatechange = function()
  {
    if ( req.readyState == 4 )
    {
     if ( req.status == 200 )
     {

		 
       document.getElementById( 'calendar' ).innerHTML = req.responseText;
jQuery(function () {
	jQuery('.date_has_event').each(function () {
		// options
		var distance = 10;
		var time = 250;
		var hideDelay = 100;

		var hideDelayTimer = null;

		// tracker
		var beingShown = false;
		var shown = false;

		var trigger = jQuery(this);
		var popup = jQuery('.events ul', this).css('opacity', 0);

		// set the mouseover and mouseout on both element
		jQuery([trigger.get(0), popup.get(0)]).mouseover(function () {
			// stops the hide event if we move from the trigger to the popup element
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// don't trigger the animation again if we're being shown, or already visible
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;

				// reset position of popup box
				popup.css({
					bottom: 20,
					left: -76,
					display: 'block' // brings the popup back in to view
				})

				// (we're using chaining on the popup) now animate it's opacity and position
				.animate({
					bottom: '+=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					// once the animation is complete, set the tracker variables
					beingShown = false;
					shown = true;
				});
			}
		}).mouseout(function () {
			// reset the timer if we get fired again - avoids double animations
			if (hideDelayTimer) clearTimeout(hideDelayTimer);

			// store the timer so that it can be cleared in the mouseover if required
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				popup.animate({
					bottom: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					// once the animate is complete, set the tracker variables
					shown = false;
					// hide the popup entirely after the effect (opacity alone doesn't do the job)
					popup.css('display', 'none');
				});
			}, hideDelay);
		});
	});
});




     };
    };
  };
  req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
  req.send( query );
};









