/*
 * Pixo- here,crazy things make sense!
 * @author team@pixo.com - http://www.pixo.in
 */
//
$(document).ready(function(){

	

		  		$.smoothAnchors("slow", "swing", false);
		var scrollWidth=0 ;
		var Content = document.getElementById('art-main');
		var scrollBar = document.getElementById('slider');
		var scrollBarBg = document.getElementById('bar');
		var contentH = (Content.offsetHeight)-500;
		var scrollBgH = (scrollBarBg.offsetHeight)-88;
		var scrollContent=0;
		var percent = 0;
		var scrollContent2=0;
		var percent2 = 0;
		$("#slider").draggable({ axis: 'y',iframeFix: true,scroll: false,scrollSpeed: 40,cursor: 'hand',distance: 30,containment: 'parent',drag:function(event, ui) {
		
		clearTimeout(timer);
		},stop:		function(event, ui) {

		scrollTop = parseInt(scrollBar.style.top);
		percent = Math.round(((scrollTop*100)/(myHeight-88)));
		scrollContent= (((Content.offsetHeight)-500)*percent)/100;
		$("html:not(:animated),body:not(:animated)").animate({ "scrollTop": scrollContent}, 700 );
		timer = setTimeout('ShowMessage()', 500);

		}
  });
				$("html:not(:animated),body:not(:animated)").mousewheel(function(event, delta) {
						var scrollTOP;
						var mainH;
						if( typeof( window.innerWidth ) == 'number' ) {
						scrollTOP = window.pageYOffset;
						mainH = Content.innerHeight;
						//window.alert(scrollTOP);
						} 
						else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
						//IE 6+ in 'standards compliant mode'
						scrollTOP = document.documentElement.scrollTop;
						mainH = Content.offsetHeight;
						} 
						else if( document.body && ( document.body.clientHeight ) ) {
						//IE 4 compatible
						scrollTOP = document.body.scrollTop;
						mainH = Content.offsetHeight;
						}
			
				
						if (delta > 0)
						{
							if(scrollTOP > 0){
							//window.alert("Equal or bigger="+document.documentElement.scrollTop+"Height ="+0);
							contPercent = Math.round(((scrollTOP*100)/(Content.offsetHeight-523)));
							scrollContent = scrollTOP-300;
							sliderPOS= (scrollBgH*contPercent)/100;
							//$("#slider").animate({ "top": sliderPOS}, 40 );
							$("html:not(:animated),body:not(:animated)").animate({ "scrollTop": scrollContent}, 250 );
							}
}
						else if (delta < 0)
							
{								
						if(scrollTOP <= (Content.offsetHeight-523)){
						//	window.alert("Equal or bigger="+document.documentElement.scrollTop+"Height ="+(Content.offsetHeight-523));
						contPercent = Math.round(((scrollTOP*100)/(Content.offsetHeight-523)));
						scrollContent = scrollTOP+300;
						sliderPOS= (scrollBgH*contPercent)/100;
						//$("#slider").animate({ "top": sliderPOS}, 100 );
						$("html:not(:animated),body:not(:animated)").animate({ "scrollTop": scrollContent}, 500 );
}

}
						
						event.stopPropagation();
						event.preventDefault();
					});

		ShowMessage();
		document.getElementById('bar').height = myHeight;

});
  		var myHeight = 0;
		  
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myHeight = window.innerHeight;

			//alert("FF");
		  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'

			myHeight = document.documentElement.clientHeight;
			
			//window.alert("IE");
		  } else if( document.body && ( document.body.clientHeight ) ) {
			//IE 4 compatible

			myHeight = document.body.clientHeight;
		
		  }


//Function Loop
function ShowMessage(){ 
			if( typeof( window.innerWidth ) == 'number' ) {
							//scrollContent = window.pageYOffset+300;
							contPercent = Math.round(((window.pageYOffset*100)/((document.getElementById('art-main').offsetHeight)-523)));
							
			
		  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'

							//scrollContent = document.documentElement.scrollTop+300;
							contPercent = Math.round(((document.documentElement.scrollTop*100)/((document.getElementById('art-main').offsetHeight)-523)));

			
		  } else if( document.body && ( document.body.clientHeight ) ) {
			//IE 4 compatible
							//scrollContent = document.documentElement.scrollTop+300;
							contPercent = Math.round(((document.body.scrollTop*100)/((document.getElementById('art-main').offsetHeight)-523)));

		  }
		  					sliderPOS= ((myHeight-88)*contPercent)/100;
							$("#slider").animate({ "top": sliderPOS}, 200 );
							timer = setTimeout('ShowMessage()', 500); 
							
} 

