//jQuery Robot v.01 - Original idea, graphics, mark-up, css and clunkified js script by: Anthony Calzadilla
//jQuery robot script completely rewritten by the very generous folks at: codingcyborg.com

$(document).ready(function(){ 
		
		$('.p_media').animate({opacity: 0}, 0);
		$('.p_media').animate({backgroundPosition: '(800px 30px)',opacity:1, filter: ''},700);
		$('.p_about').animate({opacity: 0}, 0);
		$('.p_about').animate({backgroundPosition: '(800px 30px)',opacity:1, filter: ''},700);
		$('.p_product').animate({opacity: 0}, 0);
		$('.p_product').animate({backgroundPosition: '(800px 350px)',opacity:1, filter: ''},700);
		$('.p_news').animate({opacity: 0}, 0);
		$('.p_news').animate({backgroundPosition: '(150px 00px)',opacity:1, filter: ''},700);
		
		/*---------------------------------*/
		$('.d_index .drop3').animate({opacity: 0, top:'0' }, 0);
		$('.d_index .drop1').animate({opacity: 0, top:'0', left:'350'}, 0);
		$('.d_index .drop2').animate({opacity: 0, top:'0', left:'450'}, 0);
		
		$('.d_index .drop3').animate({top: '+=200',opacity:1, },600, 'swing', function() {
			
			$('.d_index .drop1').animate({top: '+=250',opacity:1},600);
			$('.d_index .drop2').animate({top: '+=210',opacity:1},800);
		});
		/*---------------------------------*/
		$('.d_about .drop3').animate({opacity: 0, top:'0', left:'825' }, 0);
		$('.d_about .drop1').animate({opacity: 0, top:'0', left:'870'}, 0);
		$('.d_about .drop2').animate({opacity: 0, top:'0', left:'910'}, 0);
		
		$('.d_about .drop3').delay(200).animate({top: '+=100',opacity:1},600);
		$('.d_about .drop1').delay(0).animate({top: '+=130',opacity:1},600);
		$('.d_about .drop2').delay(300).animate({top: '+=110',opacity:1},800);
		/*---------------------------------*/
		$('.d_product .drop3').animate({opacity: 0, top:'250', left:'820' }, 0);
		$('.d_product .drop1').animate({opacity: 0, top:'250', left:'880'}, 0);
		$('.d_product .drop2').animate({opacity: 0, top:'250', left:'920'}, 0);
		
		
		$('.d_product .drop3').animate({top: '+=120',opacity:1, },1000);
			
		$('.d_product .drop1').animate({top: '+=200',opacity:1},600);
		$('.d_product .drop2').animate({top: '+=150',opacity:1},900);
		/*---------------------------------*/
		$('.d_news .drop3').animate({opacity: 0, top:'0', left:'140' }, 0);
		$('.d_news .drop1').animate({opacity: 0, top:'0', left:'230'}, 0);
		$('.d_news .drop2').animate({opacity: 0, top:'0', left:'280'}, 0);
		
		$('.d_news .drop3').animate({top: '+=40',opacity:1, },800);
			
		$('.d_news .drop1').animate({top: '+=70',opacity:1},600);
		$('.d_news .drop2').animate({top: '+=50',opacity:1},900);
		
		
			// add a "rel" attrib if Opera 7+
			if(window.opera) {
				if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
					$("a.jqbookmark").attr("rel","sidebar");
				}
			}
		
			$("a.jqbookmark").click(function(event){
				event.preventDefault(); // prevent the anchor tag from sending the user off to the link
				var url = this.href;
				var title = this.title;
		
				if (window.sidebar) { // Mozilla Firefox Bookmark
					window.sidebar.addPanel(title, url,"");
				} else if( window.external ) { // IE Favorite
					window.external.AddFavorite( url, title);
				} else if(window.opera) { // Opera 7+
					alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
					//return false; // do nothing - the rel="sidebar" should do the trick
				} else if(window.chrome){
					var msg = 'Press ctrl+D to bookmark (Command+D for macs) after you click Ok';
					alert(msg);
				} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
					 alert('Unfortunately, this browser does not support the requested action,'
					 + ' please bookmark this page manually.');
				}
		
			});
		
		
		//bounceHim();
  		
		});
		
		function handleSliderChange(e, ui)
		{
		  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
		  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
		}
		
		function handleSliderSlide(e, ui)
		{
		  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
		  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
		}
		
		
		function bounceHim(){
			$("#indexpage").animate({backgroundPosition: '(0px 310px)'},800).animate({ backgroundPosition: '(0px 300px)'},800);
			setTimeout("bounceHim2()",3200);
		}
		function bounceHim2(){				
			$("#indexpage").animate({backgroundPosition: '(0px 310px)'},800).animate({ backgroundPosition: '(0px 300px)'},800);		
			setTimeout("bounceHim()",12000);
		}
	
