/*
K-Scripte

Copyright © Kristijan Vujovic 2010 All Rights Reserved.
No part of this document may be reproduced without written consent from the author.

More info: http://www.kristijan-solutions.com/

*/

$j(window).resize(function(){ // ----- KAD SE PROZOR POVECAVA/SMANJUJE IZVRSI OVO -----
	
	// alert ($j(document).height()); <=> alert (document.documentElement.scrollHeight);
	
	PodesiVisinu();
	
	//*** SNOW - Added for resize - www.kristijan-solutions.com
	/*if (typeof ResizeTimer != "undefined") { clearTimeout(ResizeTimer); }
	ResizeTimer = setTimeout(function () {
		if ($j(".snowflakes").length > 0) {
			if (ie) {
			
				if(document.documentElement){
				marginright = document.documentElement.clientWidth
				}
				else if(document.body){
				marginright = document.body.clientWidth
				}
			}
			else if (ns_moz|| opera) {
				marginright = window.innerWidth
			}
			
		}
	}
	, 300);*/
	
/*var changeImageTimeout = null;

function changeImage()
{
    ...
    // you might not need this, but it's not a bad idea:
    if ( changeImageTimeout != null ) clearTimeout(changeImageTimeout);
    changeImageTimeout = setTimeout('changeImage()',1000);
}
function stopChangeImage()
{
    // don't call clear if it's not set...
    if ( changeImageTimeout != null ) clearTimeout(changeImageTimeout);
    changeImageTimeout = null; // tell yourself nothing is active
}*/
	
});

$j(window).load(function(){ // ----- KAD SE STRANICA UCITA IZVRSI OVO -----
	
	// prettyPhoto jQuery Lightbox settings and initialization
	if (typeof isRunningIE6OrBelow == "undefined") { // ako nije IE6 (Internet Explorer 6)
		
		$j("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});
		
	}

});

$j(document).ready(function(){
	
	PodesiVisinu();
	
	// Za opis stavki u jCarusel-u
	$j("#WebfolioCarousel img").mouseenter(function() {
		
		if (typeof CarT != "undefined") { clearTimeout(CarT); }
		$j(this).fadeTo("fast", 0.5);
		if ($j(this).attr("alt") !== "offline") {
			var cTxt = "Web design references: <span style='color: #77FF55;'>" + $j(this).attr("title") + "</span>";
		} else {
			var cTxt = "Web design references: <span style='color: #FFB5B5;'>(offline) " + $j(this).attr("title") + "</span>";
		}
		$j("#CarouselReference").html(cTxt);
		
	}).mouseleave(function(cTxt) {
		
		$j(this).fadeTo("fast", 1);
		CarT = setTimeout ('$j("#CarouselReference").html("Web design references:");', 700);
		
	});
	
	//$j('body').prepend('<div style="position: absolute; left: 50%; top: 0px;"><a href="http://www.nadlanu.com/pocetna/specijalno/web-fest/Kristijan-SolutionsCom.wf-376.429.html" target="_blank" style="position: relative; left: 1px; top: 15px; display: block; float: left;"><img src="http://www.kristijan-solutions.com/slike/Kristijan-Solutions-Web-fest.png" /></a></div>');
	
});

function SlideUpDown(nesto, brzina) {
	
	if (typeof SlideTimer !== "undefined") { clearTimeout(SlideTimer); }
	
	$j("#"+nesto+"").slideToggle(brzina, function() {
		
		if ($j("#"+nesto+"").is(':visible') && ($j("#"+nesto+" iframe").length > 0)) { // ako je skriveno i ako se radi o iframe-u
			$j("#"+nesto+" iframe").attr({
				src: $j("#"+nesto+" iframe").attr("src")
			});
			return false;
		} 
		if (typeof isInternetExplorer !== "undefined") { // Fix donjeg karuzela za IE
			$j('.jcarousel-skin-K .jcarousel-container-horizontal').css("bottom", "0px");
		}
		
	});
	
}

function PodesiVisinu() { // Podesavanje visine
	
	var MainTableContH = $j("#BottomContainer > table").height();
	var bodyh = $j("body").height();
	
	$j("#BottomContainer > table").css("height", bodyh);
	
}

/*
// --------------------- > Skripta za snijeg
// -------------------------------------------------------------

// CREDITS:
// Snowmaker Copyright (c) 2003 Peter Gehrig. All rights reserved.
// Distributed by http://www.hypergurl.com
// Permission given to use the script on webpages provided that this notice remains as is.
// Modified 2007 for DOM compliant browsers by Kor corneliulucian[at]gmail.com

// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax=35

// Set the colors for the snow. Add as many colors as you like
var snowcolor=new Array("#FFFFFF")

// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Times","Comic Sans MS") // Array("Arial Black","Arial Narrow","Times","Comic Sans MS")

// Set the letter that creates your snowflake (recommended:*)
var snowletter="*"

// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=0.7

// Set the maximal-size of your snowflaxes
var snowmaxsize=21

// Set the minimal-size of your snowflaxes
var snowminsize=8

// Set the snowing-zone
// Set 1 for all-over-snowing, set 2 for left-side-snowing 
// Set 3 for center-snowing, set 4 for right-side-snowing
var snowingzone=1

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////


// Do not edit below this line
var snow=new Array()
var marginbottom
var marginright
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var browserinfos=navigator.userAgent 
var ie=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var ns_moz=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/)  
var browserok=ie||ns_moz||opera

function randommaker(range) {		
	rand=Math.floor(range*Math.random())
    return rand
}

function initsnow() {
	if (ie) {
	
		if(document.documentElement){
		marginbottom = document.documentElement.clientHeight
		marginright = document.documentElement.clientWidth
		}
		else if(document.body){
		marginbottom = document.body.clientHeight
		marginright = document.body.clientWidth
		}
	}
	else if (ns_moz|| opera) {
		marginbottom = window.innerHeight
		marginright = window.innerWidth
	}
	var snowsizerange=snowmaxsize-snowminsize;
	for (var i=0;i<=snowmax;i++) {
		crds[i] = 0;                      
    	lftrght[i] = Math.random()*15;         
    	x_mv[i] = 0.03 + Math.random()/10;
		snow[i]=document.getElementById("s"+i)
		snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
		snow[i].size=randommaker(snowsizerange)+snowminsize;
		snow[i].style.fontSize=snow[i].size+'px'
		snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
		snow[i].sink=sinkspeed*snow[i].size/5
		if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
		if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
		if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
		if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
		snow[i].posy=randommaker(6*marginbottom-marginbottom-6*snow[i].size)
		snow[i].style.left=snow[i].posx+'px'
		snow[i].style.top=snow[i].posy+'px'
	}
	movesnow()
}

function movesnow() {
	for (var i=0;i<=snowmax;i++) {
		crds[i] += x_mv[i];
		snow[i].posy+=snow[i].sink
		snow[i].style.left=(snow[i].posx+lftrght[i]*Math.sin(crds[i]))+'px';
		snow[i].style.top=(snow[i].posy)+'px';
		
		if (snow[i].posy>=marginbottom-6*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
			if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
			if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
			if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
			if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
			snow[i].posy=0
		}
	}
	var timer=setTimeout("movesnow()",50)
}

for (var i=0;i<=snowmax;i++) {
	document.write('<span id="s'+i+'" style="position:absolute;top:-'+snowmaxsize+'px" class="snowflakes">'+snowletter+'</span>');
}
if (browserok) {
	window.onload=initsnow
}

// -------------------------------------------------------------
// --------------------- > KRAJ Skripte za snijeg
*/
