/* Rockstah Media JS V1 */

/* IMAGE CYCLE */

;(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery);



/* CYCLE */

(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);


(function($){var ws_activeItemClass="dpui-ws-active",ws_itemsClass="dpui-ws-item";$.widget("ui.wideScroller",{options:{offsetLocatorID:'#locator',containerID:'#scroller-container',loaderID:'#scroller-spinner',nextButtonClass:'.next',prevButtonClass:'.prev',showItemNumbers:true,currentItemDisplayClass:'.ws-currentItem',totalItemDisplayClass:'.ws-totalItems',goToItem:null,easing:'swing',speed:300},_create:function(){var self=this,o=this.options,e=this.element;e.addClass("dpui-widget");$(window).resize($.throttle(500,function(){self.resize();}));self._bindControls();self.itemsLength=$("."+ws_itemsClass).length;if(self.itemsLength<=1){$(o.prevButtonClass+", "+o.nextButtonClass).hide();}
if(o.goToItem!==null){self._reOrderItems();}
self._initialState=e.html();self.setItemPosition();},_bindControls:function(){var self=this,o=this.options;$(o.nextButtonClass).bind('click',function(event){self.moveNext();self._unbindControls();self._trigger('nextButtonClick',event);return false;});$(o.prevButtonClass).bind('click',function(event){self.movePrev();self._unbindControls();self._trigger('previousButtonClick',event);return false;});$("#swipe-test").bind('swipeleft',function(event){self.moveNext();self._unbindControls();self._trigger('nextButtonClick',event);event.stopPropagation();});$("#swipe-test").bind('swiperight',function(event){self.movePrev();self._unbindControls();self._trigger('previousButtonClick',event);event.stopPropagation()});},_unbindControls:function(){var o=this.options;$(o.prevButtonClass+","+o.nextButtonClass+",#swipe-test").unbind();},_reOrderItems:function(){var o=this.options,items=$("."+ws_itemsClass);items.removeClass(ws_activeItemClass);$(items[o.goToItem-1]).addClass(ws_activeItemClass);for(var i=0;i<(o.goToItem-1);i++){$(items[i]).detach().appendTo(o.containerID);}
items=null;},setItemPosition:function(){var self=this,o=this.options,windowOffset=$(o.offsetLocatorID).offset(),windowWidth=$(window).width(),items=$("."+ws_itemsClass),offsetWidth=0,leftWidth=0,overflowElements=[],count=0;$.each(items,function(){if(offsetWidth===0){$(this).css('left',windowOffset.left);offsetWidth=$(this).outerWidth();}else{if((offsetWidth+windowOffset.left)>=windowWidth){overflowElements[count]=this;count++;}else{$(this).css('left',(offsetWidth+windowOffset.left));offsetWidth+=$(this).outerWidth();}}});overflowElements.reverse();$.each(overflowElements,function(){leftWidth+=$(this).outerWidth();$(this).css('left',(windowOffset.left-leftWidth)).prependTo(o.containerID);});self._updateItemNumber();self.hideLoader();},moveNext:function(){var self=this,o=this.options,e=this.element,windowWidth=$(window).width(),items=$("."+ws_itemsClass),itemsLength=$("."+ws_itemsClass).length,activeItem=e.find("."+ws_activeItemClass),totalWidth=0;self._highlightItem('next');var lastItem=$(items).last();var offset=lastItem.offset();self.swappedElement=$(items).first();$('<div></div>').html(self.swappedElement.html()).addClass(ws_itemsClass).css('left',(lastItem.outerWidth()+offset.left)).appendTo(o.containerID);lastItem=$("."+ws_itemsClass).last();totalWidth=(parseInt(lastItem.css("left"),10)+lastItem.outerWidth())-activeItem.outerWidth();if(totalWidth<windowWidth){var i=0;while(totalWidth<=windowWidth){i++;$(items[i]).css('left',(lastItem.outerWidth()+lastItem.offset().left)).detach().appendTo(o.containerID);totalWidth+=$(items[i]).outerWidth();lastItem=$(items[i]);}}
var moveDistance=activeItem.outerWidth()+"px";self._scroll('next',moveDistance,function(){self._scrollOnComplete('next');});},movePrev:function(){var self=this,o=this.options,e=this.element,windowWidth=$(window).width(),items=$("."+ws_itemsClass),activeItem=e.find("."+ws_activeItemClass);self.shortClass="";self.nextItem="";self._highlightItem('prev');var lastItem=$("."+ws_itemsClass).last();var totalWidth=(parseInt(lastItem.css("left"),10)+lastItem.outerWidth())-activeItem.outerWidth();if(lastItem.offset().left+self.nextItem.outerWidth()>windowWidth){var firstItem=$(items).first();var offset=firstItem.offset();self.swappedElement=$(items).last();$('<div></div>').html(self.swappedElement.html()).addClass(ws_itemsClass+" "+self.shortClass).css('left',(offset.left-self.swappedElement.outerWidth())).prependTo(o.containerID);}
var moveDistance=self.nextItem.outerWidth()+"px";self._scroll('prev',moveDistance,function(){self._scrollOnComplete('prev');});},_scroll:function(direction,distance,callback){var self=this,o=this.options,e=this.element,count=0;self._trigger('startScroll');switch(direction){case"next":$("."+ws_itemsClass).animate({'left':"-="+distance},o.speed,o.easing,function(){count++;if(count>=$("."+ws_itemsClass).length){callback();}});break;case"prev":$("."+ws_itemsClass).animate({'left':"+="+distance},o.speed,o.easing,function(){count++;if(count>=$("."+ws_itemsClass).length){callback();}});break;default:break;}},_scrollOnComplete:function(direction){var self=this,o=this.options;if(self.swappedElement){self.swappedElement.remove();self.swappedElement=null;}
self._bindControls();self._updateItemNumber(direction);self._trigger('stopScroll');},_highlightItem:function(direction){var self=this,o=this.options,e=this.element,activeItem=e.find("."+ws_activeItemClass);if(direction==="next"){self.nextItem=activeItem.next();}else{if(activeItem.prev().length!==0){self.nextItem=activeItem.prev();}else{self.nextItem=$("."+ws_itemsClass).last();self.shortClass=ws_activeItemClass;}}
activeItem.removeClass(ws_activeItemClass);self.nextItem.addClass(ws_activeItemClass);},_updateItemNumber:function(direction){var self=this,o=this.options,e=this.element;if(o.showItemNumbers){var currentPage=parseInt($(o.currentItemDisplayClass).html(),10);$(o.totalItemDisplayClass).html(self.itemsLength);switch(direction){case"next":if(currentPage<self.itemsLength){currentPage++;}else{currentPage=1;}
$(o.currentItemDisplayClass).html(currentPage);break;case"prev":if(currentPage>1){currentPage--;}else{currentPage=self.itemsLength;}
$(o.currentItemDisplayClass).html(currentPage);break;default:$(o.currentItemDisplayClass).html("1");break;}}},resize:function(){var self=this,o=this.options,e=this.element;e.html(self._initialState);self.setItemPosition();self._trigger('resize');},hideLoader:function(){var self=this,o=this.options;if(o.loaderID!==null){setTimeout(function(){$(o.loaderID).fadeOut();},800);}},showLoader:function(){var self=this,o=this.options;if(o.loaderID!==null){setTimeout(function(){$(o.loaderID).fadeIn();},800);}},destroy:function(){var self=this,o=this.options,e=this.element;e.removeClass('rid-widget');$(o.nextButtonClass).unbind('click');$(o.prevButtonClass).unbind('click');self.hideLoader();e.html(self._initialState);$("."+ws_itemsClass).css('left','0');$.Widget.prototype.destroy.apply(this,arguments);return this;}});})(jQuery);

