var t1 = 0;
var carr = new Array();
var opendiv = 0;
$(document).ready(function(){
	$(".menu_active_item").parents("ul[id$='child']").show().parent("li").toggleClass("menu_parent_active");
	$("#products").mouseover(function(){
		if (t1){
			clearTimeout(t1);
			t1 = null;
		}
		var prodcoord = $("#products").offset();
		$("ul.sf-menu").css({top: prodcoord.top+24, left: prodcoord.left});
		$("ul.sf-menu").show();
		}).mouseout(function(){
			t1 = setTimeout('$("ul.sf-menu").hide()', 400);
	});
	$("ul.sf-menu").mouseover(function(){
		if (t1){
			clearTimeout(t1);
			t1 = null;
		}
	}).mouseout(function(){
		t1 = setTimeout('$("ul.sf-menu").hide();', 400);
	});

	$("ul.sf-menu").superfish({ 
            speed: 100,
            delay: 0
    });
	
});



function OpenFileBrowser( url, width, height ){
	// oEditor must be defined.
	var iLeft = ( screen.width - width ) / 2 ;
	var iTop = ( screen.height - height ) / 2 ;
	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;
	sOptions += ",width=" + width ;
	sOptions += ",height=" + height ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;
	window.open( url, 'FCKBrowseWindow', sOptions ) ;
}

function templatewindow(path, to) {
	OpenFileBrowser( 'admin.php?page=fmanager&action=filebrowser&path='+path+'&to='+to, 600, 400 );
}

function show_child(id){
	$("#"+id).parent("li").toggleClass("menu_parent_active");
	$("#"+id).slideToggle();
}

function em(box, server, zone, img)
{
 var at = String.fromCharCode(64);
 if (img == 1)
 	return '<a href="'+'mai'+'lto'+':'+box+at+server+'.'+zone+'">';
 else
 	return '<a href="'+'mai'+'lto'+':'+box+at+server+'.'+zone+'">'+box+at+server+'.'+zone+'<'+'/a>';
}

function PopUp(url, name, width,height,center,posleft,postop)
{
	showx = "";
	showy = "";
	
	if (posleft != 0) { X = posleft; }
	if (postop  != 0) { Y = postop  }
	
	if ((parseInt (navigator.appVersion) >= 4 ) && (center))
	{
		X = (screen.width  - width ) / 2;
		Y = (screen.height - height) / 2;
	}
	
	if (posleft == 0)
	{
		X = (screen.width  - width ) / 2;
	}	
	if ( X > 0 )
	{
		showx = ',left='+X;
	}

	if(postop  == 0)
	{
		Y = (screen.height - height) / 2;
	}	
	if ( Y > 0 )
	{
		showy = ',top='+Y;
	}
	
	Win = window.open( url, name, 'width='+width+',height='+height+ showx + showy + ',resizable=no,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no');
	return Win;
}
