// ############################ JQUERY DOM READY FUNCTION -------------------------------------->>>>
$(document).ready(function(){

// ############################ Navigation roll overs start
// clear inital visibliity
$(" li.headlink ul ").css({display: "none"});
    $('li.headlink').hover(
      function() { 
// Animate in:             
        if($('ul', this).siblings('a').length){
         $(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(350).show(); 

          $('ul', this).css('padding','0px');
          $('ul', this).siblings('a').css("color", "#cc0000");
        }
      },
      function() { 
// Animate out:   
  $(this).find('ul:first').css({visibility: "hidden"});
        if($('ul', this).siblings('a').length){
          $('ul', this).siblings('a').css("color", "#003366");
        }
      }
    );
//--- remove "current" class so rollovers function correctly
    $("li.headlink").hover(
      function() { 
        if( $(this).hasClass("current")){
          $(this).addClass("ie6current")
        }else{
          $(this).addClass("ie6headlink")      
        }
      },
      function() {
        if( $(this).hasClass("current")){
          $(this).removeClass("ie6current")
        }else{
          $(this).removeClass("ie6headlink")     
        }
      }
    );
// ############################ Navigation roll overs end

// ############################ image rollovers START ##############>>>>
/*
usage:
up image name must end in _off over image name must end in _on
image class must be "rollover"
*/
    $("img.rollover").hover(
     function(){
      this.src = this.src.replace("_off","_on");
     },
     function(){
      this.src = this.src.replace("_on","_off");
     });
// ############################ image rollovers END ##############||||

// ############################ link popups START ##############>>>>
/*
usage:
add attribute popup="width,height"
to any link you want as a popup window
treats images & text docs differently
*/
    $('a').filter(function() { return $(this).attr('popup'); }).each(function() {
      $(this).click(function(){ 
        var dim=$(this).attr('popup').split(",");
        var type=$(this).attr('href').split(".");
        if(type[1]=="jpg"||type[1]=="gif"||type[1]=="png"){
            newWin = window.open("", "", "menubar=0,location=0,toolbar=0,width="+dim[0]+",height="+dim[1]+",resizable,scrollbars=yes"); 
            pageCode = "<html><head><title>IT management software | IT services software | PSA software - Autotask Corporation</title></head>"; 
            pageCode += "<body style=\"margin:5px; padding:0; border:0;\"><img src='" + $(this).attr('href') + "'></body></html>"; 
            newWin.document.write(pageCode); 
            newWin.document.close(); 
        }else{
          !window.open(this.href,"","menubar=0,location=0,toolbar=0,width="+dim[0]+",height="+dim[1]+",resizable,scrollbars=yes");
        }
        return false;
      });
    });
// ############################ link popups END ##############||||


// ############################  check if search text is ' Search Autotask' -- remove if true
		$("#Stext").focus(function() {
			if ($(this).val() == ' Search Autotask') {
				$(this).val('');
        $(this).css('color','#000000');
			}
		});
    
    $("#Stext").blur(function() {
			if ($(this).val() == '') {
				$(this).val(' Search Autotask');
        $(this).css('color','#cccccc');
			}
		});

    
// ############################ toggle show/hide
    $('a').filter(function() { return $(this).attr('toggle'); }).each(function() {
      var sh=$(this).attr('toggle');
      $(this).removeClass("collapse").addClass("expand");
      $(this).html("expand")
      $("#"+sh).css("display","none");

      $(this).click(function(){       
        if($(this).html()=="expand"){
          $(this).removeClass("expand").addClass("collapse");  
          $(this).html("collapse")
        }else{
          $(this).removeClass("collapse").addClass("expand");
          $(this).html("expand")
        }
    
        $("#"+sh).slideToggle("normal");
      });
    });
    
//-------------------------------------dom ready function end
});
// ############################ JQUERY DOM READY FUNCTION END--------------------------------------||||