/* SCROLL TO */

;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

jQuery(document).ready(function($)
	{
	jQuery('a.toppage').click(function(){
	$.scrollTo( 0, 500);
	return false;
	});


    jQuery('#image_holder').cycle({
		fx: 'fade'
	});
	
	jQuery('').append('<span class="roll_fade">&nbsp;</span>');
	
	jQuery('').hover(
	
		function() {
		
			jQuery(this).children('span.roll_fade').fadeIn();
		
		},
		
	
		function() {

			jQuery(this).children('span.roll_fade').fadeOut();
		
		}
	
	);
	
	jQuery('.client_box img').hover(
		
		function() {
	
			jQuery(this).animate({'opacity' : '1'});
		
	},
		function() {
		
			jQuery(this).animate({'opacity' : '0.7'});
		
		}
		
	);

	jQuery('.client_box img').click(function() {
	
		jQuery('#client_blocks').find('.highlighted').removeClass('highlighted').animate({'opacity' : '0.7'});

		jQuery(this).animate({'opacity' : '1'}).addClass('highlighted');
		
		jQuery('#client_blocks').find('.client_text_shown').removeClass('client_text_shown').slideUp();
		
		var clientName = jQuery(this).siblings('h3').html(),
			clientText = jQuery(this).siblings('div').html();
									
		if (jQuery(this).parent().siblings('.client_content_holder').css('display') === 'block') {
			
			var getSlider = jQuery(this).parent().siblings('.client_content_holder:first');
			
			jQuery(this).parent().siblings('.client_content_holder').slideUp( function() {
				
				jQuery(this).children('h3').empty();		
				jQuery(this).children('.client_about').empty();
		
				jQuery(this).children('h3').append(clientName);
				jQuery(this).children('.client_about').append(clientText);
				jQuery(getSlider).addClass('client_text_shown').slideDown();
				
			});				
		
		} else {

			jQuery(this).parent().siblings('.client_content_holder:first').children('h3').empty();		
			jQuery(this).parent().siblings('.client_content_holder:first').children('.client_about').empty();
		
			jQuery(this).parent().siblings('.client_content_holder:first').children('h3').append(clientName);
			jQuery(this).parent().siblings('.client_content_holder:first').children('.client_about').append(clientText);
			jQuery(this).parent().siblings('.client_content_holder:first').addClass('client_text_shown').slideToggle();
			
		}
					
	});


	jQuery('#services_offered h3').click(function() {

		if (jQuery(this).next('div').css('display') === 'block') {
		
			jQuery(this).next('div').slideUp().removeClass('service_select');
					
		} else {
		
			jQuery('#services_offered .service_select').slideUp( function() {
				
				jQuery(this).removeClass('service_select');
				
			});
		
			jQuery(this).next('div').slideDown().addClass('service_select');
		
		}
		
	});

	if (jQuery('ol.forms li input, ol.forms li textarea').val() == '') {
	
		jQuery('ol.forms li label.form_label').css({'top' : '33px'});
	
		jQuery('ol.forms li input, ol.forms li textarea').focus( function() {
		
			jQuery(this).prev('label').animate({'top' : '0px'});
				
		});					
	
	}
	
	
});

