
/* Diese Variable speichert das zuletzt geoeffnete Top Menu, bis es wieder geschlossen wird */
var _lastTM = null;

/* Diese Funktion oeffnet ein bestimmtes Top Menue, und schliesst evtl. bereits geoeffnete vorher. */
function showTopMenu(tm) {
	var curr_id = null;
	if(document.getElementById) {
		if(document.getElementById('top_menu_'+tm+'_sub')) {
			curr_id = document.getElementById('top_menu_'+tm+'_sub');
		} else {
			return(false);
		}
	}

	if(_lastTM != null) {
		_lastTM.style.visibility = 'hidden';
	}
	if(_lastTM != curr_id) {
		curr_id.style.visibility = 'visible';
		_lastTM = curr_id;
	} else {
		_lastTM = null;
	}
}

function hoverCountry(c, mode) {
	if(document.getElementById) {
		var img = document.getElementById('flag_'+c);
		switch(mode) {
			case 0: // off
				img.src = '_gfx/flag_'+c+'_sw.gif';
			break;
			case 1: // on
				img.src = '_gfx/flag_'+c+'.gif';
			break;
		}
	}
}


function checkLoginForm(f, act) {
	var frm = document.forms[f];
	var pre = '';
	if(!frm) {
		return(false);
	}
	switch(f) {
		case 'customer_frm':
			pre = 'cf';
		break;
		case 'service_frm':
			pre = 'svs';
		break;
		case 'partner_frm':
			pre = 'pf';
		break;
	}
	switch(act) {
		case 'logout':
			frm.submit();
		break;
		case 'login':
			if(frm.elements[pre+'_login'].value.length > 0) {
				if(frm.elements[pre+'_pass'].value.length > 0) {
					frm.submit();
				}
			}
		break;
	}
}


function openEplusCheck(str_url, str_title, boo_resizable) {

	// all except Explorer
	if (self.innerHeight) {
		var int_height = self.innerHeight;
	}
	// Explorer 6 Strict Mode
	else if (document.documentElement && document.documentElement.clientHeight)	{
		var int_height = document.documentElement.clientHeight;
	}
	// other Explorers
	else if (document.body) {
		var int_height = document.body.clientHeight;
	}

	var int_width 	= parseInt(int_height*1.33);

	//var int_height	= 600;
	int_height			= parseInt(int_height-70);
	var int_width 	= parseInt(int_height*1.33);

	openWindow(str_url, int_width, int_height, str_title, boo_resizable);

	document.getElementById('eplusAvailable').style.visibility = 'visible';
}

function openOrderHelpWindow(str_url, int_width, int_height, str_title) {
	win = new Window({title: str_title, width:int_width, height:int_height, zIndex: 100, resizable:false, minimizable:false, maximizable:false, url: str_url, destroyOnClose:true, recenterAuto:true});
	return win.showCenter();
}

function openWindow(str_url, int_width, int_height, str_title, boo_resizable) {
	win = new Window({title: str_title, width:int_width, height:int_height, zIndex: 100, resizable:boo_resizable, minimizable:false, maximizable:false, url: str_url, destroyOnClose:true, recenterAuto:false});
  return win.showCenter();
}



var tariffSelected;

function toggleTariffOption(order_tariff_id) {

	if (tariffSelected != undefined && document.getElementById('tariffOption' + tariffSelected))
		document.getElementById('tariffOption' + tariffSelected).style.display 	= 'none';

	if (document.getElementById('tariffOption' + order_tariff_id))
		document.getElementById('tariffOption' + order_tariff_id).style.display = 'block';

	tariffSelected = order_tariff_id;

}


// Funktion zum Setzen der Höhe der SideBar
// und Positionieren der Buttons (zurück und weiter)

function setSidebarHeight() {

	var int_heightMainSection	= (document.getElementById('main_section')) ? document.getElementById('main_section').offsetHeight 	: 0;
	var int_heightTopLogo			= (document.getElementById('top_logo')) 		? document.getElementById('top_logo').offsetHeight			: 0;
	var int_heightTopNavi			= (document.getElementById('top_navi'))			? document.getElementById('top_navi').offsetHeight			: 0;
	var int_heightKeyGfx			= (document.getElementById('key_gfx')) 			? document.getElementById('key_gfx').offsetHeight				: 0;

	if (document.getElementById('side_bar')) {

		var int_heightSideBar	= document.getElementById('side_bar').offsetHeight;

		int_heightMainSection	= parseInt(int_heightMainSection - int_heightTopLogo - int_heightTopNavi - int_heightKeyGfx);

		var int_height				= (int_heightSideBar < int_heightMainSection) ? int_heightMainSection : int_heightSideBar;

		// Höhe der SideBar setzen
		document.getElementById('side_bar').style.height = int_height + 'px';

		// Höhe des Spacers setzen
		if (document.getElementById('orderOverviewSpacer')) {

			var int_heightCustomerLogin	= (document.getElementById('customerLogin')) 			? document.getElementById('customerLogin').offsetHeight 					: 0;
			var int_heightPartnerLogin	= (document.getElementById('partnerLogin')) 			? document.getElementById('customerLogin').offsetHeight 					: 0;

			var int_heightEutelsat	= (document.getElementById('eutelsat')) 							? document.getElementById('eutelsat').offsetHeight 								: 0;
			var int_heightOverview	= (document.getElementById('orderOverview')) 					? document.getElementById('orderOverview').offsetHeight						: 0;
			var int_heightButtonRow	= (document.getElementById('orderOverviewButtonRow')) ? document.getElementById('orderOverviewButtonRow').offsetHeight	: 0;
			var int_heightSpacer		= parseInt(int_height - int_heightEutelsat - int_heightOverview - int_heightButtonRow - int_heightCustomerLogin - int_heightPartnerLogin - 35);

			document.getElementById('orderOverviewSpacer').style.height = int_heightSpacer + 'px';
		}
	}
}


// Funktion zum An- und Abschalten des Eingabefeldes für Ust-Nr.

function formRowUstToggle(obj) {
	if (document.getElementById('formRowUst')) {
		document.getElementById('formRowUst').style.display = (obj.value != '') ? 'block' : 'none';
	}
}
