	$sCurrentAddress 	= window.location.href;
	$sHostName 			= window.location.host;
	
	$aCurrentAddres 	= $sCurrentAddress.split("#");
	$aControllers 		= $sCurrentAddress.split("/");
	
	if($aCurrentAddres.length == 2){
		$sCurrentController = $aControllers[3];
		$sClearedCurrentController = $sCurrentController.replace(/#/, '');
		
		if($sClearedCurrentController != $aCurrentAddres[1]){
			
			window.location.href = $aCurrentAddres[1];
		}
	}
	
	function closeLightbox(){
		$(".pp_overlay").click(); 
	}
	
	var loaded = 0;
	var currentOpen = '';

function debug($msg)
{
	$.ajax({
		  type: "GET",
		  url: "/log/msg/msg/" + $msg
		});
	
}

function getPageTitle($title){
	
	//alert($title);
		$languageId = $('#actualLanguage').html();

		switch($languageId){
			case 1  : $sNowa = 'Ecreation'; break;
			case 2  : $sNowa = 'Ecreation'; break;
			case 3  : $sNowa = 'Ecreation'; break;
			default : $sNowa = 'Ecreation'; break;	
		}
		
		
		if($languageId == 1){
			
			switch($title){
				case 'Start'		: $titleTest='Chatboty na komunikatorze MSN (Windows Live Messenger) oraz projektowanie stron www'; break;
				case 'O nas'		: $titleTest='Chatboty na komunikatorze MSN (Windows Live Messenger) oraz projektowanie stron www'; break;
				case 'Kontakt'		: $titleTest='Ecreation Holandia, Polska'; break;
				case 'Kariera'		: $titleTest='Marketing internetowy';  break;
				case 'Media'		: $titleTest='Ecreation w mediach'; break;
				case 'Chatboty'		: $titleTest='Tworzenie chatbotów na komunikator MSN (Windows Live Messenger)'; break;
				case 'Serwisy www'	: $titleTest='Projektowanie stron www'; break;
				case 'Reklama'		: $titleTest='Tanie rozmowy reklama w Televergelijk, Wyczajka'; break;
				default 			: $titleTest='Chatboty na komunikatorze MSN (Windows Live Messenger) oraz projektowanie stron www';  break;		
			}
		
		}
		
		if($languageId == 2){
			switch($title){
				case 'Home'			: $titleTest='Chatbots on MSN Messenger (Windows Live messenger) and website development '; break;
				case 'About'		: $titleTest='Chatbots on MSN Messenger (Windows Live messenger) and website development '; break;
				case 'Contact'		: $titleTest='Ecreation The Netherlands, Poland'; break;
				case 'Career'		: $titleTest='Affiliate Marketing';  break;
				case 'Media'		: $titleTest='Ecreation w mediach'; break;
				case 'Chatbots'		: $titleTest='Chatbot development on MSN Messenger (Windows Live messenger)'; break;
				case 'Websites'		: $titleTest='Website development '; break;
				case 'Advertisement': $titleTest='Cheap calls Televergelijk advertisement Alice Vindcent chatbot'; break;
				default 			: $titleTest='Chatbots on MSN Messenger (Windows Live messenger) and website development';  break;		
			}
		}
		
		if($languageId == 3){
		
			switch($title){
				case 'Home'			: $titleTest='Chatbots op MSN messenger en website ontwikkeling '; break;
				case 'Over'			: $titleTest='Chatbots op MSN messenger en website ontwikkeling '; break;
				case 'Contact'		: $titleTest='Ecreation Nederland, Polen'; break;
				case 'Carrière'		: $titleTest='Affiliate marketing ';  break;
				case 'Media'		: $titleTest='Ecreation in de media'; break;
				case 'Chatbots'		: $titleTest='Chatbots maken op MSN messenger'; break;
				case 'Websites'		: $titleTest='Website maken'; break;
				case 'Adverteren' 	: $titleTest='Goedkoop bellen Televergelijk adverteren Chatbot Alice Vindcent'; break;
				default 			: $titleTest='Chatbots op MSN messenger en website ontwikkeling';  break;		
			}
		}
		return $titleTest + " - Ecreation";

}

function loadPage($sType){	

	if (currentOpen != $sType || $sType == 'home/game')
	{
			
	
	currentOpen = $sType;
	
	var $sController;
	
	switch($sType){
		case 'chatbots'		: $sController = "/"+$sType+"/"+"about"; pageTracker._trackPageview('/chatbots/about'); break;
		case 'websites'		: $sController = "/"+$sType+"/"+"about"; pageTracker._trackPageview('/websites/about'); break;
		case 'media'		: $sController = "/"+$sType+"/"+"show"; pageTracker._trackPageview('/media/show'); break;
		case 'advertisement': $sController = "/"+$sType+"/"+"show"; pageTracker._trackPageview('/advertisement/show'); break;
		case 'websites/realisations' : $sController = '/websites/realisations/show/1'; pageTracker._trackPageview('/websites/realisations/show/1'); break;
		case 'chatbots/realisations' : $sController = '/chatbots/realisations/show/1'; pageTracker._trackPageview('/chatbots/realisations/show/1'); break;
		default				: if ($sType[0] == '/') {$sController = ""+$sType } else { $sController = "/" + $sType }; pageTracker._trackPageview(); break;	
	}

	/* smart fix */
	if ($sType.substring(1,9) == 'chatbots' || $sType.substring(1,9) == 'websites')
	{
		$sType = $sType.substring(1,9);
	}
	
	if ($sType.substring(0,8) == 'chatbots')
	{
		$sType = $sType.substring(0,8);
	}
	
	/* end of smart fix */
	
	$('.current').attr('class', 'menu');
	$("[title="+$sType+"]").attr('class', 'current menu');
	
	$sType = $sType.replace("/", "");
	$categoryText = $('#hidden_inputs #'+$sType).attr('value');
	
	//console.log($("a[title='"+$sType+"']"));
	//alert($('#'+$sType).attr('value'));
	
	$('#middle').fadeTo('slow', 0, function(){
		if($('#preloader').length == 0)
			$('#outter').prepend('<div id="preloader" style="width:100%;text-align:center;"><img  src="/images/default/preloader.gif" /></div>');
		$('#middle').load($sController, null, function(){
			document.location.hash = $sController;
			if($sController != '/websites/realisations/flash/1' && $sController != '/chatbots/realisations/flash/1'){
				$("#preloader").remove();
				$('#middle').fadeTo('slow', 1, function(){
					if(typeof sIFR == "function"){
						
						sIFR.replaceElement(named({sSelector:"h1.grey", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
						sIFR.replaceElement(named({sSelector:"h1.purple", sFlashSrc:"/swf/sifr.swf", sColor:"#c51f9e", sLinkColor:"#c51f9e", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
						sIFR.replaceElement(named({sSelector:"h1.purple1", sFlashSrc:"/swf/sifr.swf", sColor:"#c51f9e", sLinkColor:"#c51f9e", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
						sIFR.replaceElement(named({sSelector:"h1.right", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=right&offsetTop=0"}));
						sIFR.replaceElement(named({sSelector:"h1.writeus", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
						sIFR.replaceElement(named({sSelector:"h1.darkpurple", sFlashSrc:"/swf/sifr.swf", sColor:"#86136b", sLinkColor:"#585858", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
					
					};
				});
			}
		});
	});

	
	
	switch($sType){
		case 'contact'		: 	if($('#bottom_right').attr('id') == 'bottom_right'){
									$('#bottom_right').remove();
									$('#bottom_left').after('<div id="bottom_subscribe"></div>');
									$('#bottom_subscribe').load('/footer/contact');
								}
								break;
		default				: 	if($('#bottom_subscribe').attr('id') == 'bottom_subscribe'){
									$('#bottom_subscribe').remove();
									$('#bottom_left').after('<div id="bottom_right"></div>');
									$('#bottom_right').load('/footer/regular');
								}
								break;
	}
	

	document.title = getPageTitle($categoryText);

}
}

$(document).ready(function(){

	$('.article-link').css('display', 'block');
	
	$('.menu').bind('click', function(){
		$('.current').attr('class', 'menu');

		$title = $(this).attr('title');
		$("[title="+$title+"]").attr('class', 'current menu');
		
		var $sType 			= $(this).attr('title');
		var $sController;
		switch($sType){
			case 'chatbots'		: $sController = "/"+$sType+"/"+"about"; break;
			case 'websites'		: $sController = "/"+$sType+"/"+"about"; break;
			case 'media'		: $sController = "/"+$sType+"/"+"show"; break;
			case 'advertisement': $sController = "/"+$sType+"/"+"show"; break;
			case 'websites/realisations' : $sController = '/websites/realisations/flash/1'; break;
			case 'chatbots/realisations' : $sController = '/chatbots/realisations/flash/1'; break;
			default				: $sController = "/"+$sType; break;	
		}
		
		
		$('#middle').fadeTo('slow',0, function(){
			if($('#preloader').length == 0)
				$('#outter').prepend('<div id="preloader" style="width:100%;text-align:center;"><img  src="/images/default/preloader.gif" /></div>');
			$('#middle').load($sController, null, function(){
				
				
				if($sController != '/websites/realisations/flash/1' && $sController != '/chatbots/realisations/flash/1'){
				
					$("#preloader").remove();
					$('#middle').fadeTo('slow',1, function(){
						if(typeof sIFR == "function"){
							
							sIFR.replaceElement(named({sSelector:"h1.grey", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
							sIFR.replaceElement(named({sSelector:"h1.purple", sFlashSrc:"/swf/sifr.swf", sColor:"#c51f9e", sLinkColor:"#c51f9e", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
							sIFR.replaceElement(named({sSelector:"h1.purple1", sFlashSrc:"/swf/sifr.swf", sColor:"#c51f9e", sLinkColor:"#c51f9e", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
							sIFR.replaceElement(named({sSelector:"h1.right", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=right&offsetTop=0"}));
							sIFR.replaceElement(named({sSelector:"h1.writeus", sFlashSrc:"/swf/sifr.swf", sColor:"#585858", sLinkColor:"#585858", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
							sIFR.replaceElement(named({sSelector:"h1.darkpurple", sFlashSrc:"/swf/sifr.swf", sColor:"#86136b", sLinkColor:"#585858", sBgColor:"#fbfbfb", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
						
						};
						
					});
				}
			});
		});
		
		switch($sType){
			case 'contact'		: 	if($('#bottom_right').attr('id') == 'bottom_right'){
										$('#bottom_right').remove();
										$('#bottom_left').after('<div id="bottom_subscribe"></div>');
										$('#bottom_subscribe').load('/footer/contact');
									}
									break;
			default				: 	if($('#bottom_subscribe').attr('id') == 'bottom_subscribe'){
										$('#bottom_subscribe').remove();
										$('#bottom_left').after('<div id="bottom_right"></div>');
										$('#bottom_right').load('/footer/regular');
									}
									break;
		}
		

		document.title =  getPageTitle($(this).text());
		
	});
	
});