// JavaScript Document

//FUNKCIJA ZA OTVARANJE PROZORA
function openwindowdata(url)
{
	window.open(url,"idemvan.hr","menubar=0,resizable=yes,scrollbars=yes,width=400,height=600");
}
//FUNKCIJA ZA OTVARANJE PROZORA


/////////////////////////////////////////MENU

var menuids=["treemenu1"] ;
function buildsubmenus_horizontal(){
	
for (var i=0; i<menuids.length; i++){
	if(document.getElementById(menuids[i]).getElementsByTagName("ul")){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
	}
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal) 
/////////////////////////////////////////MENU

//FORMA ZA UNOS KOMENTARA
        $(document).ready(function() { 
		var options = { 
        //target:        '#comment_output',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequestComment,  // pre-submit callback 
        success:       showResponseComment,  // post-submit callback 
 		resetForm: true,     // reset the form after successful submit 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        
 contentType: "application/x-www-form-urlencoded;charset=utf-8"
        // $.ajax options can be used here too, for example: 
        //timeout:10000 
    };
            // bind 'myForm' and provide a simple callback function 
            $('#comment_form').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    });
        }); 
//FORMA ZA UNOS KOMENTARA	


//PRIKAZUJE REZULTAT FORME
function showResponseComment(responseText, statusText)  {
	//document.getElementById('comment-div').innerHTML = '<img class="comment_loading_img" src="template_idemvan/css_images/loading.gif" />';
	if(responseText=="da"){
	document.getElementById('comment-div').innerHTML = responseText;
	}
	else{
	document.getElementById('comment-div').innerHTML = responseText;	
	}
}
//PRIKAZUJE REZULTAT FORME

//CHEKIRA FORMU PRIJE NEGO JU POSALJE
function showRequestComment(formData, jqForm, options) { 
var send=true;
    var queryString = $.param(formData); 

var ime=jqForm[0][0].value;
var komentar=jqForm[0][1].value;
    //alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return send; 
}
//CHEKIRA FORMU PRIJE NEGO JU POSALJE


//SMANJUJE DUZINU UNOSA U INPUT
function input_max_length(input,length){
	//var comment_form.this.value = '';
	if(document.getElementById(input).value.length>length){
		var string=document.getElementById(input).value;
	document.getElementById(input).value=string.substring(0,length);	
	}
	
}
//SMANJUJE DUZINU UNOSA U INPUT


//CAROUSEL KOD ITEM-A
jQuery(document).ready(function() {
    jQuery('#itemcarousel').jcarousel();
});

jQuery(document).ready(function() {
								
    jQuery("#itemcarousel").jcarousel({
		vertical: true,
        scroll: 2,
        initCallback: itemcarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

function itemcarousel_initCallback(carousel) {
    jQuery('#itemcarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#itemcarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
//CAROUSEL KOD ITEM-A


//CAROUSEL U LISTI CONTENT-A
jQuery(document).ready(function() {
    jQuery('#livecarousel').jcarousel();
});

jQuery(document).ready(function() {
								
    jQuery("#livecarousel").jcarousel({
        scroll: 3,
        initCallback: livecarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

function livecarousel_initCallback(carousel) {
    jQuery('#livecarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#livecarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
//CAROUSEL U LISTI CONTENT-A


jQuery(document).ready(function() {
    jQuery('#mycarousel1').jcarousel();
});
						   

jQuery(document).ready(function() {
    jQuery('#mycarousel2').jcarousel();
});

jQuery(document).ready(function() {
    jQuery('#mycarousel3').jcarousel();
});

jQuery(document).ready(function() {
    jQuery('#mycarousel4').jcarousel();
});

jQuery(document).ready(function() {
    jQuery('#mycarousel5').jcarousel();
});

jQuery(document).ready(function() {
    jQuery('#mycarousel6').jcarousel();
});


// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel1").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback1,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel2").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback2,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel3").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback3,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel4").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback4,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel5").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback5,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel6").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback6,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});


function mycarousel_initCallback1(carousel) {
    jQuery('#mycarousel1-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel1-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};


function mycarousel_initCallback2(carousel) {
    jQuery('#mycarousel2-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel2-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback3(carousel) {
    jQuery('#mycarousel3-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel3-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback4(carousel) {
    jQuery('#mycarousel4-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel4-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback5(carousel) {
    jQuery('#mycarousel5-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel5-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback6(carousel) {
    jQuery('#mycarousel6-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel6-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};












var isMSIE=navigator.appVersion.indexOf('MSIE')!=-1;
function addtofavorite(){if(!isMSIE){window.sidebar.addPanel(document.title,location.href,'');}else{window.external.AddFavorite(location.href,document.title);}}

