
jQuery(function() {
	// Image preload
	var list = ['/wp-content/themes/kiwimedia/images/intro_image_hover.png'
		   ,'/wp-content/themes/kiwimedia/images/bekijk_portfolio_1_hover.png'
		   ,'/wp-content/themes/kiwimedia/images/bekijk_portfolio_2_hover.png'
		   ]
	var imgs = []
	for (i in list) {
		imgs[i] = new Image()
		imgs[i].src = list[i]
	}
})

jQuery(document).ready(function() {

	jQuery("h3.toggler").click(function(){
		jQuery(this).toggleClass("active").next(".toggle_container").slideToggle("fast");
	});
	
	jQuery(".tab_content").hide();
	jQuery("ul.tabs li:first").addClass("active").show();
	jQuery(".tab_content:first").show(); 
	
	jQuery("ul.tabs li").click(function() {
	
		jQuery("ul.tabs li").removeClass("active");
		jQuery(".tab_content").hide(); 
		jQuery(this).addClass("active"); 
		var tabNum = (jQuery(this).find("a").attr("href")).replace('#tab', '');
		jQuery(this).parent().next().find("div:nth-child(" + tabNum + ")").fadeIn();

		return false;
	});


	
	jQuery(".footer_social_networks ul li").fadeTo('normal', 0.4);
	jQuery(".footer_social_networks ul li").hover(function(){
				jQuery(this).fadeTo('normal', 1);
			}, function() {
					jQuery(this).fadeTo('normal', 0.4);
	});
	
	
	jQuery(".form-input input").focus(function () {
	jQuery(this).css({ "backgroundPosition":"0 -28px"});});
	jQuery(".form-input input").blur(function () {
	jQuery(this).css({ "backgroundPosition":"0 0"});});

	jQuery(".form-textarea textarea").focus(function () {
	jQuery(this).parent().css({ "backgroundPosition":"0 -224px"});});
	jQuery(".form-textarea textarea").blur(function () {
	jQuery(this).parent().css({ "backgroundPosition":"0 0"});});

	jQuery(".small_text").focus(function () {
	jQuery(this).css({ "backgroundPosition":"0 -28px"});});
	jQuery(".small_text").blur(function () {
	jQuery(this).css({ "backgroundPosition":"0 0"});});

	jQuery(".picloader img").hide();
	jQuery(".image_holder img").hide();
	jQuery(".image_holder").hide();
	

	jQuery("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_rounded',slideshow:5000});
});




jQuery(window).load(function() { 
	jQuery(".picloader").css("background-image", "none");
    jQuery(".picloader img").fadeIn("fast");
	
	jQuery(".image_skin_anime").css("background-image", "none");

	jQuery(".image_holder").show();
	jQuery(".image_holder img").fadeTo('normal', 1, function() {
		
		jQueryget_id = jQuery(this).parent().parent().attr("id");
		if(jQueryget_id != ""){
			jQuery(this).parent().parent().addClass(jQueryget_id);
			
			jQuery(this).hover(function(){
				jQuery(this).fadeTo('normal', 0.5);
				
			}, function() {
					jQuery(this).fadeTo('normal', 1);
			});
		}
    });
;

});	










/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 2.0
 * Demo: http://www.texotela.co.uk/code/jquery/newsticker/
 *
 * jQueryLastChangedDate: 2007-05-29 11:31:36 +0100 (Tue, 29 May 2007) jQuery
 * jQueryRev: 2005 jQuery
 *
 */

jQuery(document).ready(function() {

jQuery.fn.newsTicker = jQuery.fn.newsticker = function(delay)
{
	delay = delay || 4000;
	initTicker = function(el)
	{
		stopTicker(el);
		el.items = jQuery("li", el);
		// hide all items (except first one)
		el.items.not(":eq(0)").hide().end();
		el.currentitem = 0;
		startTicker(el);
	};
	startTicker = function(el)
	{
		el.tickfn = setInterval(function() { doTick(el) }, delay)
	};
	stopTicker = function(el)
	{
		clearInterval(el.tickfn);
	};
	pauseTicker = function(el)
	{
		el.pause = true;
	};
	resumeTicker = function(el)
	{
		el.pause = false;
	};
	doTick = function(el)
	{
		if(el.pause) return;
		el.pause = true;
		jQuery(el.items[el.currentitem]).fadeOut("normal",
			function()
			{
				jQuery(this).hide();
				el.currentitem = ++el.currentitem % (el.items.size());
				jQuery(el.items[el.currentitem]).fadeIn("normal",
					function()
					{
						el.pause = false;
					}
				);
			}
		);
	};
	this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			initTicker(this);
		}
	)
	.addClass("newsticker")
	.hover(
		function()
		{
			pauseTicker(this);
		},
		function()
		{
			resumeTicker(this);
		}
	);
	return this;
};

jQuery("#news_ticker").newsTicker($headlines_delay);
jQuery("#tweet_ticker").newsTicker(5000);
})

