function scrollbarWidth() {
    var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
    // Append our div, do our calculation and then remove it
    $('body').append(div);
    var w1 = $('div', div).innerWidth();
    div.css('overflow-y', 'scroll');
    var w2 = $('div', div).innerWidth();
    $(div).remove();
    return (w1 - w2);
}	





function isIE() {
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function rw_trigger(height1, height2) {
	var height1 = $("#main-content-div").height();
	var height2 = $("#right-wraper").outerHeight();
	
	if(height2 < height1)
		 return $("#right-wraper").height(height1);
	
	else return false;
}

// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////



$(document).ready(function(){

	
	
	
	var site = "";
	//var site="";						// for the server
	//alert("access");
/* PRINT THE PAGE ////// */

$("#print-content").click(function(){
	// Print the DIV.
	//alert("sdfsd");
	
// options for the print process
/*{printMode: 'popup', pageTitle: 'thisWillBeTheNameInThePrintersLog.html', overrideElementCSS: ['http://assets3.github.com/stylesheets/bundle.css'] }*/	
var options = { pageTitle: $("#middle-content-title").text() };
	$("div#middle-col").printElement( options );
  
 // Cancel click event.
	//return false;
});

/* //////////////////////// */
	
	if ($.browser.msie && $.browser.version.substr(0,1)<=8 || ($.browser.opera)) {
		$("head").append("<link>");
    	css = $("head").children(":last");
    	css.attr({
     		rel:  "stylesheet",
     		type: "text/css",
	    	href: "/settings/ie-hacks.css",
	    	media: "screen"
        });
    }
	
	/*
    else {
    //loadjscssfile("/Argus/settings/main-menu_all.css", "css");	
    $("head").append("<link>");
    	css = $("head").children(":last");
    	css.attr({
     		rel:  "stylesheet",
     		type: "text/css",
	    	href: site+"/settings/main_menu_all.css",
	    	media: "screen"
        });
    }
*/

		
	




   	
	if($('.slideshow').length>0) {
		$('.slideshow').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}


	


////////////////////////////////////////////// /* FEEDBACK PANEL */
$("#close-btn").click(function(){
	 
  $('.content').fadeOut('slow', function() { //fade out the content 
      $('#panel').stop().animate({width:"0", opacity:0.1}, 500); //slide the #panel back to a width of 0
  });
});

$("#panel, .content").hide(); //hides the panel and content from the user
 
   $('#tab').toggle(function(){ //adding a toggle function to the #tab
      $('#panel').stop().animate({width:"400px", opacity:0.8}, 500, function() {//sliding the #panel to 400px
	  $('.content').fadeIn('slow'); //slides the content into view.
	  });  
   },
   function(){ //when the #tab is next cliked
   $('.content').fadeOut('slow', function() { //fade out the content 
      $('#panel').stop().animate({width:"0", opacity:0.1}, 500); //slide the #panel back to a width of 0
	  });
   });

// validating the data
	$('.error').hide(); 
	$("#submit_btn").click(function() {
      // validate and process form here

      $('.error').hide();
	  
	  var url = $("input#url").val();
  		if (url == "") {
        $("label#url_error").show();
        $("input#url").focus();
        return false;
      	}
	  
  	  var name = $("input#name").val();
  		if (name == "") {
        $("label#name_error").show();
        $("input#name").focus();
        return false;
      	}
  		
  		var comment = $("textarea#comment").val();
  		if (comment == "") {
        $("label#comment_error").show();
        $("textarea#commment").focus();
        return false;
      	}
		
	var dataString = 'name='+ name + '&comment=' + comment + '&url=' + url;
	//alert(dataString);
  	//alert (dataString);return false;
	

	
  	$.ajax({
    	type: "POST",
    	url: "/feedbacks/send",
    	data: dataString,
    	success: function(r) {
      		$('#feedback_form').html("<div id='message'></div>");
			//alert(r);
      		$('#message').html(r)
      		//.append("<p>We will be in touch soon.</p>")
			
      		.hide()
      		.fadeIn(1500);
    	}
 	 });
  	return false;
	
    });

}); // document.ready


