$(function() {
	/*
	 * Prodaji program menjava slik
	 */
	setTimeout(function() {
		$('#imagesContent').fadeIn(7000);
        $('#imagesContent') 
        .cycle({});
	}, 700);
	
    $("input[name='search_string']").focus(function () {
         $(this).val("");
    });
    
    
    
    
    var width = 125 * $(".navigation a").size();
    $("#siteMap .right").css("width", width + "px");
    
    
    callFancyBox();
    
    // toggles the slickbox on clicking the noted link
    $('a#slick-toggle').click(function() {
        $('#product-desc').toggle(400);
        return false;
    });
    
    

});

function callFancyBox(){
    
	
	$('a:has(img):not(:has(span.title):has(h2)):not(.no-fancybox)').fancybox({ 'overlayShow': true });
    
   
    
	if($("#productText").size()) {
	  /* var tab = $("#productText").css("height");
	   var array = tab.split("p");*/
       
       var d = document.getElementById('productText') // Get div element
       var dh = d.offsetHeight
       
       if (dh > 285) {
            $("#productText").css("width", "140px");
            $("#productText").css("height", 272 + "px");
            $('#productText').jScrollPane();
       }    
	}
}





function getSiteMap(path){
    if ($("#siteMap").css("display") == "none") {
        $("#sitemap a").attr("class", "open");
        $("#siteMap").show();
    }
    else { 
        $("#siteMap").hide();
        $("#sitemap a").attr("class", "");
    }
}

var plugin = 0;

if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		plugin = 1;
		
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
	document.write('<script language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
	document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
	document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
	document.write('//plugin= 1;\n');
	document.write('</script\> \n');
}

function flashBannerStr(bannerName, bannerWidth, bannerHeight, bannerLink, bannerSRC) {
	var BannerLinkEncode;
	bannerLinkEncode = escape(bannerLink);
	s = new String();
	s = s + '<object id="flash'+bannerName+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	s = s + ' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" ';
	s = s + ' id="' + bannerName + '" width="' + bannerWidth + '" height="' + bannerHeight + '"\> \n';
	s = s + ' <param name="movie" value="' + bannerSRC +'?clickthru=' + bannerLinkEncode +'" /> \n';
	s = s + ' <param name="quality" value="high"/> \n';
	s = s + ' <embed src="' + bannerSRC +'?clickthru=' + bannerLinkEncode +'" quality="high" ';
	s = s + ' swLiveConnect="false" width="' + bannerWidth + '" height="' + bannerHeight + '" ';
	s = s + ' type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
	s = s + ' </embed> \n';
	s = s + ' </object>\n';
	return(s);
}


function flashBanner(bannerName,bannerSRC,bannerIMG, bannerWidth, bannerHeight, bannerLink, bannerTarget){
	if ( plugin && bannerSRC!="") {
		document.write(flashBannerStr(bannerName, bannerWidth, bannerHeight, bannerLink, bannerSRC));
	}
	else if (!(navigator.appname && navigator.appname.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)) {
		
		if (bannerTarget == false) {
			cTarget = "";
		} else {
			cTarget = 'onclick="this.target=\'_blank\'"';
		}
		
		if (bannerWidth > 0) {
			cWidth  = "width:" + bannerWidth + "px;";
		} else {
			cWidth = "";
		}

		if (bannerHeight > 0) {
			cHeight = "height:" + bannerHeight + "px;";
		} else {
			cHeight = "";
		}
		
		cStyle = "style=\"border:none;" + cWidth + cHeight + "\"";

		document.write('<a class="clearfix banner-bottom no-fancybox" href="' + bannerLink + '" ' + cTarget + '><img src="' + bannerIMG + '" ' + cStyle + ' alt="" /></a>');
	}
}

$(document).ready(function(){
	$('#slider').cycle({
		fx:			'fade', 
		speed:		700, 
		timeout:	7000, 
		pager:		'#nav'
	});

});
