Learn how to use jQuery at the Blog

PBZ « visit

  • Added 5 months ago
  • 287 Lines of Code shown
  • 4 Links of Interest
http://pbz.hr
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to PBZ - http://pbz.hr

function showMainPane(index) {
	$(".homeMainFile").hide();
	$(".homeMainFile:eq(" + index + ")").fadeIn(2000);	

	$(".homeMainContentNavigation a").removeClass("selected");
	$(".homeMainContentNavigation a:eq(" + index + ")").addClass("selected");
}

function rotateMainPane() {
	var index = 0;
	var filesLength = $(".homeMainContentNavigation a").length;
	
	showMainPane(0);
	
	/*if (filesLength > 1) {
		$(document).everyTime(10000, "swapfiles", function() {
			index++;
			if (index == filesLength) index = 0;
			
			showMainPane(index);
		});
	}*/
}

function getSectionId(str) {
    var myregexp = /sec=(\d{1,4})/;
    var match = myregexp.exec(str);
    
    if (match != null) {
        result = match[1];
    } else {
        result = "";
    }

    return result;
}

function doSearch() {
	var strSearchFieldLocatorValue = $(".searchFieldWrapper input:hidden").attr("value");
		
	if (strSearchFieldLocatorValue !== "") {
		MarkForm("6","1",strSearchFieldLocatorValue,'');
		window.iSite_SetCacheTrigger(null);
		document.forms[0].submit();
	}
}	

function homeInitialize() {
	//	Short news handler
	$(".inoutdexNews").accordion({
		autoheight: false,
		header: 'h3',
		alwaysOpen: false,
		active: 0
	});
	
	$(".inoutdexNewsContent img").wrap("<div class=inoutdexNewsImage></div>");

	if (!document.getElementById("searchResults") && !document.getElementById("siteMap")) {
		//	Expand Search control
		$(".searchControlContainer").animate({width:"553px"}, 1800, "swing");
		$(".searchControlExpander").animate({marginLeft:"740px"}, 1800, "swing").addClass("searchControlExpanderExpanded");
		
		//	Expand Product control		
		$(".productControlContainer").animate({width:"553px"}, 2000, "swing");
		$(".productControlExpander").animate({marginLeft:"740px"}, 2000, "swing").addClass("productControlExpanderExpanded");
	}

	// Main content handler
	if ($(".homeMainFile").length > 1) {
		$(".homeMainFile").each(function(i){
			var slideIndex = i+1;
			$(".homeMainContentNavigation:first").append("<a href=\"#\" title=\"\">" + slideIndex + "</a>");
		});
	}
	
	//	Files auto rotate
	rotateMainPane();
	
	$(".homeMainContentNavigation a").each(function(i){
		$(this).click(function(e){
			e.preventDefault();
			$(document).stopTime("swapfiles");
			showMainPane(i);
		})
	});
}

function pageInitialize() {
	//	Set UI skin
	$("h2.skin").addClass(topSectionSkin);
	
	//	Mark selected root section
	$("#navigation a").each(function(){
		var oLink = $(this);
		
		if (oLink.attr("href") !== "") {
			if (getSectionId(oLink.attr("href")) == topSectionId) {
				oLink.parent().addClass(topSectionSkin);	
			}
		}
	});

	//	Mark seleced current section
	$(".inoutdexSiteTree a").each(function(){
		var oLink = $(this);
		
		if (oLink.attr("href") !== "") {
			if (getSectionId(oLink.attr("href")) == currentSectionId) {
				oLink.parent().addClass("selected");
				oLink.parent().parents('li').addClass("selected");
			}
		}
	});
	
	//	Build 4-th level navigation
	var oSiteTreeThirdLevel = $(".inoutdexSiteTree ul ul ul");
	var oMainSiteTree = oSiteTreeThirdLevel.clone(); 
	
	oSiteTreeThirdLevel.hide();
	oMainSiteTree.appendTo(".mainSiteTree:first");
	$(".mainSiteTree li").addClass(topSectionSkin);
	
	//	Remove 4-th level selected section link
	$(".mainSiteTree a").each(function(){
		var oLink = $(this);
		
		if (oLink.attr("href") !== "") {
			if (getSectionId(oLink.attr("href")) == currentSectionId) {
				oLink.parent().hide();
			}
		}
	});
	
	//	Back button
	$(".buttonBack").click(function(){
		history.go(-1);							
	});
	
	//	Send mail button
	$(".buttonEmail").click(function(){
		var strArticleTitle = $(".articleTitle:first span").text();
		window.location = "mailto:?Subject=" + document.title + " - " + strArticleTitle + "&body=" + document.location;							
	});
	
	//	Print button
	$(".buttonPrint").click(function(){
		window.print();							
	});
	
	//	Handle article links
	$(".articleLinks li > span").each(function(){
		if ($.trim($(this).text()) != "(, )") $(this).show();					 
	});
	
	//	Handle photos in articles
	$(".article a img").each(function(){
		var oImg = $(this);
		var oLink = oImg.parent("a");
		
		oLink.attr("title", oImg.attr("alt"));
	});
	
	$(".article a[name='isite_sp_a'], .article a:has(.gen_articleImage)").lightBox({
		imageLoading: "designtemplates/pbz/images/lightbox-ico-loading.gif",
		imageBtnPrev: "designtemplates/pbz/images/lightbox-btn-prev.png",
		imageBtnNext: "designtemplates/pbz/images/lightbox-btn-next.png",
		txtImage: labelGalleryImage,
		txtOf: labelGalleryImageOf
	});
}

