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

$('.thumb').fancybox({
	'transitionIn'	:	'elastic',
	'transitionOut'	:	'fade',
	'easingIn'			: 'easeOutBack',
	'speedIn'				:	400,
	'speedOut'			:	200,
		'titlePosition' 	: 'inside',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
});

///
});

var bo_ns_id = 0;

function startIeFix(){
  if(isIE()){
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}

function endIeFix(){
  if(isIE()){
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
    document.write(theCode);
  }
}

function isIE(){
  // only for Win IE 6+
  // But not in Windows 98, Me, NT 4.0, 2000
  var strBrwsr= navigator.userAgent.toLowerCase();
  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
    if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
      return false;
    }
    if(strBrwsr.indexOf("win98") > -1 ||
       strBrwsr.indexOf("win 9x 4.90") > -1 ||
       strBrwsr.indexOf("winnt4.0") > -1 ||
       strBrwsr.indexOf("windows nt 5.0") > -1)
    {
      return false;
    }
    return true;
  }else{
    return false;
  }
}

function popup_image(image, width, height, title, server) {
	
	popwindow = window.open('http://' + server + '/image.php?src=' + image + '&title=' + title, null, 'top=128, left=128, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=128, height=128');
	popwindow.focus();
	return popwindow;
	
}

function openimage(querystring, width, height) {
	popwindow = window.open('include/popimage.php' + querystring, null, 'top=128, left=128, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + width + ', height=' + height);
	var agt=navigator.userAgent.toLowerCase();
	this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
		&& (agt.indexOf('webtv')==-1));
	this.opera = (agt.indexOf("opera") != -1);
	if(nav){
		popwindow.resizeTo(width+7, height+48);
	}
	else if(opera) {
		popwindow.resizeTo(width+12, height+31);
	}
	else {
		popwindow.resizeTo(width+10, height+29);
	}
	popwindow.focus();
}

function border_switch(imgid, color) {
	var img = document.getElementById(imgid);
	img.style.borderBottom = '5px solid #' + color;
}

function getWindowHeight() {
	var windowHeight = 0;
	if(typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if(document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if(document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setFooterBox() {
	if(document.getElementById) {
		var windowHeight = getWindowHeight();
		if(windowHeight > 0) {
			var mainBoxHeight = document.getElementById('mainbox').offsetHeight;
			var footerBoxElement = document.getElementById('footerbox');
			var footerBoxHeight  = footerBoxElement.offsetHeight;
			if(windowHeight - (mainBoxHeight + footerBoxHeight) >= 0) {
				footerBoxElement.style.position = 'absolute';
				footerBoxElement.style.top = (windowHeight - footerBoxHeight) + 'px';
				footerBoxElement.style.visibility = 'visible';
			}
			else {
				footerBoxElement.style.position = 'absolute';
				footerBoxElement.style.top = (mainBoxHeight - footerBoxHeight) + 'px';
				footerBoxElement.style.visibility = 'visible';
			}
		}
	}
}

function setFooter()
{
	var wh = jQuery(window).height();
	var ch = jQuery('.container').height();

	jQuery('.mainbox').height( wh > ch ? wh : ch );
}

window.onload = function() {
	setFooter();
	jQuery('#footerbox').show();
}

window.onresize = function() {
	setFooter();
}





var vdive;
var marker;
var map;

function initialize() {
  var mapOptions = {
    zoom: 13,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: vdive
  };

  map = new google.maps.Map(document.getElementById("map_canvas"),
          mapOptions);
        
  marker = new google.maps.Marker({
    map:map,
    draggable:true,
    animation: google.maps.Animation.DROP,
    position: vdive
  });
  //marker.setAnimation(google.maps.Animation.BOUNCE);
  google.maps.event.addListener(marker, 'click', toggleBounce);
}

function toggleBounce() {
  if (marker.getAnimation() != null) {
    marker.setAnimation(null);
  } else {
    marker.setAnimation(google.maps.Animation.BOUNCE);
  }
}