$(document).ready(function () {
	$('body').removeClass('nojs');
	$('html').removeClass('nojshtml');

	var siteURLapd = "http://" + top.location.host.toString();

    var $textContent = $("#case_study_dump"),
        $blockContent = $("#case_study_content"),
        URL = '',
        siteURL = "http://" + top.location.host.toString(),
        $internalLinks = $("a[href^='"+siteURL+"']"),
        hash = window.location.hash;


    $("a.case_link").live("click", function(e) {
        e.preventDefault();

		if ($textContent.css('display') === 'block') {
	        $textContent.slideUp( function() {
	            $textContent.empty();		        
	        });
		}
				
        $ajaxSpinner = $('#case_study_content .spinner_gif');
    	$ajaxSpinner.fadeIn();
        $textContent.slideUp();
        URL = $(this).attr("href");
        $textContent.load(URL + " #case_study_collection", function() {
	        	$textContent.slideDown();
      	        $ajaxSpinner.fadeOut();
        });
   	});


        $(function() {
            $("#scroller").wideScroller();
        });
	
	
	$('form#contactForm').submit(function() {
		$('form#contactForm .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).after('<span class="error '+labelText+'error" style="display:none;">You forgot to enter a '+labelText+'</span>');
				$(this).next('span').slideDown();
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
	$('form#contactForm li.buttons button').fadeOut('normal', function() {
		$(this).parent().append('');
	});
	$("#form_sending").fadeIn('normal');
	
	var formInput = $(this).serialize();
	$.post($(this).attr('action'),formInput, function(data){
		$("#form_sending").fadeOut('normal');
		$("form#contactForm").before('<p class="thanks round_nav">Thank You for your query. We will be in touch as soon as possible.</p>');
	});
	$("form#contactForm").fadeOut();
	}
	
		return false;
		
	});
    		
});


$(document).ready(function () {

	$('#left_col a').hover(
	
		function() {

			if (jQuery(this).hasClass('add_to_fav')) {
		 	  	
	 		  	$(this).css('color','#BEBEBE').animate({'color': '#7a7a7a'});	 		
			
			} else if (jQuery(this).hasClass('more_info')) {
			
	 		  	$(this).css('color','#959595').animate({'color': '#ffffff'});	 		
			
	 		} else {
	 		
	 		  	$(this).css('color','#757575').animate({'color': '#9B9FA1'});
	 		
	 		}
						
		},
		function() {

			if (jQuery(this).hasClass('add_to_fav')) {
		
				$(this).animate({'color': '#BEBEBE'});
		
			} else if (jQuery(this).hasClass('more_info')) {
			
				$(this).animate({'color': '#959595'});

			} else {
			
				$(this).animate({'color': '#757575'});
			
			}
		}
		
	);		
		
});
