// Image Ratator
$('#photo-window').cycle({ 
   fx:    'fade', 
   pause:  1,
   random: 1
});

// play sound on button hover
function playSound(soundfile) {
 document.getElementById("dummy").innerHTML=
 "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}

// Appended elements for html validation
$(function(){
	     if ( document.location.href.indexOf('') == 0 ) {
        $('#nav-home').addClass('active');
    }

	     if ( document.location.href.indexOf('about-us') > -1 ) {
        $('#about-us').addClass('active');
        $('#nav-home').removeClass('active');
    }
	  
	   if ( document.location.href.indexOf('equipment') > -1 ) {
        $('#nav-equipment').addClass('active');
        $('#nav-home').removeClass('active');
    }
	   if ( document.location.href.indexOf('catalog') > -1 ) {
        $('#nav-catalog').addClass('active');
        $('#nav-home').removeClass('active');
    }

 		if ( document.location.href.indexOf('contact-us') > -1 ) {
        $('#nav-contact-us').addClass('active');
        $('#nav-home').removeClass('active');
    }

		if ( document.location.href.indexOf('links') > -1 ) {
        $('#nav-links').addClass('active');
        $('#nav-home').removeClass('active');
    }
	
		if ( document.location.href.indexOf('recent-news') > -1 ) {
        $('#nav-recent-news').addClass('active').removeAttr( 'onclick' );
        $('#nav-home').removeClass('active');
       
    }
   
   
	$('head').append('<meta name="fragment" content="!">');
});

// Main Navigation Roller Effect and Sound Event
var roller=function(){
	return{
		init:function(el,ty,sx,ex,d,st){
			e=document.getElementById(el);if(!e){return;}a=e.getElementsByTagName("a");
			for(i=0;i<a.length;i++){
				if(!a[i].id){a[i].id=el.id+i;}
				a[i].n=a[i].o=sx;a[i].en=ex; a[i].ty=ty;				
				if(a[i].ty=='v'){a[i].style.backgroundPosition = '0px '+a[i].n+'px';}
				else if(a[i].ty=='h'){a[i].style.backgroundPosition = a[i].n+'px 0px';}
				else{return;}
				a[i].onmouseover=roller.o;a[i].onmouseout=roller.o;
				a[i].st=Math.abs(Math.abs(ex-sx)/st);a[i].t=d/st;
			}
		},
		o:function(e){
			e=e||window.event;c=e.target!=null?e.target:e.srcElement;
			if(c.nodeName=='A' && e.type=="mouseover"){c.w=c.en;roller.s(c);}
			else if(c.nodeName=='A'){c.w=c.o;roller.s(c);}
		},
		s:function(e){
			if(e.ti){clearTimeout(e.ti);}
			if(Math.abs(e.n-e.w)<e.st){e.n=e.w;}
			else if(e.n<e.w){e.n=e.n+e.st;}
			else if(e.n>e.w){e.n=e.n-e.st;}			
			if(e.ty=='v'){e.style.backgroundPosition = '0px '+e.n+'px';}
			else{e.style.backgroundPosition = e.n+'px 0px';}
			if(e.n==e.w){clearTimeout(e.ti);return;}
			e.ti=setTimeout(function(){roller.s(e)}, e.t);
		}
	}
}();


// Page Calls     
   function home_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideUp('slow');
    $('#header').slideDown('slow', function() {
    window.location = "/wp/index.php"
  });
  }
  
    function about_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
    window.location = "/wp/about-us"
  
  });
  }
    
    function equipment_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
    window.location = "/wp/equipment"
  
  });
  }

    function recent_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
    window.location = "category/recent-news"
  
  });
  }
  
      function catalog_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
    window.location = "/wp/catalog"
  
  });
  }
  
   function contact_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
     window.location = "/wp/contact-us"
  });
  }
  
     function link_request(){
    $("html, body").animate({ scrollTop: 0 }, "slow");
    $('#sub-nav').slideDown('slow');
    $('#header').slideUp('slow', function() {
    window.location = "/wp/links"
  
  });
  }
  

	$('#main-left-sidebar li .side-click').live('click', function(){                       
  $('a').removeClass('current');
  $(this).addClass('current');
  $("#right-content").hide().load($(this).attr("href"));
  $('html,body').animate({scrollTop: $("#main-navigation").offset().top},'slow', function(){
  $('#right-content').fadeIn(600);
  });
  return false;
});
	     
	     
	      $(document).ready(function(){  
        $("#main-left-sidebar li .side-click").hover(function() {  
                $(this).stop().animate({ backgroundColor: "#ffffff"}, 50);  
                },function() {  
                $(this).stop().animate({ backgroundColor: "#eeeeee" }, 800);  
                });  
     });  

     $(document).ready(function(){  
        var textinput = $(this).find(':text');
        $(textinput).hover(function() {  
                $(this).stop().animate({ backgroundColor: "#eeeeee"}, 50);  
                },function() {  
                $(this).stop().animate({ backgroundColor: "#ffffff" }, 800);  
                }); 
        $(textinput).click(function() {         
       $(this).addClass('textactive')
       });          
     });  
