﻿var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}

function jsddm_close()
{	
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function jsddm_timer()
{	
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer()
{	
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

$(document).ready(function()
{	
	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
});
document.onclick = jsddm_close;


var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	

		$(this.parent).append(modal);

		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
	}
};

var openMyModal = function(source)
{
	modalWindow.windowId = "myModal";
	modalWindow.width = 480;
	modalWindow.height = 405;
	modalWindow.content = "<iframe width='480' height='405' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";
	modalWindow.open();
};

$(document).ready(function()
{
    // define sizes
    var cssBegin = { width: 150, height: 150};
    var cssMax   = { width: 150, height: 150};

    // init images with the small size
    $('img.object').css(cssBegin);

    // init click event on all images
    $("img.object").click(function(){ 
        $(this).animate(cssMax, 'slow'); 
    }); 
});

function centrePage() { 
	var browser = navigator.appName; 
	var b_version = navigator.appVersion; 
	var arrVersion = b_version.split(";"); 
	var versionStr = ""; 
	var i; 
	for (i = 0; i < arrVersion[1].length; i++) { 
		if (isNaN(arrVersion[1][i]) == false) { 
			versionStr = versionStr + arrVersion[1][i]; 
		} 
		else if (arrVersion[1][i] == ".") { 
			versionStr = versionStr + arrVersion[1][i]; 
		} 
	} 
	var version = parseFloat(arrVersion[1].replace("MSIE ", "")); 
	var contDv = document.getElementById("main"); 
	
	if ((browser == "Microsoft Internet Explorer") && (version==7)) { 
		contDv.style.left = lSpace; 
	} 	 
} 