/* begin contact form */
jQuery(document).ready(function(){
	var form = jQuery("#commentform");
	var name = jQuery("#name");
	var email = jQuery("#email");
	var subject = jQuery("#subject");
	var message = jQuery("#message");
	
	name.blur(validateName);
	email.blur(validateEmail);
	subject.blur(validateSubject);
	message.blur(validateMessage);
	
	name.focus(function () {
		jQuery(this).css({ "backgroundPosition":"0 -28px"});
	});
	
	subject.focus(function () {
		jQuery(this).css({ "backgroundPosition":"0 -28px"});
	});
	
	message.focus(function () {
		jQuery(this).parent().css({ "backgroundPosition":"0 -224px"});
	});
	
	var inputs = form.find(":input").filter(":not(:submit)").filter(":not(:checkbox)").filter(":not([type=hidden])").filter(":not([validate=false])");

	form.submit(function(){
		if(validateName() & validateEmail() & validateSubject() & validateMessage()){
			
			var jQueryname = name.val();
			var jQueryemail = email.val();
			var jQuerysubject = subject.val();
			var jQuerymessage = message.val();
			
			jQuery.ajax({
				type: 'GET',
				url: jQuerysite_url+"/framework/includes/get_mail.php",
				data: form.serialize(),
				success: function(ajaxCevap) {
					jQuery('#list').hide();
					jQuery('#list').html(ajaxCevap);
					jQuery('#list').fadeIn("normal");
					name.attr("value", "");
					email.attr("value", "");
					subject.attr("value", "");
					message.attr("value", "");
				}
			});

			return false;
		}else{
			return false;
		}
	});
	
	function validateEmail(){
		var a = jQuery("#email").val();
		var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}jQuery/;
		if(filter.test(a)){
			email.css({ "backgroundPosition":"0 0"});
			return true;
		}
		else{
			email.css({ "backgroundPosition":"0 -56px"});
			return false;
		}
	}
	function validateName(){
		if(!name.val()){
			name.css({ "backgroundPosition":"0 -56px"});
			return false;
		}
		else{
			name.css({ "backgroundPosition":"0 0"});
			return true;
		}
	}
	
	function validateSubject(){
		if(!subject.val()){
			subject.css({ "backgroundPosition":"0 -56px"});
			return false;
		}
		else{
			subject.css({ "backgroundPosition":"0 0"});
			return true;
		}
	}
	
	function validateMessage(){
		if(!message.val()){
			message.parent().css({ "backgroundPosition":"0 -448px"});
			return false;
		}else{			
			message.parent().css({ "backgroundPosition":"0 0"});
			return true;
		}
	}
});
/* end contact form */



/* begin scrolltop control */
jQuery(function(){
   sh = jQuery(window).height() / 2;
   xh = jQuery(document).height() /2 - sh;
});	

var scrolltotop={
	
	setting: {startline:200, scrollto: 0, scrollduration:1000, fadeduration:[200, 50]},
	controlHTML: '<span class="scroll_up"></span>',
	controlattrs: {offsetx:5, offsety:5}, 
	anchorkeyword: '#top',
	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) 
			this.jQuerycontrol.css({opacity:0}) 
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) 
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.jQuerybody.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var jQuerywindow=jQuery(window)
		var controlx=jQuerywindow.scrollLeft() + jQuerywindow.width() - this.jQuerycontrol.width() - this.controlattrs.offsetx
		var controly=jQuerywindow.scrollTop() + jQuerywindow.height() - this.jQuerycontrol.height() - this.controlattrs.offsety
		this.jQuerycontrol.css({left:controlx+'px', top:controly+'px'})
		
	
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=xh)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.jQuerycontrol.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.jQuerycontrol.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function(jQuery){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.jQuerybody=(window.opera)? (document.compatMode=="CSS1Compat"? jQuery('html') : jQuery('body')) : jQuery('html,body')
			mainobj.jQuerycontrol=jQuery('<div id="topcontrol"><span class="scroll_up"></span></div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.jQuerycontrol.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.jQuerycontrol.css({width:mainobj.jQuerycontrol.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			jQuery('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			jQuery(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

scrolltotop.init()
/* end scrolltop control */

