// JavaScript Document
var dom_implementation = document.implementation && true;
var dom_cerate_document = dom_implementation && document.implementation.createDocument;
var dom_feature = dom_implementation && document.implementation.hasFeature;
var moz = dom_cerate_document && dom_feature;
var safari = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1));
var ie = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
var nn4 = (navigator.appName.indexOf("Netscape") > -1 && navigator.appVersion.indexOf("4") > -1) ? true:false                 
var nn6 = (document.getElementById) ? true:false
var java_vitrin; 


function getId(id){
//var layer = (nn4) ? document.layers[id] : (ie) ? document.all[id] : document.getElementById(id) ; 
var layer = document.getElementById(id) ; 
return layer; 
}

function createBookmarkLink(title,url) {

	if (window.sidebar) 
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) 
	{ // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print) 
	{ // Opera Hotlist
		return true; 
	}
 }

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}


var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
		listEvents.push(arguments);
	},
	flush : function(){
	var i, item;
	for(i = listEvents.length - 1; i >= 0; i = i - 1){
	item = listEvents[i];
		if(item[0].removeEventListener){
			item[0].removeEventListener(item[1], item[2], item[3]);
		};
		if(item[1].substring(0, 2) != "on"){
			item[1] = "on" + item[1];
		};
		if(item[0].detachEvent){
			item[0].detachEvent(item[1], item[2]);
		};
		item[0][item[1]] = null;
	};
	}
	};
}();


function sysDialogBoxWindowLoad(obj) {
	$("#SysDialogBoxWindow").load(jQuery(obj).attr("href"));
	$("#SysDialogBoxWindow").dialog("open");
	return false; 
}

function sysTopLinkBlockLoad(obj,id) {
	var divId = $(obj).attr("title");
	$('#linkMiddleBar > ul').tabs('select', id);
	$('#'+divId).load($(obj).attr("href"));
	$.scrollTo('#linkMiddleBar', 800);
	return false; 
}

function flashTextPrint(fontName,id,width,height,fColor,fSize,fLineHeight,fLineColor,fnoLine){
	flashText = $('#'+id).html();
	//$('#'+id).html('');
	$('#'+id).flash ({ src: '/_interface/_swf/font/'+fontName+'.swf',  width: width,  height: height, flashvars: { cdata:flashText , fColor:fColor, fSize:fSize, fLineHeight:fLineHeight,fLineColor:fLineColor,fnoLine:fnoLine }, wmode: 'transparent', bgcolor: '#FFFFFF' });
}

function printFaceboxPage(){
		$.jPrintArea('#SysDialogBoxWindow');
        $.facebox.close();
}

function formSelectSelectButton(obj) {
	listenerId=obj.id; 
	inputIdName=listenerId+'check';
	inputValue=getId(inputIdName).value; 
	if(inputValue==0) {
		getId(inputIdName).value='1'; 
		obj.className='selected';
	} else {
		getId(inputIdName).value='0';
		obj.className='noselected';
	}
} 

function formSelectRadioButton(id,numOfValue,value) {
	radioId = id+'radio'; 
	for (i=1; i<=numOfValue; i++){
		containerId = id+i; 
		if(i==value) {
			getId(containerId).className='selected';
			getId(radioId).value = i; 
		} else {
			getId(containerId).className='noselected';
		}
	} 
	
} 



function setPositionsHomepage(){
	page_height = $(".main").height(); 
	title_height = $(".header").height();
	footer_height = $(".footer").height();
	content_height = $(".content").height();
	video_height = $("#flashContainerContent").height();
	total_height = page_height;
	window_height = $(window).height(); 
	var window_height = jQuery.browser.opera ? window.innerHeight : jQuery.browser.safari ? window.innerHeight : jQuery(window).height(); 

	containerHeight = window_height-title_height-footer_height;
	content_diff = containerHeight - content_height;
	page_diff = content_diff / 2;
	var object_height;
	if(page_diff>0) {
		video_diff = page_diff+video_height;
		object_height = video_diff*2;
	} else {
		video_diff = (page_diff*2)+video_height;
		object_height = video_diff*2;
		page_diff = 0;
	}
	
	if(containerHeight>400) { 
		$('#flashContainerContent').css("height",video_diff+"px");
		$('#flashContainerContent').css("width",object_height+"px");
		//$(".content").css("margin-top",page_diff+"px");
		$(".content").css("margin-bottom",page_diff+"px");
		$('#pane').jScrollPane({showArrows:true});
	}
}


function setPositions(){
	menuMaxPosition = 20;
	page_height = $(".main").height(); 
	title_height = $(".header").height();
	footer_height = $(".footer").height();
	content_height = $(".content").height();
	total_height = page_height;
	window_height = $(window).height();
	var window_height = jQuery.browser.opera ? window.innerHeight : jQuery.browser.safari ? window.innerHeight : jQuery(window).height(); 
	containerHeight = window_height - title_height - footer_height;
	content_diff = containerHeight - content_height;
	
	page_diff = content_diff / 2;
	//alert(page_diff);
	if(containerHeight>400) { 
	
		menuPosition = page_diff-menuMaxPosition; 
		if(menuPosition<0) menuPosition=0;
		else if(menuPosition>menuMaxPosition) menuPosition=menuMaxPosition; 
		
		$("#SubMenuContainer").css("top","-"+menuPosition+"px");
		$(".content").css("margin-top",page_diff+"px");
		$(".content").css("margin-bottom",page_diff+"px");
		//$('#pane').jScrollPane({showArrows:true});
	}
}

