// Add to bookmark
function addBookmark(title,url) {
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) {
        window.external.AddFavorite( url, title); 
    } else if( window.opera && window.print ) {
        return true;
    }
}

function Confirm()
{
	confirm ("Are you sure ???");
} 

// Check if schnell contact options have been selected
function check_selected_options_schnell_contact() {
	
	var str = "";

	if ( document.getElementById("form_anrede").value == 0 ) {
		str = str+"- Anrede fehlt \n";
	}
	if ( !document.getElementById("form_name").value ) {
		str = str+"- Name fehlt \n";
	}
	if ( !document.getElementById("form_email").value ) {
		str = str+"- Email fehlt \n";
	}
	if ( !document.getElementById("form_tel").value ) {
		str = str+"- Telefon fehlt \n";
	}
	
	if( str != "" ) {
		alert(str);
		return false;
	}
	return true;
}

/*
	function disableselect(e){
		return false
	}
	function reEnable(){
		return true
	}
	//if IE4+
	document.onselectstart=new Function ("return false")
	//if NS6
	if (window.sidebar){
		document.onmousedown=disableselect
		document.onclick=reEnable
	}
*/

/* COUNTER START */
function CountMax() 
{ 
	var wert,max; 
	max = 255; 
	wert = max-document.contactForm.description.value.length; 
	if (wert < 0) { 
		alert("Es dürfen nicht mehr als " + max + " Zeichen eingegeben werden!"); 
		document.contactForm.description.value = document.contactForm.description.value.substring(0,max); 
		wert = max-document.contactForm.description.value.length; 
		document.contactForm.rv_counter.value = wert; 

	} else { 
		document.contactForm.rv_counter.value = max - document.contactForm.description.value.length; 
	} 
} 
/* COUNTER END */


/* SHOW/HODE START */
var BUTTONTEXT = [ '[-]' , '[+]' ];

function initPage() {
	oMyDiv = document.getElementById( "myDiv" );
	oMyButton = document.getElementById( "myButton" );
	
	myCookies = getCookies();
	
	if ( myCookies[ "HIDEDIV" ] == 0 ) {
		oMyDiv.style.display = "block";
		oMyButton.firstChild.nodeValue = BUTTONTEXT[ 0 ];
	}
};

function doIt() {
	var isHidden = ( oMyDiv.style.display != "none" ) ? 1 : 0;
	oMyDiv.style.display = ( isHidden ) ? "none" : "block";
	oMyButton.firstChild.nodeValue = BUTTONTEXT[ isHidden ];

	setCookie( "HIDEDIV" , isHidden );
}
/* SHOW/HIDE END */


var oldobj = "";

function fett(obj)
{
    if (oldobj != "")
    {
        /* oldobj.style.color="0033FF"; */
        /* oldobj.style.fontWeight="normal";  */
    }
    /* obj.style.color="555555"; */
    obj.style.fontWeight="bold";
    oldobj = obj;
}
   
/*  Leasing */

function clear_result(form)
{
	form.rate.value="";
}

function input(wert)
{
	wert=wert.replace(/,/,".");wert=parseFloat(wert);if (isNaN(wert)) wert=0;
	return wert
}

function calculate(form)
{
	// zinssatz=eval(form.zinssatz.value);
	zinssatz=input(form.zinssatz.value);
	form.zinssatz.value=zinssatz;
	
	// r=eval(form.restwert.value);
	r=input(form.restwert.value);
	form.restwert.value=r;
	
	p=zinssatz/100;
	q=1+p/12;
	
	k=input(form.kosten.value);
	form.kosten.value=k;
	
	//n=parseFloat(form.zeitraum.value);
	
	n=input(form.zeitraum.value);
	form.zeitraum.value=n;
	
	
	// Annuitätenfaktor für vorschüssige Kalkulation
	av=(Math.pow(q,n)*(q-1))/(q*(Math.pow(q,n)-1));
	
	// Restwert abgezinst
	bw=r/Math.pow(q,n);
	
	// Rate calculate
	rate=av*(k-bw);
	form.rate.value=Math.round (rate*100)/100;
} 

/*  TABS START */
function tabButtonClicked(t, b) {
  var lis=document.body.getElementsByTagName('li');
  for (var i=0; i<lis.length; i++) {
    if (lis[i].id==t+'_'+b+'_button') {
	lis[i].className='ac';
    } else if (lis[i].id.match('^'+t+'_.*_button$')) {
	lis[i].className='ia';        
    }
  }
  var divs=document.body.getElementsByTagName('div');
  for (var i=0; i<divs.length; i++) {
    if (divs[i].id==t+'_'+b+'_content') {
	divs[i].style.display='block';
    } else if (divs[i].id.match('^'+t+'_.*_content$')) {
	divs[i].style.display='none';
    }
  }
}
/*  TABS END */

function LoadGallery(pictureName,imageFile,titleCaption,captionText, origin) {
	if (document.all) {
		document.getElementById(pictureName).style.filter="blendTrans(duration=0.3)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	document.getElementById(pictureName).src = '/images/'+origin+'/1-1000/'+imageFile;
	if (document.all) {
			document.getElementById(pictureName).filters.blendTrans.Play();
	}
	// document.getElementById(titleCaption).innerHTML=captionText;
}

/*  SHOW HIDE TEXT */
function elemOn(elem_id){
	if(document.getElementById(elem_id))
		document.getElementById(elem_id).style.display = "block";
}
function elemOff(elem_id){
	if(document.getElementById(elem_id))
		document.getElementById(elem_id).style.display = "none";
}
function hideAll(){
	for( var i = 1; i <= 4; i++ )
		elemOff( 'div'+i );
}
function showAll(){
	for( var i = 1; i <= 4; i++ )
		elemOn( 'div'+i );
}
function showOne(elem_id){
	hideAll( );
	elemOn( elem_id );
}
/*  END SHOW HIDE TEXT */
