// JavaScript Document
$(document).ready(function(){       
// BROWSER Detection //						   
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);


// }
		// This function is making the info messages to slide up when the X is clicked //
		$(".info").click(function() {
			$(this).slideUp("fast");							 	  
		});
		// This is creating a modal box from a hidden element on the page with id #inline_example1 //
		$("#inline_example1").dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true
		});	
		// This is creating a modal box from a hidden element on the page with id #inline_example2 //
		$("#inline_example2").dialog({
			bgiframe: false,
			autoOpen: false,
			modal: true
		});		
		// This triggers the modal dialog box //
		$('.mail').click(function() {
			$('#inline_example1').dialog('open');
		})
		$('a.ajax').click(function(e) {
			e.preventDefault();
			var $this = $(this);
			var horizontalPadding = 18;
			var verticalPadding = 0;
	        $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
	            title: ($this.attr('title')) ? $this.attr('title') : 'External Site',
	            autoOpen: true,
	            width: 800,
	            height: 500,
	            modal: true,
	            resizable: true,
				autoResize: true,
	            overlay: {
	                opacity: 0.5,
	                background: "black"
	            }
	        }).width(800 - horizontalPadding).height(500 - verticalPadding);	        
		});

		$('a.ajax2').click(function() {
                        var url = this.href;
						var title = this.title; 
                        var dialog = $('<div style="display:hidden"></div>').appendTo('body');
                        // load remote content
                        dialog.load(
                                url, 
                                {},
                                function (responseText, textStatus, XMLHttpRequest) {
                                        dialog.dialog({ modal: true, width: 600, height: 500, resizable: true, title: title });
                                }
                        );
                        //prevent the browser to follow the link
                        return false;
                });
// The functions below are made as FX for table operations //
if ( $(".approve_icon").length > 0 ) {		
		$(".approve_icon").click(function() { 
			$(this).parents("tr").css({ "background-color" : "#e1fbcd" }, 'fast'); 
				// THE ALERT BELOW CAN BE REMOVED - you can put any function here linked to the approve icon link in the table //
				alert('this is approved');
			});
}
if ( $(".reject_icon").length > 0 ) {	
		$(".reject_icon").click(function() { 
			$(this).parents("tr").css({ "background-color" : "#fbcdcd" }, 'fast'); 	
				// THE ALERT BELOW CAN BE REMOVED - you can put any function here linked to the reject icon link in the table //
			alert('this is rejected');
			});
}
if ( $(".delete_icon").length > 0 ) {	
		$(".delete_icon").click(function() { 
			$(this).parents("tr").css({ "background-color" : "#fbcdcd" }, 'fast'); 
			// THE ALERT BELOW CAN BE REMOVED - you can put any function here linked to the delete icon link in the table //
			alert('this is deleted!');
			// And we make the deleted row to dissapear! //
			$(this).parents("tr").fadeOut("fast");
			});
}
// This triggers the 2nd modal box when clicked on the TIP link on the right of the title - forms.html //
if ( $(".inline_tip").length > 0 ) {
		$(".inline_tip").click(function() { 
			$("#inline_example2").dialog('open');
		});
}
});
// THE jQuery scripts end here //

// Below is the "allbox" script for selecting all checkboxes in a table by clicking one of them - usualy the on in the table heading //

if ( $("#allbox").length > 0 ) {		
	function checkAll(){
		for (var i=0;i<document.forms[0].elements.length;i++)
		{
			var e=document.forms[0].elements[i];
			if ((e.name != 'allbox') && (e.type=='checkbox'))
			{
				e.checked=document.forms[0].allbox.checked;
			}
		}
	}
}
