$(document).ready(function() {
	
	$("#consumables").tooltip({
			offset: [0, -75],
			delay: 100, 
			effect: 'slide'
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
	
		$("#searchtext").Watermark("Search...");	   
		$('.tabs .tab-active').show(); // show default content
		$('.tabs .header ul a').click(function(){
			$('.tabs .header ul li').removeClass('active');
			$(this).parent().addClass('active'); // make clicked tab active
			$('.tabs .tab').hide(); // hide all content
			$('.tabs').find('#' + $(this).attr('rel')).show(); // and show content related to clicked tab
			return false;
		});
		
		$("a.lightview").fancybox({'overlayShow': true, overlayOpacity:0.9,frameWidth:605,frameHeight:405 });
		$("a.lightview2").fancybox({'overlayShow': true, overlayOpacity:0.9,frameWidth:605,frameHeight:500 });
		
		$("a").focus(function () {
        	$(this).blur();
		});
		$("img.rollover").hover(function () {
			newsrc=$(this).attr('src').replace('.jpg','-over.jpg').replace('.png','-over.png');
        	$(this).attr('src',newsrc);
		},function () {
			newsrc=$(this).attr('src').replace('-over.jpg','.jpg').replace('-over.png','.png');
        	$(this).attr('src',newsrc);
		});
		
		$('.anythingSlider').anythingSlider({
			easing: "easeInOutQuad",
			autoPlay: true,
			delay: 6000,
			startStopped: false,
			animationTime: 600,
			hashTags: true,
			buildNavigation: true,
			pauseOnHover: false,
			startText: "Go",
			stopText: "Stop",
			navigationFormatter: null
				});
		
		$(".anyClass1").jCarouselLite({
	        btnNext: ".next1",
	        btnPrev: ".prev1",
	       	auto: 3000,
			speed: 1000,
			visible: 3
	    });	
	
					$('ul#portfolio').innerfade({
						speed: 1000,
						timeout: 7000,
						type: 'sequence',
						containerheight: '282px'
					});
			});
	
	function sendEmail() 
	{
		$('.submitButton').val('Sending...');
		$('.submitButton').attr("disabled","true");
		$.post('form-contactus.php?r='+Math.random(),{
			visitor_name: $('#visitor_name').val(),
			visitor_email: $('#visitor_email').val(),
			visitor_company: $('#visitor_company').val(),
			visitor_tel: $('#visitor_tel').val(),
			visitor_product: $('#visitor_product').val(),
			visitor_message: $('#visitor_message').val()
		});
		$('#sendStatus').html('<br /><p>Your message has been sent, we will reply as soon as possible.<br /><br />Thank you,<br />AGP Systems</p>');
		$('.submitButton').val('Send Message');
		$('.submitButton').attr("disabled",false);
		$('#contactUsForm').html("");
			
	}


	function hover(thediv,thediv2)
	{
		$('#'+thediv).removeClass('category-bg');
		$('#'+thediv2).removeClass('postioninga');
		$('#'+thediv).addClass('category-bghover');
		$('#'+thediv2).addClass('postioninga-hover');
	}
	
	function hoverout(thediv,thediv2)
	{	
		$('#'+thediv).removeClass('category-bghover');
		$('#'+thediv2).removeClass('postioninga-hover');
		$('#'+thediv).addClass('category-bg');
		$('#'+thediv2).addClass('postioninga');
	}


	
	function clickSub(thediv,div,image){
        $.each($('.'+div),function(){
            if(this.id==thediv){
                if(this.style.display=='none')
                {
                    $('#'+this.id).slideDown(700);
                    $('#'+image).show(700);
                    $('#'+'plus-'+this.id).hide(700)
                }
                else
                {
                    $('#'+this.id).slideUp(700);
                    $('#'+image).show(700);
                    $('#'+'minus-'+this.id).hide(700)
                }
            }else
            {
                $('#'+this.id).slideUp(700);
                $('#'+'minus-'+this.id).hide(700);
                $('#'+'plus-'+this.id).show(700);
            }

        });
	}
	
	function clickSub2(thediv){
			$.each($('.subs2'),function(){
				if(this.id==thediv){
					if(this.style.display=='none')
					{
						$('#'+this.id).slideDown();
					}
					else
					{
						$('#'+this.id).slideUp();
					}
				}else{
					$('#'+this.id).slideUp();
				}

			});
		}
