/**
 *  2006 Roman Richter
 *
 *  Javascript-helper for displaying and modify 
 *  lifeline beautysurgeon database.  
 *
 */

/**
 *  Show beautysurgeon photo from database and hide
 *	the currently uploaded photo.
 *  @param formdocument
 *  
 */
function resetBeautySurgeonEdit(thisvalue) {
  // hide upload photo
  thisvalue.form.uploadFilePath.height = 0;
  // show photo stored in DB
	thisvalue.form.dbArztbild.height = 135;
  return true;
}

/**
 *  Load path of uploaded beautysurgeon photo into src
 *  of the uploadFilePath-field.
 *  Hide beautysurgeon photo from database and show
 *	the currently uploaded photo.
 *  @param formdocument
 *  
 */
function uploadBeautySurgeonPhoto(thisvalue) {
  thisvalue.form.uploadFilePath.src = thisvalue.form.uploadFile.value.toString();
  // show upload photo
  thisvalue.form.uploadFilePath.height = 135;
  // hide photo stored in DB
  thisvalue.form.dbArztbild.height = 0;
  return true;
}

/** Open dialog.
  * @param iFile   file to open
  * @param iId     dialog ID
  * @param iModal  flag to indicate if dialog should be modal or not
  * @param iHeight height
  * @param iWidth  width
  */
function openDialog(iFile, iId, iModal, iHeight, iWidth) {
  var vWidth = 550, vHeight = 320;
  if(iWidth)
    vWidth = iWidth;
  if(iHeight)
    vHeight = iHeight;  
  var vPosX = screen.width*.5-vWidth*.5, vPosY = screen.height*.5-vHeight*.5;
  var vAttributes = "width="+vWidth+",height="+vHeight+",left="+vPosX+",top="+
                    vPosY+",dependent=yes,resizable=yes,scrollbars=yes,"+
                    "location=no,menubar=no,status=no,toolbar=no";
  var vDlg = window.open(iFile, "SCHOENHEITSCHIRURGEN_DLG_"+iId, vAttributes);
  if(iModal)
    m_modalDlgs[m_modalDlgs.length] = vDlg;
  vDlg.focus();
}


function popupxx(ort,x,y) {
  win = window.open(ort, _top,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+x+',height='+y);
  win.focus();
}

function popupNoScrollxx(ort,x,y) {
  win = window.open(ort, 'Fenster','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+x+',height='+y);
  win.focus();
}

function presetState(id) {
	if(document.getElementById('formState')) {
		document.getElementById('formState').selectedIndex = id;
	}
}

function presetCity(name) {
	if(document.getElementById('formCity')) {
		document.getElementById('formCity').value = name;
	}
}

	function switchTab(tab) {
		if (tab < 1 || tab > 3) {
			tab = 1;
		}
		for (i=1; i<4; i++) {
			if (i == tab) {
				if (document.getElementById("detail_tab_" + i)) {
					document.getElementById("detail_tab_" + i).style.display = "block";
				}
				if (document.getElementById("tab_" + i)) {
					document.getElementById("tab_" + i).className = "active";
				}
			} else {
				if (document.getElementById("detail_tab_" + i)) {
					document.getElementById("detail_tab_" + i).style.display = "none";
				}
				if (document.getElementById("tab_" + i)) {
					document.getElementById("tab_" + i).className = "";
				}
			}
		}		
	}

function preswitchTab() {
	if(location.hash.substr(1) == 'praxistv') {
		switchTab(2);
	}
}

window.onload=function()  {
	preswitchTab();
}