Cufon.replace('h1',{
	letterSpacing: '-0.7px'
});
Cufon.replace('h2',{
	letterSpacing: '-0.5px'
});
Cufon.replace('h2 > span, h3, .bottom_link, .lavaLamp a strong, .calltoaction',{
	letterSpacing: '-0.3px'
});

$(window).bind("load", function() {
	$(".slider").slideView({
		easeFunc: "easeInOutQuart",
		easeTime: 1200
	});
});

$(document).ready(function(){

	$("#geboortedatum").mask("99-99-9999");

	$("#soliciteren").validationEngine({promptPosition : "bottomRight"});

	$("input[type=file]").each(function(){
		//alert($(this).html());
		$(this).before('<div class="inputfile-wrapper"></div>');
		$(this).prev().append('<div class="inputfile"><div class="inputfile-text"></div></div>');
		$(this).appendTo($(this).prev());
	});
	$("input.inputfile").change(function(){
		$(this).prev().children("div.inputfile-text").text($(this).val());
	});

	if($.browser.msie == true){
		browser = 'Internet Explorer';
	}else if($.browser.safari == true){
		browser= 'Chrome of Safari';
	}else if($.browser.mozilla == true){
		browser= 'Firefox';
	}else{
		browser='onbekend';
	}
	$("input.browser").val(browser);

	$("input.star").each(function(){
		name = $(this).attr("name");
		val = $(this).val();
		title = $(this).attr("title");
		if($("#"+name).length < 1){
			$(this).before("<div class='starholder' id='"+name+"'><div class='star value"+val+"'><a title='"+title+"'></a></div></div>");
		}else{
			$("#"+name).append("<div class='star value"+val+"'><a title='"+title+"'></a></div>");
		}
		$(this).hide();
	});
	$("div.star").mouseenter(function(){
		aantal = $(this).index();
		title = $(this).children().attr("title");
   
		id = $(this).parent().next("input").attr("name").split("--");
		id=id[1];
		$("#comptid"+id).text(title);
   
		aantal++;
		$(this).nextAll().removeClass("hover").addClass("no-hover");
		for($i=0; $i<aantal; $i++){
			$(this).parent().children().eq($i).addClass("hover").removeClass("no-hover");
		}
	});
	$("div.star").mouseleave(function(){
		aantal = $(this).index();
		aantalChildren = $(this).parent().children().length;
   
		id = $(this).parent().next("input").attr("name").split("--");
		id=id[1];
		$("#comptid"+id).text("");
   
		aantal++;
		for($i=aantal; $i<aantalChildren; $i++){
			$(this).parent().children().eq($i).removeClass("hover").addClass("no-hover");
		}
	});
	$("div.star").click(function(){
		aantal = $(this).index();
		name = $(this).parent().attr("id");
   
		id = $(this).parent().next("input").attr("name").split("--");
		id=id[1];
		$("#comptid"+id).text(title).addClass("vast");
   
		$(this).parent().nextAll("input[name='"+name+"']").eq(aantal).attr("checked", "checked");
   
		$(this).nextAll().removeClass("selected");
		for($i=0; $i<=aantal; $i++){
			$(this).parent().children().eq($i).addClass("selected");
		}
	});
	$("div.starholder").mouseleave(function(){
		$(this).children().removeClass("hover").removeClass("no-hover");
	});
	
	//LINK-AFBREKING
	var ie6 = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (ie6) {
		$(".hyphenate a").each(function(){
			$(this).replaceText(/\//ig, '\/<b> <\/b>');
			$(this).replaceText(/\./ig,'.<b> <\/b>');
			$(this).replaceText('/ / ', '\/\/<b> <\/b>');
			$(".hyphenate a b").css({
				"font-size":"1px"
			});
		});
	}else{
		$(".hyphenate a").each(function(){
			$(this).replaceText(/\//ig, '/​');
			$(this).replaceText(/\./ig,'.​');
			$(this).replaceText('/​/​', '//​');
		});
	}

	// PORTFOLIO ITEMS EEN FLOAT RIGHT GEVEN
	$(".image-grid li:odd").css({
		"float":"right"
	});
	
	// ROUNDED CORNERS
	$('#column_center .portfolio').append('<div class="t_l"/><div class="t_r"/><div class="b_l"/><div class="b_r"/>');
	
	
	//CLASS TOEWIJZEN
	$("#twitter p:first-child").addClass('first-child');	

	
	// LAVALAMP
	$(function(){
		$(".lavaLamp").lavaLamp({
			fx: "backout",
			speed: 1000
		});
	});


	//SOCIAL MEDIA ICONS
	$("#social_media a").hover(function(){
		$(this).addClass('hover');
		$(this).stop().animate({
			height: 42
		}, 300);
		$(this).children("span").stop().animate({
			height: 42
		}, 300);
	}, function(){
		$(this).stop().animate({
			height: 25
		}, 300, function(){
			$(this).removeClass('hover');
		});
		$(this).children("span").stop().animate({
			height: 25
		}, 300);
	});
	
	
	//INFADEN MENU
	
	$("#navigation ul li:not(.current) a span").css({
		"visibility":"visible"
	}).fadeTo(0, 0);
	$("#navigation ul li:not(.current)").hover(function(){
		$(this).children("a").children("span").stop().fadeTo("fast", 1);
	},function(){
		$(this).children("a").children("span").stop().fadeTo("fast", 0);
	});
	$("#navigation ul li#arrows").replaceWith('<div id="arrows"/>');
	

	//PORTFOLIO IMG VERPLAATSEN
	$(".image-grid li a").live('mouseover mouseout', function(event) {
		if (event.type == 'mouseover') {
			$(this).children("img").stop().animate({
				"margin-left":"-272px"
			}, 500);
		} else {
			$(this).children("img").stop().animate({
				"margin-left":"-30px"
			}, 500);
		}
	});

	//TEAM-FOTO VERGROTEN
	$(".team").each(function(){
		var index = $(this).index();
		var length = $(".team:even").length;
		$(this).attr({
			id: "teamlid-" + index
		}).css({
			top: 110 * index
		});
		$(".team:even").css({
			left: 0
		});
		$(".team:odd").css({
			right: 0
		});
		$(this).parent("#team_grid").css({
			height: length * 218
		});
	});
	$(".team:odd").each(function(){
		var position = $(this).position();
		$(this).css({
			top: + position.top - 110
		});
	});
	$(".team:last").css({
		top: "auto",
		bottom: 0
	}).prev(".team:even").css({
		top: "auto",
		bottom: 0
	});
	
	jQuery.easing.def = "easeOutCubic";
	var showSpeed = 800;
	
	$(".team").hover(function(){
		$(this).css({
			"z-index": 2
		}).stop().animate({
			width:514,
			height:514
		}, showSpeed -10, function(){
			$(this).css({
				"z-index": 3
			});
		});
		$(this).children("img").stop().animate({
			width:516,
			height:516,
			marginTop: -1,
			marginLeft: -1
		}, showSpeed -10);
		$(this).children(".team_title").stop().animate({
			opacity: 0.9
		}, showSpeed -10);
		if($.browser.msie && jQuery.browser.version == '8.0'){
			$(this).children(".team_title").css({
				'z-index':'3'
			});
		}else{
			$(this).children(".team_title h2").css({
				"visibility":"visible !important"
			});
		}
		
	},function(){
		$(this).css({
			"z-index": 1
		}).stop().animate({
			width:246,
			height:200
		}, showSpeed -10, function(){
			$(this).css({
				"z-index": 0
			});
		});
		$(this).children("img").stop().animate({
			width:380,
			height:380,
			marginTop: -10,
			marginLeft: -73
		}, showSpeed -10);
		$(this).children(".team_title").stop().animate({
			opacity: 0
		}, showSpeed -10);
		if($.browser.msie && jQuery.browser.version == '8.0'){
		}else{
			$(this).children(".team_title h2").css({
				"visibility":"hidden !important"
			});
		}
	});

	// FORMULIER INPUT CLASSES
	$("input[type=text], input[type=password]").addClass("input_tekst");
	$("input[type=radio]").addClass("input_radio");
	$("input[type=checkbox]").addClass("input_checkbox");
	$("input[type=submit]").addClass("input_button");

	
	// RADIOBUTTONS AANPASSEN PORTFOLIO
	$("#filter input:radio").css({
		opacity:0
	}).each(function(){
		var name = $(this).attr("name");
		$(this).before('<span class="radiobutton"/>');
		$(this).prev("span").addClass("name-" + name +"");
	});
	$("#filter input:radio:checked").each(function(){
		$(this).prev("span").css({
			"background-position":"bottom"
		});
	});
	$("#filter input:radio").click(function(){
		var nameclass = $(this).prev("span").attr("class");
		$(".radiobutton[class$='" + nameclass + "']").css({
			"background-position":"top"
		});
		$(this).prev("span").css({
			"background-position":"bottom"
		});
		$(this).attr('checked','checked');
	});
	$("#filter input:radio").next("label").each(function(){
		var label = $(this).text();
		$(this).prev("input").prev("span").text(label);
		$(this).remove();
	});	


	//PHONE NUMBER
	$("#phonenumber").animate({
		"height":"0px"
	},0);
	$("#mini_navigation a").click(function(){
		$(this).next("#phonenumber").animate({
			"height":"100px"
		},100);
	});
	$("#phonenumber").click(function(){
		$(this).animate({
			"height":"0px"
		},100);
	});
	
	
	// UITKLAPPEN SQUAREPOINT
	$("#squarepoint a").hover(function(){
		$(this).stop().animate({
			"margin-left":"0px"
		},100);
	},function(){
		$(this).stop().animate({
			"margin-left":"5px"
		},100);
	});


	// INPUT, TEXTAREA FOCUS
	$("#middle input[type=text], #middle textarea, #animatie_popup input").focus(function(){
		$(this).parent("div.curvyRedraw").addClass("focus");
	});
	$("#middle input[type=text], #middle textarea, #animatie_popup input").blur(function(){
		$(this).parent("div.curvyRedraw").removeClass("focus");
	});
	
	
	// TARGET: _BLANK
	$("a[href^='http://'],a[href^='www.']").not("a[href^='http://www.netsquare.nl'],a[href^='http://netsquare.nl']").attr('target','_blank');

	$("#flash_animatie").fancybox({
		'width':800,
		'height':300,
		'autoScale':false
	});
	$("#flash_animatie").trigger("click");


	$(".share-on-facebook").click(function(){
		FB.ui(
			{
				app_id : '56f8ef1dbcf7fb342bfae6b854013af3',
				redirect_url : window.location.href,
				method: 'feed',
				name: 'Netsquare',
				link : $(this).attr("href"),
				message: $(this).attr("title"),
				attachment: [
					{
						type: 'image',
						src: 'http://www.netsquare.nl/views/img/icon-facebook.gif'
					}
				]
			},
			function(response) {
				if (response && response.post_id) {
					alert("Bedankt voor het delen van dit artikel.");
					$.post("/cron/twitter.php" , {value: response.post_id});
				} else {
					alert("U heeft het artikel niet gedeeld.");
				}
			}
		);
		return false;
	});
});
