// Copyright Jochen Kieser - Softwareentwicklung und -beratung, Mannheim
// Last modified by jockie	2003/08/19

/**********************************************************************************   
print page  script: seperate window
*********************************************************************************/

function jkPrintPage (printwhat) {
	var w	= 580;
	var h	= 440;
	var l	= (screen.width - w) / 2;
	var t	= (screen.height - h) / 2;
	var p	= "dependant=yes,scrollbars=yes,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l;
	window.open("printpage.php?" + printwhat, "_blank", p);
}
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printitnow() {
	if (pr) {
		// NS4, IE5
		window.print();
	}
	else if (da && !mac) {
		// IE4 (Windows)
		vbPrintPage();
	}
	else {
		alert("Eine Druckfunktion ist in Ihrem Browser leider nicht enthalten.");
		return false;
	}
}

if (da && !pr && !mac) with (document) {
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	writeln('Sub window_onunload');
	writeln('  On Error Resume Next');
	writeln('  Set WB = nothing');
	writeln('End Sub');
	writeln('Sub vbPrintPage');
	writeln('  OLECMDID_PRINT = 6');
	writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
	writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	writeln('  On Error Resume Next');
	writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	writeln('End Sub');
	writeln('<' + '/SCRIPT>');
}


/**********************************************************************************   
form reset script
*********************************************************************************/

function clearAddressDoctorsForm() {
    window.document.AddressForm.search_name.value          = '';
    window.document.AddressForm.search_zip.value           = '';
    window.document.AddressForm.search_city.value          = '';
    window.document.AddressForm.search_additions.value     = '';
    window.document.AddressForm.search_country.selectedIndex    = 0;
    window.document.AddressForm.search_additions.selectedIndex  = 0;
    window.document.AddressForm.search_category.selectedIndex   = 0;
    window.document.AddressForm.search_general.value       = '';

}

function submitAddressSort(name, dir) {
    document.AddressForm.sortName.value     = name;
    document.AddressForm.sortDir.value      = dir;
    document.AddressForm.submit();
}

function submitAddressOffset(offset) {
    document.AddressForm.offset.value       = offset;
    document.AddressForm.submit();
}

function clearAddressHospitalsForm() {
    window.document.AddressForm.surname.value       = '';
    window.document.AddressForm.zip.value           = '';
    window.document.AddressForm.city.value          = '';
    window.document.AddressForm._countries_ID.selectedIndex = 0;
    reset_multi_select('_addressdiseases_ID[]');
    reset_multi_select('_addresskeywords_ID[]');
    reset_multi_select('_addressspecialities_ID[]');
}

function clearAddressRehaHospitalsForm() {
    window.document.AddressForm.surname.value       = '';
    window.document.AddressForm.zip.value           = '';
    window.document.AddressForm.fulltext.value      = '';
    window.document.AddressForm.city.value          = '';
    window.document.AddressForm._countries_ID.selectedIndex = 0;
    reset_multi_select('_addressspecialities_ID[]');
}

function clearAddressHealthcareForm() {
    window.document.AddressForm.surname.value       = '';
    window.document.AddressForm.zip.value           = '';
    window.document.AddressForm.fulltext.value      = '';
    window.document.AddressForm.city.value          = '';
    window.document.AddressForm._countries_ID.selectedIndex = 0;
    reset_multi_select('_addressspecialities_ID');
    reset_multi_select('state');
}

function clearAddressHeatlthDepForm() {
    window.document.AddressForm.zip.value           = '';
    window.document.AddressForm.fulltext.value      = '';
    window.document.AddressForm.city.value          = '';
    window.document.AddressForm._countries_ID.selectedIndex = 0;
    window.document.AddressForm.state.selectedIndex = 0;
}

function clearAddressInforprotalForm() {
    reset_multi_select('_addressdiseases_ID[]');
    reset_multi_select('_addresskeywords_ID[]');
    reset_multi_select('_addressspecialities_ID[]');
    window.document.AddressForm.fulltext.value = '';
}

