function fixH(one, two) {
    //alert('wow');
	if (document.getElementById(one) && document.getElementById(two)) {
        //alert('radi');
        var lh=document.getElementById(one).offsetHeight;
		var rh=document.getElementById(two).offsetHeight;
		var nh = Math.max(lh, rh);
		document.getElementById(one).style.height=nh+"px";
		document.getElementById(two).style.height=nh+"px";
		}
    return nh;
	}

function toggleLayer(whichLayer) {
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function openTarget (form, features, windowName) {
		if (!windowName)
		windowName = 'formTarget';
		form.target = windowName;
	open (form, windowName, features);
	}
	function makeEmail(name,domain,link) {
		if (link=='')
			document.write('<a href=mailto:'+name+'@'+domain+'>'+name+'@'+domain+'</a>');
	 	else 
			document.write('<a href=mailto:'+name+'@'+domain+'>'+link+'</a>');
	}
var bookmarkurl="http://www.virtualnigrad.com"
var bookmarktitle="VirtualniGrad |"

function addbookmark(){
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}
	var firstfenster = true;
    function GrossBild(Bildseite,Breite,Hoehe) {
    	fenster = window.open (Bildseite, "Bildseite","Width="+Breite+",Height="+Hoehe+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
        firstfenster = false;
    }
    function fensterzu() {
    	if (! firstfenster) {
        	if (fenster.closed == false) fenster.close();
        }
    }

function popUp(strURL,strType,strHeight,strWidth) {
	var strOptions="";
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;
	window.open(strURL, 'newWin', strOptions);
}

function setBookmark(url,str){
if(str=='')str=url;
if (document.all)window.external.AddFavorite(url,str);
else alert('Pritisnite CTRL i D da bi dodali u svoje bookmark:\n"'+str+'".');
}

function checkForm(){
    var a = document.forms['form1'].what_search.value;
	if (document.forms['form1'].src_opt[0].checked) {
        //if (a == '')
            document.forms['form1'].action = 'tx';
        //else
        //    document.forms['form1'].action = 'tx-'+a;
        //alert('tx-'+a);
		}
	else{
		document.forms['form1'].action = 'search-what-'+a;
		}
	return true;
}

function getSearch() {
    if(document.forms['pretraga_firmi'].what.value != '') {
        var a = document.forms['pretraga_firmi'].what.value;
        document.forms['pretraga_firmi'].action = 'search-what-'+a;
        }
    }

// popUpDiv sa css
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=45;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-400;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
// JS za 360 fotografije
function jumpVpic(objSel){   
  //window.status=objSel.options[objSel.selectedIndex].value;
  document.ptviewer.newPanoFromList(objSel.options[objSel.selectedIndex].value);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function DoAutorotationStart() {
        document.ptviewer.startAutoPan( 0.5, 0.0, 1.0 );
}
function DoAutorotationStop() {
        document.ptviewer.stopAutoPan();
}
function DoZoomIn() {
	document.ptviewer.startAutoPan( 0.0, 0.0, 1.0/1.03 );
}
function DoZoomOut() {
	document.ptviewer.startAutoPan( 0.0, 0.0, 1.03 );
}
function DoShowHideHotspots() {
	document.ptviewer.toggleHS();
}
function DoReset() {
	document.ptviewer.gotoView( -1.39, 0.86, 90 );
}
function DisplayPan() {
	status = document.ptviewer.pan().toString() ;
}
function DisplayTilt() {
	status = document.ptviewer.tilt().toString() ;
}
function DisplayFov() {
	status = document.ptviewer.fov().toString() ;
}
function mousehs(n) {
	if( n== -1 )
   			document.cn.hsnum.value = "---" ;
	else
   			document.cn.hsnum.value = n ;
}
function getview(p,t,f) {
   document.cn.pan.value = p ;
   document.cn.tilt.value = t ;
   document.cn.fov.value = f ;
}
function NewPano0() {
document.ptviewer.newPanoFromList(0)
}
function NewPano1() {
document.ptviewer.newPanoFromList(1)
}
function NewPano2() {
document.ptviewer.newPanoFromList(2)
}
function NewPano3() {
document.ptviewer.newPanoFromList(3)
}
function NewPano4() {
document.ptviewer.newPanoFromList(4)
}
function NewPano5() {
document.ptviewer.newPanoFromList(5)
}