//



$(function(){
	$('#carousel').infiniteCarousel({
		displayTime: 6000,
		textholderHeight : .25,	
		displayProgressBar : 0,
		displayThumbnailBackground: 0

	});
});

	$(function() {
	
		$("#we").click(function() {

			$("#we-div").show( 'blind', 1000 )

			return false;
		});
		
		$("#we-close").click(function() {

			$("#we-div").hide( 'blind', 600 )

			return false;
		});

		$("#hello").click(function() {

			$("#hello-div").show( 'blind', 1000 )

			return false;
		});
		
		$("#hello-close").click(function() {

			$("#hello-div").hide( 'blind', 600 )

			return false;
		});
		
		$("#we2").click(function() {

			$("#we-div").show( 'blind', 1000 )

			return false;
		});

		$("#hello2").click(function() {

			$("#hello-div").show( 'blind', 1000 )

			return false;
		});
		
		/*Portfolio open & Close*/
		var proChk1=0;
		var proChk2=0;
		var proChk3=0;
		var proChk4=0;
		var proChk5=0;
		var proChk6=0;
		var proChk7=0;
		var proChk8=0;
		var proChk9=0;
		var proChk10=0;
		var proChk11=0;
		//Top
	
		//One
		
		
		$("#pro1").click(function() {
		
		if(proChk1==0)
		{

			$("#pro1-fullview").show( 'blind', 1000 )
			
			proChk1=1;
		}
		else{
			proChk1=0;
			$("#pro1-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//Two
		$("#pro2").click(function() {
		
		if(proChk2==0)
		{

			$("#pro2-fullview").show( 'blind', 1000 )
			proChk2=1;
		}
		else{
			proChk2=0;
			$("#pro2-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//Three
				$("#pro3").click(function() {
		
		if(proChk3==0)
		{

			$("#pro3-fullview").show( 'blind', 1000 )
			proChk3=1;
		}
		else{
			proChk3=0;
			$("#pro3-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		
		//Four
		$("#pro4").click(function() {
		
		if(proChk4==0)
		{

			$("#pro4-fullview").show( 'blind', 1000 )
			proChk4=1;
		}
		else{
			proChk4=0;
			$("#pro4-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//Five
		$("#pro5").click(function() {
		
		if(proChk5==0)
		{

			$("#pro5-fullview").show( 'blind', 1000 )
			proChk5=1;
		}
		else{
			proChk5=0;
			$("#pro5-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		
				$("#pro6").click(function() {
		
		if(proChk6==0)
		{

			$("#pro6-fullview").show( 'blind', 1000 )
			proChk6=1;
		}
		else{
			proChk6=0;
			$("#pro6-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		
				$("#pro7").click(function() {
		
		if(proChk7==0)
		{

			$("#pro7-fullview").show( 'blind', 1000 )
			proChk7=1;
		}
		else{
			proChk7=0;
			$("#pro7-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
				
		//8
		$("#pro8").click(function() {
		
		if(proChk8==0)
		{

			$("#pro8-fullview").show( 'blind', 1000 )
			
			proChk8=1;
		}
		else{
			proChk8=0;
			$("#pro8-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//9
		$("#pro9").click(function() {
		
		if(proChk9==0)
		{

			$("#pro9-fullview").show( 'blind', 1000 )
			
			proChk9=1;
		}
		else{
			proChk9=0;
			$("#pro9-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//10
		$("#pro10").click(function() {
		
		if(proChk10==0)
		{

			$("#pro10-fullview").show( 'blind', 1000 )
			
			proChk10=1;
		}
		else{
			proChk10=0;
			$("#pro10-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		//11
			$("#pro11").click(function() {
		
		if(proChk11==0)
		{

			$("#pro11-fullview").show( 'blind', 1000 )
			
			proChk11=1;
		}
		else{
			proChk11=0;
			$("#pro11-fullview").hide( 'blind', 500 )
			

		}
			return false;
		});
		/*
		function callback(){
			setTimeout(function(){
				$('#div-style').removeClass('newClass');
			}, 1500);
		}*/
	});

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

$.event.special.mousewheel = {
	setup: function() {
		if ( this.addEventListener )
			for ( var i=types.length; i; )
				this.addEventListener( types[--i], handler, false );
		else
			this.onmousewheel = handler;
	},
	
	teardown: function() {
		if ( this.removeEventListener )
			for ( var i=types.length; i; )
				this.removeEventListener( types[--i], handler, false );
		else
			this.onmousewheel = null;
	}
};

$.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});


function handler(event) {
	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
	
	event = $.event.fix(event || window.event);
	event.type = "mousewheel";
	
	if ( event.wheelDelta ) delta = event.wheelDelta/120;
	if ( event.detail     ) delta = -event.detail/3;
	
	// Add events and delta to the front of the arguments
	args.unshift(event, delta);

	return $.event.handle.apply(this, args);
}

})(jQuery);

(function($){
	
	$.extend({
			 
		smoothAnchors : function(speed, easing, redirect){
				
			speed = speed || "fast";
			easing = easing || null;
			redirect = (redirect === true || redirect == null) ? true : false;
			
			$("a").each(function(i){
							
				var url = $(this).attr("href");
				
				if(url){
					if(url.indexOf("#") != -1 && url.indexOf("#") == 0){
		
						var aParts = url.split("#",2);
						var anchor = $("a[name='"+aParts[1]+"']");
						
						if(anchor){
																					
							$(this).click(function(){
												   
								if($(document).height()-anchor.offset().top >= $(window).height()
								 || anchor.offset().top > $(window).height()
								 || $(document).width()-anchor.offset().left >= $(window).width()
								 || anchor.offset().left > $(window).width()){
												   
									$('html, body').animate({
										scrollTop: anchor.offset().top,
										scrollLeft: anchor.offset().left
									}, speed, easing, function(){
										if(redirect){ 
											window.location = url 
										}
									});
								
								}
								
								return false;
																
							});
						}
					
					}
					
				}
				
			});
			
		}
	
	});
	
})(jQuery);
//P


//B
(function($){
	$.fn.extend({ 
		infiniteCarousel: function(options)
		{
			var defaults = 
			{
				transitionSpeed : 1500,
				displayTime : 6000,
				textholderHeight : .2,
				displayProgressBar : 1,
				displayThumbnails: 1,
				displayThumbnailNumbers: 1,
				displayThumbnailBackground: 1,
				thumbnailWidth: '20px',
				thumbnailHeight: '20px',
				thumbnailFontSize: '.7em'
			};
		var options = $.extend(defaults, options);
	
    		return this.each(function() {
    			var randID = Math.round(Math.random()*100000000);
				var o=options;
				var obj = $(this);
				var curr = 1;

				var numImages = $('img', obj).length; // Number of images
				var imgHeight = $('img:first', obj).height();
				var imgWidth = $('img:first', obj).width();
				var autopilot = 1;
		
				$('span', obj).hide(); // Hide any text paragraphs in the carousel
				$(obj).width(imgWidth).height(imgHeight);
			
				// Build progress bar
				if(o.displayProgressBar)
				{
					$(obj).append('<div id="progress'+randID+'" style="position:absolute;bottom:0;background:#bbb;left:'+$(obj).css('paddingLeft')+'"></div>');
					
				}
			
				// Move last image and stick it on the front
				$(obj).css({'position':'relative'});
				$('li:last', obj).prependTo($('ul', obj));
				$('ul', obj).css('left',-imgWidth+'px');
				$('ul',obj).width(9999);

				$('ul',obj).css({'list-style':'none','margin':'0','padding':'0','position':'relative'});
				$('li',obj).css({'display':'inline','float':'left'});
			
				// Build textholder div thats as wide as the carousel and 20%-25% of the height
				$(obj).append('<div id="textholder'+randID+'" class="textholder" style="position:absolute;bottom:0px;margin-bottom:'+-imgHeight*o.textholderHeight+'px;left:'+$(obj).css('paddingLeft')+'"></div>');
				var correctTHWidth = parseInt($('#textholder'+randID).css('paddingTop'));
				var correctTHHeight = parseInt($('#textholder'+randID).css('paddingRight'));
				$('#textholder'+randID).width(imgWidth-(correctTHWidth * 2)).height((imgHeight*o.textholderHeight)-(correctTHHeight * 2));
				showtext($('li:eq(1) span', obj).html());
			

				



				function showtext(t)
				{
					// the text will always be the text of the second list item (if it exists)
					if(t != null)
					{
						$('#textholder'+randID).html(t).animate({marginBottom:'-80px', 'opacity':1},500); // Raise textholder

					}
				}

				function borderpatrol(elem)
				{
					
				}
				function anim(direction,dist)
				{
					// Fade left/right arrows out when transitioning
					//$('#btn_rt'+randID).fadeOut(500);
					//$('#btn_lt'+randID).fadeOut(500);
					
					// animate textholder out of frame
					

					if(direction == "next")
					{
						if(curr==numImages) curr=0;
						if(dist>1)
						{
							//to Hide yellow strip
							//$('li:lt(2)', obj).clone().insertAfter($('li:last', obj));
							
							$('ul', obj).animate({left:-imgWidth*(dist+1)},o.transitionSpeed,function(){
								$('li:lt(2)', obj).remove();
								for(j=1;j<=dist-2;j++)
								{
									$('li:first', obj).clone().insertAfter($('li:last', obj));
									$('li:first', obj).remove();
								}

								showtext($('li:eq(1) span', obj).html());
								$(this).css({'left':-imgWidth});
								curr = curr+dist;
								//$('#thumbs'+randID+' a').bind('click', thumbclick).css({'cursor':'pointer'});
							});
						}
						else
						{
							borderpatrol($('#thumb'+randID+'_'+(curr+1)));
							
							// Copy leftmost (first) li and insert it after the last li
							$('li:first', obj).clone().insertAfter($('li:last', obj));	
							// Update width and left position of ul and animate ul to the left
							$('ul', obj)
								.animate({left:-imgWidth*2},o.transitionSpeed,function(){
									$('li:first', obj).remove();
									$('ul', obj).css('left',-imgWidth+'px');
									//$('#btn_rt'+randID).fadeIn(500);
									//$('#btn_lt'+randID).fadeIn(500);
									if(autopilot) $('#pause_btn'+randID).fadeIn(250);
									showtext($('li:eq(1) span', obj).html());
									if(autopilot)
									{
										$('#progress'+randID).width(imgWidth).height(5);
										$('#progress'+randID).animate({'width':0},o.displayTime,function(){
											$('#pause_btn'+randID).fadeOut(50);
											setTimeout(function(){$('#pause_btn'+randID).fadeIn(250)},o.transitionSpeed)
										});
									}
									curr=curr+1;
									//$('#thumbs'+randID+' a').bind('click', thumbclick).css({'cursor':'pointer'});
								});
						}
					}
					if(direction == "prev")
					{
						if(dist>1)
						{
							borderpatrol($('#thumb'+randID+'_'+(curr-dist)));
							$('li:gt('+(numImages-(dist+1))+')', obj).clone().insertBefore($('li:first', obj));
							$('ul', obj).css({'left':(-imgWidth*(dist+1))}).animate({left:-imgWidth},o.transitionSpeed,function(){
								$('li:gt('+(numImages-1)+')', obj).remove();
								//$('#btn_rt'+randID).fadeIn(500);
								//$('#btn_lt'+randID).fadeIn(500);
								$('#play_btn'+randID).fadeIn(250);
								showtext($('li:eq(1) span', obj).html());
								curr = curr - dist;
								//$('#thumbs'+randID+' a').bind('click', thumbclick).css({'cursor':'pointer'});
							});
						}
						else
						{
							borderpatrol($('#thumb'+randID+'_'+(curr-1)));
							$('#thumbs'+randID+' a').css({'cursor':'default'}).unbind('click'); // Unbind the thumbnail click event until the transition has ended
							// Copy rightmost (last) li and insert it after the first li
							$('li:last', obj).clone().insertBefore($('li:first', obj));
							// Update width and left position of ul and animate ul to the right
							$('ul', obj)
								.css('left',-imgWidth*2+'px')
								.animate({left:-imgWidth},o.transitionSpeed,function(){
									$('li:last', obj).remove();
									//$('#btn_rt'+randID).fadeIn(500);
									//$('#btn_lt'+randID).fadeIn(500);
									if(autopilot) $('#pause_btn'+randID).fadeIn(250);
									showtext($('li:eq(1) span', obj).html());
									curr=curr-1;
									if(curr==0) curr=numImages;
									//$('#thumbs'+randID+' a').bind('click', thumbclick).css({'cursor':'pointer'});
								});
						}
					}
				}

				var clearInt = setInterval(function(){anim('next');},o.displayTime+o.transitionSpeed);

  		});
    	}
	});
})(jQuery);
