﻿$(document).ready(function() {//remove player for apple devices	if( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) ) {	 		$('#player').remove();	}		setInterval('anchors()',50); //player activity	$("a.tapecom").click(function () {      		if(!($("#player").hasClass("playerexpanded"))){            $("#player").animate({        left: "-14px"      }, 1000 );      $("#player").addClass("playerexpanded");    	}else{    	    	$("#player").animate({        left: "-214px"      }, 1000 );      $("#player").removeClass("playerexpanded");    	    	}          });//hover on da toyz   $("#link_info").hover(		function () {			$("#hobo").animate({        		top: "0px"      		}, 200, function(){ $("#hobo-light").show(); });		}, 		function () {			if(!$(this).hasClass("on")){			$("#hobo-light").hide();			$("#hobo").animate({        		top: "-10px"      	}, 200 );      	}		}	);    $("#link_photo").hover(		function () {			$("#lolaroid").animate({        		top: "0px"      		}, 200, function(){ $("#lolaroid-flash").show(); });		}, 		function () {			if(!$(this).hasClass("on")){			$("#lolaroid-flash").hide();			$("#lolaroid").animate({        		top: "-10px"      	}, 200 );      	}		}	);			$("#link_video").hover(		function () {			$("#vhs").animate({        		bottom: "-50px"      		}, 200);		}, 		function () {			if(!$(this).hasClass("on")){			$("#vhs").animate({        		bottom: "-60px"      	}, 200 );      	}		}	);	    	$("#link_news").hover(		function () {			$("#coin").animate({        		right: "0px"      		}, 200);		}, 		function () {			if(!$(this).hasClass("on")){			$("#coin").animate({        		right: "-10px"      	}, 200 );      	}		}	);	//tipz on da toyz	$('#link_info').tipsy({fade: true, delayIn: 1000, delayOut: 1000, gravity: 'n'});		$('#link_photo').tipsy({fade: true, delayIn: 1000, delayOut: 1000, gravity: 'e'});	$('.tapecom').tipsy({fade: true, delayIn: 1000, delayOut: 1000, gravity: 'sw'});		$('#link_video').tipsy({fade: true, delayIn: 1000, delayOut: 1000, gravity: 's'});	$('#link_news').tipsy({fade: true, delayIn: 1000, delayOut: 1000, gravity: 'e'});//teh clickz on da toyz	$('#link_info').click(function(){showToylinks(); paintInfo();});		$('#link_photo').click(function(){showToylinks(); paintPhoto();});	$('#tophoto').live('click', function(){showToylinks(); paintPhoto();});	$('#link_video').click(function(){showToylinks(); paintVideo();});	$('#link_news').click(function(){showToylinks(); paintNews();});	$('#tonews').live('click', function(){showToylinks(); paintNews();});	$('.pager > a').live('click', function(){	$("#content").addClass("loadable").load($(this).attr("href"), function(){$(this).removeClass("loadable")}); return false;});//lightbox//at all		$("a[rel='lightbox']").colorbox();//youtube embed    $('#videoprevs a.vp').live('click', function() {  		var vid=$(this).attr("video"); 		if( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) ) {	 		$('#vb').addClass("loadable").empty().html('<iframe type="text/html" width="640" height="390" src="http://www.youtube.com/embed/'+vid+'" frameborder="0"></iframe>');			}	   				else{			$('#vb').addClass("loadable").empty().html('<object type="application/x-shockwave-flash" style="width:640px; height:390px;" data="http://www.youtube.com/v/'+vid+'"><param name="wmode" value="transparent" /><param name="movie" value="http://www.youtube.com/v/'+vid+'" /></object>');			}		return false;	});//ready photo album$("a.phoa").live('click', function() {		var oid=$(this).attr("href").split("-")[1];  		paintAlbum(oid);	});		//ready one note$("a.readpost").live('click', function() {		var nid=$(this).attr("href").split("-")[1];  		paintNote(nid);	});		//end of document.ready	   });function cleanRemoveable(){	$('.removeable').remove();	$('body').attr("id", "");	$('body').attr("class", "");}function showToylinks(){	$('#link_info').show();	$('#link_photo').show();	$('#link_video').show();	$('#link_news').show();}function removeToys(){	$("#hobo-light").hide();	$("#hobo").css({top: "-10px"});	$("#lolaroid-flash").hide();	$("#lolaroid").css({top: "-10px"});	$("#vhs").css({bottom: "-60px"});	$("#coin").css({right: "-10px"});	$(".toylink").removeClass("on");}function anchors (){	var newloc = window.location.hash.replace("#!/","");	if (newloc==0) {newloc = 1;}		switch (newloc) {  		case 1:    		break  		  		case "info":  			if(!($("body").attr("class")=="info")){  			showToylinks();    		paintInfo();    		}    		break    		  		case "photo":  			if(!($("body").attr("class")=="photos")){  			showToylinks();    		paintPhoto();    		}    		break    		    	case "video":  			if(!($("body").attr("class")=="video")){  			showToylinks();    		paintVideo();    		}    		break     		    	case "news":  			if(!($("body").attr("class")=="news")){  			showToylinks();    		paintNews();    		}    		break	    		  		default:  			break 		}		 		//detect one album 		if(newloc.substr(0, 5)=='album'){ 			var aid=newloc.split("-")[1]; 			if(!($("body").attr("id")=='album'+aid)){  			showToylinks();    		paintAlbum(aid);    		} 		} 		 		//detect one note 		if(newloc.substr(0, 4)=='note'){ 			var nid=newloc.split("-")[1]; 			if(!($("body").attr("id")=='note'+nid)){  			showToylinks();    		paintNote(nid);    		} 		} 		 		} //end of anchorsfunction paintAlbum(id){	cleanRemoveable();	removeToys();	$("body").attr("class","photo");	$("body").attr("id", 'album'+id);	$('#link_photo').addClass("on");	$("#lolaroid").animate({top: "0px"}, 200, function(){$("#lolaroid-flash").show();});	$(".outer").append('<div id="photos" class="removeable" />');	$("#photos").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/'+id+'', function() {$(this).find("a[rel='lightbox']").colorbox(); $(this).removeClass("loadable")});	$("#content:empty").html('<h1>Фото</h1> Неверный альбом. <a href="/#!/photo" id="tophoto">Вернитесь к выбору альбома</a>');	document.title="3-1-3: Фото";}function paintNote(id){	cleanRemoveable();	removeToys();	$("body").attr("id", 'note'+id);	$('#link_news').addClass("on");	$("body").attr("class","note");	$('#link_news').addClass("on");	$("#coin").animate({right: "0px"});	$(".outer").append('<div id="nwsdiv" class="removeable" />');	$("#nwsdiv").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/'+id+'', function() {$(this).find("a[rel='lightbox']").colorbox();$(this).removeClass("loadable")});	$("#content:empty").html('<h1>Новости</h1> Неверная статья. <a href="/#!/news" id="tonews">Вернитесь к новостям</a>');	document.title="3-1-3: Новости";	alert($(h1).html());}function paintInfo(){	$('#link_info').addClass("on");	cleanRemoveable();	removeToys();	$("body").attr("class","info");	$('#link_info').addClass("on");	$("#hobo").animate({top: "0px"}, 200, function(){$("#hobo-light").show();});	$(".outer").append('<div id="txtdiv" class="removeable" />');	$("#txtdiv").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/info', function(){$(this).removeClass("loadable")});	document.title="3-1-3: Инфо о проекте";}function paintNews(){	$('#link_news').addClass("on");	cleanRemoveable();	removeToys();	$("body").attr("class","news");	$('#link_news').addClass("on");	$("#coin").animate({right: "0px"});	$(".outer").append('<div id="nwsdiv" class="removeable" />');	$("#nwsdiv").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/news', function(){$(this).removeClass("loadable")});	document.title="3-1-3: Новости";}function paintPhoto(){	cleanRemoveable();	removeToys();	$("body").attr("class","photos");	$('#link_photo').addClass("on");	$("#lolaroid").animate({top: "0px"}, 200, function(){$("#lolaroid-flash").show();});	$(".outer").append('<div id="photos" class="removeable" />');	$("#photos").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/photo', function(){$(this).removeClass("loadable")});	document.title="3-1-3: Фото";}function initVideo(){	$(".videocar").jCarouselLite({        btnNext: ".vnext",        btnPrev: ".vprev",        visible: 5,    });}function paintVideo(){	cleanRemoveable();	removeToys();	$("body").attr("class","video");	$('#link_video').addClass("on");	$("#vhs").animate({bottom: "-50px"});	$(".outer").append('<div id="videos" class="removeable" />');	$("#videos").append('<div class="cnt" id="content" />');	$("#content").addClass("loadable").load('/video', function() {  		$(this).removeClass("loadable");  		setTimeout('initVideo()',1000);	});	document.title="3-1-3: Видео";}
