if(navigator.appName != "PLAYSTATION 3"){
	$(document).ready(function() {						  
		$('#projects').css('visibility', 'visible').hide().delay(100).fadeIn(800);
		$('#brands').css('visibility', 'visible').hide().delay(100).fadeIn(800);
		$('#gallery').css('visibility', 'visible').hide().delay(100).fadeIn(800);
		$('#services').css('visibility', 'visible').hide().delay(100).fadeIn(800);
		$('#jobs').css('visibility', 'visible').hide().delay(100).fadeIn(800);
		
		$('#content').css('visibility', 'visible').hide().fadeIn(800);
		$('#panels').css('visibility', 'visible').hide().fadeIn(800);
		if(document.getElementById("brandBox")){
			//startBrandBox();   
		}
		if(document.getElementById("recent")){
			var c = 0;
			$('#recent').children(".project").each(
				function(){
					$(this).css('visibility', 'visible').hide().delay(100 * c).fadeIn(1000);
					c++;
				}
			);
		}
		if(document.getElementById("servicesList")){
			var c = 0;
			$('#servicesList').children(".service").each(
				function(){
					$(this).css('visibility', 'visible').hide().delay(150 * c).fadeIn(1000);
					c++;
				}
			);
		}
		if(document.getElementById("related")){
			var c = 0;
			$('#related').children(".project").each(
				function(){
					$(this).css('visibility', 'visible').hide().delay(150 * c).fadeIn(1000);
					c++;
				}
			);
		}
		if(document.getElementById("brands")){
			var c = 0;
			$('#brands').css('height', $('#brands').height() + "px");
			$('#brands').children(".brand").each(
				function(){
					$(this).css('visibility', 'visible').hide().delay(200 * c).fadeIn(500);
					c++;
				}
			);
		}	
		if(document.getElementById("projects")){
			var c = 0;				
			$('#projects').css('height', $('#projects').height() + "px");
			$('#projects').children(".project").each(
				function(){
					$(this).css('visibility', 'visible').hide().delay(80 * c).fadeIn(800);
					c++;
				}
			);
		}
	});
}else{
	document.getElementById("projects").style.display = "block";
	document.getElementById("brands").style.display = "block";
	document.getElementById("gallery").style.display = "block";
	document.getElementById("services").style.display = "block";
	document.getElementById("content").style.display = "block";
	document.getElementById("panels").style.display = "block";
}
$(window).scroll(function () {
						   
	if(document.getElementById("bodyCategory") || document.getElementById("bodyBrand") || document.getElementById("bodyProject")){
		if(document.getElementById("sidebar")){				   
			var sidebar = $("#sidebar");
			if(window.pageYOffset){
				pageY = window.pageYOffset	
			}else{
				pageY = document.documentElement.scrollTop;
			}
			if(pageY >= 80 || pageY >= 80){ 		
				sidebar.css('position', 'fixed')
				sidebar.css('top', '15px')
			}else{
				sidebar.css('position', 'relative')
				sidebar.css('top', '0px')
			}
		}
		if(document.getElementById("info")){		
			if($("#info").height() - window.innerHeight <= -50 || $("#gallery").height() >= $("#info").height()){
				var info = $("#info");
				if(window.pageYOffset){
					pageY = window.pageYOffset	
				}else{
					pageY = document.documentElement.scrollTop;
				}
				if(pageY >= 170 || pageY >= 170){ 		
					info.css('position', 'fixed')
					info.css('top', '15px')
				}else{
					info.css('position', 'relative')
					info.css('top', '0px')
				}
			}
		}
	}
});




cId = 1;
canIPlay = true;
var t;

function startBrandBox(){
	if(canIPlay == true){
		t=setTimeout("playBrandBox()",5000);
	}
}
	
function playBrandBox(){
	$('#b' + cId).toggleClass("active");	
	$('#panel' + cId).css("left", "-600px");	
	$('#panel' + cId).animate({left: "-850px"},  {easing:"easeOutExpo", duration: 500});	
	if(cId != 3){
		cId ++;
	}else{;	
		cId =1;
	}
	$('#panel' + cId).css("left", "150px");	
	$('#panel' + cId).animate({left: "0px"}, {easing:"easeOutExpo", duration: 500});		
	$('#b' + cId).toggleClass("active");	
	startBrandBox();
}

function doNext(){
	clearTimeout(t);
	canIPlay = false;	
	$('#b' + cId).toggleClass("active");	
	$('#panel' + cId).css("left", "-600px");	
	$('#panel' + cId).animate({left: "-850px"}, {easing:"easeOutExpo", duration: 500});	
	if(cId != 3){
		cId ++;
	}else{;	
		cId =1;
	}
	$('#panel' + cId).css("left", "150px");	
	$('#panel' + cId).animate({left: "0px"}, {easing:"easeOutExpo", duration: 500});		
	$('#b' + cId).toggleClass("active");
}
function doPrev(){	
	clearTimeout(t);
	canIPlay = false;
	$('#b' + cId).toggleClass("active");	
	$('#panel' + cId).css("left", "600px");
	$('#panel' + cId).animate({left: "850px"}, {easing:"easeOutExpo", duration: 500});
	if(cId != 1){
		cId --;
	}else{;	
		cId = 3;	
	}		
	$('#panel' + cId).css("left", "-600px")
	$('#panel' + cId).animate({left: "0px"}, {easing:"easeOutExpo", duration: 500});		
	$('#b' + cId).toggleClass("active");
}

