// jQuery onload
$(document).ready(function () {

	$.scrollTo(".scrollTo", 400);
	initBinding();

});

// Initial Binding
function initBinding() {

	/* Let's prevent doubleclicking of forms
	$("form").each(function(){
		var $that = $(this);
		$that.submit(function(){
			$that.find("input[type='image'],input[type='submit']").click(function(){
				alert("Pošiljanje obrazca je v teku. Prosimo počakajte trenutek.");
				return false;
			});
		});
	});*/
	
	$('.scrollpics').cycle({
		fx:    'fade',
		speed:  4000
	});
	
	$(function() {
        $('.scrollpics a').lightBox();
    });
	
	$(function() {
        $('.lightbox').lightBox();
    });

}

// Kills IE6 warning and
// uses jquery fade
function killIt(item){
	$(function(){
		$('#'+item).fadeOut(1000);
	});
}

 /**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Prosimo, preverite elektronski naslov.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Prosimo, preverite elektronski naslov.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Prosimo, preverite elektronski naslov.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Prosimo, preverite elektronski naslov.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Prosimo, preverite elektronski naslov.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Prosimo, preverite elektronski naslov.")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Prosimo, preverite elektronski naslov.")
		    return false
		 }

 		 return true
	}

function ValidateForm(){
	var emailID=document.contactForm.email

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Pozabili ste vpisati svoj elektronski naslov.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
