//<![CDATA[


function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function getCookie(c_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function checkCookie()
{
	username=getCookie('brala');
	if (username!=null && username!="")
	  {
	  alert('Welcome again '+username+'!');
	  }
	else
	  {
	  username=prompt('Please enter your name:',"");
	  if (username!=null && username!="")
	    {
	    setCookie('username',username,1);
	    }
	  }
}

$(document).ready(function() { 

 $('#sideMenuFiltering li').each(function(index) {
 	$(this).removeClass("nodisplay");
 });

 $('.contentAreaSection').each(function(index) {
 	var contentText = $(this).html();
 	contentText =contentText.replace(/\s/g, '');
 	if (contentText == ""){
 		$(this).addClass("nodisplay");
 	}
 });

	var moreFlag = 0;
	$('.readmorePromo').click(function() {
		$('.hiddenText').slideToggle("slow", function() {
			if ( moreFlag == 0 ) {
				$('.readmorePromo').text("Read less").css("background-image", "url(/getimage.aspx?id=250880)");
				moreFlag = 1;
			} else {
				$('.readmorePromo').text("Read more").css("background-image", "url(/getimage.aspx?id=250879)");
				moreFlag = 0;
			}
		});
	});

	arr = [0, 1, 2, 3, 4]
	var remove=new Array(); 

	$.each(arr, function(key, value) { 
		if ($('#anim_dpromo_'+value+' img').length == 0) {
			$('#anim_dpromo_'+value).remove();
			remove[key]=value;
		}
	});

	$.each(remove, function(key, value) { 
		arr.remove(value);
	});
	
	var adjustedHigh = (parseFloat(arr.length) - parseFloat(1)) + 1;
  var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(1);
	var removeItem = numRand;
	arr.splice((removeItem-1),1);


	$('#home_promo').anythingSlider({
				startStopped    : false, // If autoPlay is on, this can force it to start stopped
				width           : 950,   // Override the default CSS width
				height          : 332,   // Override the default CSS width
				autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
				pauseOnHover    : true,
				resumeDelay     : 7000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
				buildArrows     : false, 
				buildNavigation : false,
				animationTime   : 800,
        hashTags				: false,
				delay           : 14000,
				easing: 'easeInOutExpo',
				onSlideComplete : function(slider){
					$("#logosSmall a").stop().animate({ backgroundColor: "#cccccc"}, 400);
					$("#logosSmall a").removeClass("aktPro");
					$("#logosSmall a").eq(slider.currentPage-1).stop().animate({ backgroundColor: "#ffffff"}, 400);
					$("#logosSmall a").eq(slider.currentPage-1).addClass("aktPro");
				}
			});

	$('#clients_carousel').anythingSlider({
				startStopped    : false, // If autoPlay is on, this can force it to start stopped
				width           : 285,   // Override the default CSS width
				height          : 205,   // Override the default CSS width
				autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
				pauseOnHover    : true,
				resumeDelay     : 7000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
				buildArrows     : false, 
				buildNavigation : false,
				animationTime   : 800,
        hashTags				: false,
				delay           : 14000,
				easing: 'easeInOutExpo',
				onSlideComplete : function(slider){
					// alert('Welcome to Slide #' + slider.currentPage);
				}
			});

	$('.carousellWrap .anim_prev').click(function(event) {
		event.preventDefault();
		current = $('#home_promo').data('AnythingSlider').currentPage;
		if ( current != 1 ) {
		  $('#home_promo').data('AnythingSlider').goBack();
			$('#home_promo').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#home_promo').data('AnythingSlider').startStop(true);
			},7000); 
			
		} else {
			$('#home_promo').anythingSlider(5);
			$('#home_promo').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#home_promo').data('AnythingSlider').startStop(true);
			},7000);
		}
	});

	$('.carousellWrap .anim_next').click(function(event) {
		event.preventDefault();
		current = $('#home_promo').data('AnythingSlider').currentPage;
		if ( current != 5 ) {
		  $('#home_promo').data('AnythingSlider').goForward();
			$('#home_promo').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#home_promo').data('AnythingSlider').startStop(true);
			},7000); 
		} else {
			$('#home_promo').anythingSlider(1);
			$('#home_promo').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#home_promo').data('AnythingSlider').startStop(true);
			},7000);
		}
	});

	$('#cliWrap .anim_prev').click(function(event) {
		event.preventDefault();
		current = $('#clients_carousel').data('AnythingSlider').currentPage;
		if ( current != 1 ) {
		  $('#clients_carousel').data('AnythingSlider').goBack();
			$('#clients_carousel').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#clients_carousel').data('AnythingSlider').startStop(true);
			},7000); 
			
		} else {
			$('#clients_carousel').anythingSlider(4);
			$('#clients_carousel').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#clients_carousel').data('AnythingSlider').startStop(true);
			},7000);
		}
	});

	$('#cliWrap .anim_next').click(function(event) {
		event.preventDefault();
		current = $('#clients_carousel').data('AnythingSlider').currentPage;
		if ( current != 4 ) {
		  $('#clients_carousel').data('AnythingSlider').goForward();
			$('#clients_carousel').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#clients_carousel').data('AnythingSlider').startStop(true);
			},7000); 
		} else {
			$('#clients_carousel').anythingSlider(1);
			$('#clients_carousel').data('AnythingSlider').startStop(false);
			setTimeout(function(){
	      $('#clients_carousel').data('AnythingSlider').startStop(true);
			},7000);
		}
	});

	$('.hiddenText').hide();
	$('.anythingControls').hide();
		
	$('.thumbNav').find(":contains('4')").css("background", "none transparent");

	$('#logosSmall a:last-child').css("border-right", "0");

	$('#logosSmall a').click(function(event) {
		event.preventDefault();
		var indexTmp = $(this).parent().find("a").index(this);
		indexTmp ++;
		$('#home_promo').anythingSlider(indexTmp);
		$("#logosSmall a").stop().animate({ backgroundColor: "#cccccc"}, 400);
		$("#logosSmall a").removeClass("aktPro");
		$(this).stop().animate({ backgroundColor: "#ffffff"}, 400);
		$(this).addClass("aktPro");
	});

	$("#logosSmall a").hover(function() {
		if (!$(this).hasClass("aktPro")) {
	  	$(this).stop().animate({ backgroundColor: "#bdbdbd"}, 800);
		}
  },function() {
		if (!$(this).hasClass("aktPro")) {
	  	$(this).stop().animate({ backgroundColor: "#cccccc" }, 800);
		}
  });

	$("#logosSmall a").eq(0).stop().animate({ backgroundColor: "#ffffff"}, 400);
	$("#logosSmall a").eq(0).addClass("aktPro");


	$(".altShowcaseItemImage a").hide();

	$('.altShowcaseItemImage').each(function(index) {
		if ($(this).parent().find("a").size() == 0) {
			$(this).css('cursor', 'auto');
		} else {
			$(this).css('cursor', 'pointer');
		}
	});

	$(this).find('').css('cursor', 'auto');

	$(".altShowcaseItemImage").click(function(){
		if ( ($(this).prev('a').attr('href') != '') && ($(this).prev('a').attr('href') != "undefined") && ($(this).prev('a').attr('href') != undefined)) {
			document.location.href = $(this).prev('a').attr('href');
		} else {
			if ( ($(this).find('.hiddenLink').attr('href') != '') && ($(this).find('.hiddenLink').attr('href') != "undefined") && ($(this).find('.hiddenLink').attr('href') != undefined)) {
				document.location.href = $(this).find('.hiddenLink').attr('href');
			}
		}
	});

	$('#workShowcase > div > a').each(function(index) {
		if ( $(this).parent().find(".showcaseDetailText .hiddenTitle").text() != '' ) {
	 		$(this).text($(this).parent().find(".showcaseDetailText .hiddenTitle").text());
		}
 	});

	var pathname = window.location.pathname;
	var posSt = pathname.indexOf("/")+1;
	var valiable1 = pathname.substring(posSt);
	var valiable2 = valiable1.split("/");
	$(".vasom span").text(valiable2[0].toLowerCase().replace("-", " "));

	$(".vasom").attr("href", $(".vasom").attr("href")+"#"+valiable2[0].toLowerCase());

});
//]]>