function clearAddressSocpedForm() {
    window.document.AddressForm.zip.value = '';
    window.document.AddressForm.city.value = '';
    window.document.AddressForm.fulltext.value = '';
    window.document.AddressForm._countries_ID.selectedIndex = 0;
    window.document.AddressForm.state.selectedIndex = 0;
}

function submitEventsSort(name, dir) {
    document.EventsForm.sortName.value     = name;
    document.EventsForm.sortDir.value      = dir;
    document.EventsForm.submit();
}

function submitEventsOffset(offset) {
    document.EventsForm.offset.value       = offset;
    document.EventsForm.submit();
}
	
	
function reset_multi_select(objID){
	selObject=document.getElementById(objID)
	//cycle through the options collection, setting the selected attribute of each to false
	for (i=0;i<selObject.options.length;i++){
		selObject.options[i].selected=false;
	}

} 

function clearEventsForm() {
    window.document.EventsForm.from_day.selectedIndex = 0;
    window.document.EventsForm.from_month.selectedIndex = 0;
    window.document.EventsForm.from_year.selectedIndex = 0;
    window.document.EventsForm.through_day.selectedIndex = 0;
    window.document.EventsForm.through_month.selectedIndex = 0;
    window.document.EventsForm.through_year.selectedIndex = 0;
    window.document.EventsForm.freetext.value = '';
    reset_multi_select('type');
    reset_multi_select('keywords');
}

function clearHgdbGenesForm() {
    window.document.form1.name.value = '';
}

function clearHgdbDiseasesForm() {
    window.document.form1.name.value = '';
    window.document.form1.omim.value = '';
}

function clearHgdbLabsForm() {
    window.document.form1.name.value    = '';
    window.document.form1.city.value    = '';
    window.document.form1.zip.value     = '';
    window.document.form1.country.selectedIndex = 0;
    window.document.form1.disease.value = '';
}

function clearHgdbSearchForm() {
    window.document.form1.name.value    = '';
    window.document.form1.omim.value    = '';
    window.document.form1.tags.value    = '';
    window.document.form1.cs.value      = '';
    window.document.form1.pp.value      = '';
    window.document.form1.tp.value      = '';
    window.document.form1.kg.value      = '';
    window.document.form1.mt.value      = '';
}

/**********************************************************************************   
toggle layer script
*********************************************************************************/

ns4 = (document.layers)		? true : false;
ie4 = (document.all)		? true : false;
ng5 = (document.getElementById)	? true : false;


var c=0;
var obj;
var speed=1;

function fadeInOut(dir){
	if(obj.filters) {
	obj.style.filter = 'alpha(opacity = '+c+')';
	}
	else {
	obj.style.opacity = c / 100;
	}
	if(dir == 'in') {
	dir1 = 'in'
	c+=5;
	}
	else {
	dir1 = 'out';
	c-=5;
	}
	if(c > 100){
	c = 100;
	return;
	}
	if(c < 0){
	c = 0;
	return;
	}
	setTimeout('fadeInOut(dir1)',speed)
}

function hideLayer(laja) { 
	if (ng5) document.getElementById(laja).style.visibility = "hidden";
	else if (ns4) document.layers[laja].visibility = "hide";
	else if (ie4) document.all[laja].style.visibility = "hidden";
}

function showLayer(laja) { 
	if (ng5) document.getElementById(laja).style.visibility = "visible";
	else if (ns4) document.layers[laja].visibility = "show";
	else if (ie4) document.all[laja].style.visibility = "visible";
}

function undisplayLayer(laja) {
	if (ng5) document.getElementById(laja).style.display = "none";
	else if (ie4) document.all[laja].style.display = "none";
}

function displayLayer(laja) { 
	if (ng5) document.getElementById(laja).style.display = "";	// former: inline
	else if (ie4) document.all[laja].style.display = "";		// former: inline
}

function toggleHelp (laja) {
	var visible	= (ng5) ? document.getElementById(laja).style.display : document.all[laja].style.display;
	if (visible == 'none') {
		obj = document.getElementById(laja);
		displayLayer(laja);
		fadeInOut('in');
	}
	else {
		obj = document.getElementById(laja);
		fadeInOut('out');
		undisplayLayer(laja);
	}
}