function videoGalleryInitalize() {
	//	Handle video articles
	$(".video-article .articelNavigation li:eq(1)").hide();
	
	$(".video-link").each(function(e){								 
		var oVideoListItem = $(this);
		var oVideoTitle = oVideoListItem.find("h2");
		var oImg = oVideoListItem.find("img");
		var oVideoLink = oImg.parent("a");
		var strImageSrc = oImg.attr("src");
		
		//	Handle video title
		oVideoTitle.html(oImg.attr("alt"));
		
		//	Handle video link
		oImg.attr("src", strImageSrc + "&sp=107");
		
		//	Set default movie
		if (e == 0) playVideo(oImg.attr("alt"), oVideoLink.attr("href"), oImg.attr("src"), false);	 
		
		oVideoLink.click(function(event){
			event.preventDefault();				 				 			 
		});
		
		oVideoListItem.click(function(){						 
			playVideo(oImg.attr("alt"), oVideoLink.attr("href"), oImg.attr("src"), true);				 			 
		});
		
		oVideoListItem.hover(
			function(){						 
				oVideoLink.addClass("hover");				 			 
			},
			function(){
				oVideoLink.removeClass("hover");
			}
		);
	});
}

function playVideo(title, video, image, autoplay) {
	var autostart = "";
	
	//	Set video title
	if ($.trim(title).length > 0) {
		$(".articleTitle span").html(title);
	}
	
	//	Set video player
	if(autoplay) {
		autostart = "&autostart=true";
	}
	
	var s1 = new SWFObject('designtemplates/pbz/include/media/player.swf','ply','480','340','9','#ffffff');
		
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('wmode','opaque');
	s1.addParam('flashvars','type=video&file=' + video + '&image=' + image + autostart);
	
	s1.write('video-player');
}

$(document).ready(function(){
	//	Handle First link in header navigation
	$("#navigation li:first").attr("style", "margin: 0");
	
	//	Search control handler
	$(".searchFieldWrapper input:text").keypress(function(e){
		if (e.which == 13) {
			doSearch();
		}
	});
	
	$("a.search").click(function(){
		doSearch();
	});
	
	$(".searchControlExpander").click(function(){
		if (!($(this).hasClass("searchControlExpanderExpanded"))) {
			$(".searchControlContainer").animate({width:"553px"}, 1000, "swing");
			$(this).animate({marginLeft:"740px"}, 1000, "swing").addClass("searchControlExpanderExpanded");	
		}
		else {
			$(".searchControlContainer").animate({width:"0px"}, 1000, "swing");
			$(this).animate({marginLeft:"178px"}, 1000, "swing").removeClass("searchControlExpanderExpanded");
		}
	});
	
	//	Product control handler
	$(".productControlExpander").click(function(){
		if (!($(this).hasClass("productControlExpanderExpanded"))) {
			$(".productControlContainer").animate({width:"553px"}, 1000, "swing");
			$(this).animate({marginLeft:"740px"}, 1000, "swing").addClass("productControlExpanderExpanded");	
		}
		else {
			$(".productControlContainer").animate({width:"0px"}, 1000, "swing");
			$(this).animate({marginLeft:"178px"}, 1000, "swing").removeClass("productControlExpanderExpanded");
		}
	});
	
	if ($(".productsWrapper li").length > 0) {
		$(".productsWrapper").jCarouselLite({
			btnNext: ".rightSlider",
			btnPrev: ".leftSlider",
			mouseWheel: true,
			//auto: 12000,
			speed: 1200
		});
	}
	
	//	Hide main navigation when search results or tag results is shown
	$("#searchResults, #tagResults").each(function(){
		$(".mainNavigation").hide();								   
	});
});