$('.input input').focus(function() {
	$(this).parent().children("span").animate({opacity:0.3, left: -($(this).parent().children("span").width())-10 + "px"}, {duration: 300});
});
$('.input span').click(function() {
	$(this).animate({opacity:0.3, left: -($(this).parent().children("span").width())-10 + "px"}, {duration: 300});		
	$(this).parent().children("input").focus();
});

$('.input input').blur(function() {
	if($(this).val() == ""){
		$(this).parent().children("span").animate({opacity:1, left:"15px"}, {duration: 300});
	}else{
		$(this).parent().children("span").animate({opacity:0}, {duration: 300});
	}
});
function focusTA(id, value){
	if(document.getElementById(id).value == value){
		document.getElementById(id).value = "";
		document.getElementById(id).style.fontSize = "11px";
	}
}
function blurTA(id, value){
	if(document.getElementById(id).value == ""){
		document.getElementById(id).value = value;
		document.getElementById(id).style.fontSize = "10px";
	}
}

function submitForm(){
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
	}					
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			if(xmlhttp.responseText == 'error'){				
				showError("e-mail", "Fout: Ongeldig e-mailadres");
			}else{
				$('#cSuc').css('visibility','visible').hide().fadeIn(450);
				$('#contact').animate({paddingTop:"60px"},250);
				
				document.getElementById("naam").value = "";
				$("#naam").parent().children("span").animate({opacity:1, left:"15px"}, {duration: 0});
				
				document.getElementById("e-mail").value = "";
				$("#e-mail").parent().children("span").animate({opacity:1, left:"15px"}, {duration: 0});
				
				document.getElementById("telefoon").value = "";
				$("#telefoon").parent().children("span").animate({opacity:1, left:"15px"}, {duration: 0});
				
				document.getElementById("bedrijf").value = "";
				$("#bedrijf").parent().children("span").animate({opacity:1, left:"15px"}, {duration: 0});
				
				document.getElementById("bericht").value = "UW BERICHT, VRAAG OF OPMERKING...";
			}
		}
	};
	var naam     = encodeURIComponent(document.getElementById("naam").value);
	var email    = encodeURIComponent(document.getElementById("e-mail").value);
	var telefoon = encodeURIComponent(document.getElementById("telefoon").value);
	var bedrijf  = encodeURIComponent(document.getElementById("bedrijf").value);	
	var bericht  = encodeURIComponent(document.getElementById("bericht").value);	
	
	if(naam == ""){
		showError("naam", "Fout: Gelieve alle vereiste velden in te vullen");
	}if(email == ""){
		showError("e-mail", "Fout: Gelieve alle vereiste velden in te vullen");
	}if(bericht == "" || bericht == encodeURIComponent("UW BERICHT, VRAAG OF OPMERKING...")){
		showError("bericht", "Fout: Gelieve alle vereiste velden in te vullen");
	}else{
		if(telefoon == ""){telefoon = "/";}
		if(bedrijf == ""){bedrijf = "/";}
		url = 'http://chilli.be/inc/functions/sendMail.php?naam=' + naam + "&telefoon=" + telefoon + "&email=" + email + "&bedrijf=" + bedrijf + "&bericht=" + bericht;		
		xmlhttp.open('GET',url,true);
		xmlhttp.send();
	}
}
function showError(id, errorMessage){
	if(document.getElementById("cError").innerHTML == ""){
		document.getElementById("cError").innerHTML = errorMessage; 
		$('#cError').css('visibility','visible').hide().fadeIn(650);
		$('#contact').animate({paddingTop:"60px"},250);
	}
	if(document.getElementById(id).value == "" && id == "bericht"){
		document.getElementById(id).value = "UW BERICHT, VRAAG OF OPMERKING...";		
	}
	document.getElementById(id).className = "error";
}

function showMap(){
	var myLatlng = new google.maps.LatLng(51.077699, 3.727518);	
	var myOptions = {
		zoom: 14,
		center: myLatlng, 
		mapTypeControl: false,
		streetViewControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	
	var map = new google.maps.Map(document.getElementById("map"), myOptions);	
	var marker = new google.maps.Marker({
			position: myLatlng,
			map: map
	});					
}
function f(u){	 /* CREATE POP-UP */
    w = window.open(u, "Share", "location=0,status=0,scrollbars=0, width=575,height=380");    
}
function t(u){	 /* CREATE POP-UP */
    w = window.open(u, "Share", "location=0,status=0,scrollbars=0, width=575,height=250");    
}
