//akgk, af 030911


//----------------------------------------------------------------------------------------------------infoWindow / Help
var infoWindow

function infoW(toOpen){
	var name = navigator.appName.toLowerCase();
	var version = navigator.appVersion.toLowerCase();
	//page = '/help/' + toOpen + '.htm';
	page = toOpen + '.php';
	//alert (page);
	//alert (name + ' / ' + version );

		// Win
	if (version.lastIndexOf('win') != -1){
		// win, ns
		if ( name == "netscape" ){
			infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=406,height=420");
		} else {
		// win, ie
			if (name.indexOf('microsoft') != -1) {
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=406,height=420");
			} else {
		// win, sonst
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=406,height=420");
			}
		}
	} else {
	// MAC
		if (version.lastIndexOf('mac') != -1) {
 	// mac, ns
			if ( name == "netscape" ){
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=405,height=420, screenX=100, screenY=100");
				infoWindow.focus();
			} else {
	// mac, ie
				if (name.indexOf('microsoft') != -1) {
					infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=389,height=420");
					infoWindow.focus();
				} else {
	//mac, sonst
					infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=405,height=420");
					infoWindow.focus();
				}
			}
		} else {
			infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=406,height=420");
    	}
	}
}


//---------------------------------------------------------------------------open cal window
function calW(){
	var name = navigator.appName.toLowerCase();
	var version = navigator.appVersion.toLowerCase();
	page = 'calendar.htm';

		// Win
	if (version.lastIndexOf('win') != -1){
		// win, ns
		if ( name == "netscape" ){
			infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=196");
		} else {
		// win, ie
			if (name.indexOf('microsoft') != -1) {
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=192");
			} else {
		// win, sonst
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=189");
			}
		}
	} else {
	// MAC
		if (version.lastIndexOf('mac') != -1) {
 	// mac, ns
			if ( name == "netscape" ){
				infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=189, screenX=100, screenY=100");
				infoWindow.focus();
			} else {
	// mac, ie
				if (name.indexOf('microsoft') != -1) {
					infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=189");
					infoWindow.focus();
				} else {
	//mac, sonst
					infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=189");
					infoWindow.focus();
				}
			}
		} else {
			infoWindow = window.open(page,"detailWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=246,height=189");
    	}
	}
}


//---------------------------------------------------------------------------change colors in result tab
function setPointer(theRow){
        if ( typeof(theRow.style) == 'undefined' ) {
            return false;
        }
        if ( typeof(document.getElementsByTagName) != 'undefined' ) {
            var theCells = theRow.getElementsByTagName('td');
        } else if ( typeof(theRow.cells) != 'undefined' ) {
            var theCells = theRow.cells;
        } else {
            return false;
        }

        var rowCellsCnt  = theCells.length;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = '#cccc99';
        }

        return true;
}

    function unsetPointer(theRow){
        if ( typeof(document.getElementsByTagName) != 'undefined' ) {
            var theCells = theRow.getElementsByTagName('td');
        } else if ( typeof(theRow.cells) != 'undefined' ) {
            var theCells = theRow.cells;
        } else {
            return false;
        }

     var rowCellsCnt  = theCells.length;
        for (var c = 0; c < rowCellsCnt; c++) {
		   if (theRow.className == "row1"){
                theCells[c].style.backgroundColor = '#BFD8FA';
            } else {
                theCells[c].style.backgroundColor = '#cccccc';
            }
        }
		/*if (theRow.className == "row1"){
		//alert('ich bin r1');
		//theRow.style.backgroundColor = '#FF9900';
		}else{
		//theRow.style.backgroundColor = '#cccccc';
		//alert('ich bin r2');
		}*/
        return true;
    }



//---------------------------------------------------------------------------Forms - write popUps
function bayReg(){
with(document){
write('<option selected>(Region)</option><option>-----------------------</option><option value="ofr">Oberfranken</option><option value="ufr">Unterfranken</option><option value="obay">Oberbayern</option><option value="ubay">Unterbayern</option>');
}
}

function days(){
with(document){
write('<option value="all" selected>Tag</option><option value="all">----</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option valugne="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">10</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option>');
}
}

function months(){
with(document){
write('<option value="all" selected>Monat</option><option value="all">----</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>');
}
}

function years(){
with(document){
write('<option value="all" selected>Jahr</option><option value="all">----</option><option value="2003">2003</option><option value="2004">2004</option><option value="2005">2005</option><option value="2006">2006</option><option value="2007">2007</option><option value="2008">2008</option><option value="2009">2009</option><option value="2010">2010</option>');
}
}

//---------------------------------------------------------------------------clear default in text field
function setField(myName, myVal){
  // if ( document.sosform.elements[myID].value == myVal ) { document.sosform.elements[myID].value='' }
     if ( document.getElementsByName(myName)[0].value == myVal ) { document.getElementsByName(myName)[0].value='' }

}


//PROVISORISCH - nur fuer demo, braucht echte ueberpruefung ob text vorhanden ist, ob mail-adr. log. richtig ist
function checkMail(){
	if (document.forms[0].elements[6].value == '')
	{
		location.href = 'mail_error02.htm';}
	else{
		location.href = 'mail_confirm.htm';}
}

//---------------------------------------------------------------------------spacer in "offer_display"
function spacer() {
  document.write('<tr align="left" valign="top"><td width="540" height="5"><img src="spc.gif" width="1" height="1"></td></tr>');
}


//--------------------------------------------------------------------------not in use !!!
function tabLine(){document.write('<tr align="left" valign="top" class="rowLine"><td width="1" height="1"><img src="spc.gif" width="1" height="1"></td><td width="179" height="1"><img src="spc.gif" width="1" height="1"></td><td width="135" height="1"><img src="spc.gif" width="1" height="1"></td><td width="135" height="1"><img src="spc.gif" width="1" height="1"></td><td width="270" height="1"><img src="spc.gif" width="1" height="1"></td><td width="90" height="1"><img src="spc.gif" width="1" height="1"></td></tr> ');}
function tabLine2(){document.write('<tr align="left" valign="top" class="rowLine"><td width="1" height="1"><img src="spc.gif" width="1" height="1"></td><td width="224" height="1"><img src="spc.gif" width="1" height="1"></td><td width="90" height="1"><img src="spc.gif" width="1" height="1"></td><td width="90" height="1"><img src="spc.gif" width="1" height="1"></td><td width="180" height="1"><img src="spc.gif" width="1" height="1"></td><td width="135" height="1"><img src="spc.gif" width="1" height="1"></td><td width="90" height="1"><img src="spc.gif" width="1" height="1"></td></tr>');}


// schliessen
function closeW(){
	//infoWindow.close();
	document.write( '<p>&nbsp;</p><a href=\'javascript:window.close()\' class="m2">Fenster schliessen</a>');
	}

// Hilfe schliessen, wenn hauptfenster aktiviert wird
function blurSwitch(){
  			 if (navigator.appVersion.lastIndexOf('Win') != -1){
					//wenn WIN
     			 	document.write('<body>' );
     			 	}
    			 else {
					// sonst MAC
    			 	document.write('<body onblur="window.close();">' );
      			}
}

function changeDetail() {

  var val = document.sosform.section.options[document.sosform.section.options.selectedIndex].value;

  document.sosform.detail.length = 2;
  document.sosform.detail.options.selectedIndex = 0;
	
	var tr_section_freitext = document.getElementById('tr_section_freitext');
	var tr_detail_1 				= document.getElementById('tr_detail_1');
	var tr_detail_2 				= document.getElementById('tr_detail_2');
	tr_section_freitext.style.display = 'none';
	tr_detail_1.style.display 				= '';
	tr_detail_2.style.display 				= '';
		
  switch( val  ) {

		case "1":
      newOption = new Option( "Lesung", "101" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Szenische Lesung", "102" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Kinderveranstaltung", "198" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "anderer Bereich Literatur", "199" );
      document.sosform.detail.options[5] = newOption;
		  break;
  	case "2":
		  newOption = new Option( "Einzelausstellung", "201" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Gruppenausstellung", "202" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Performance", "203" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "Vorführung", "204" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "Kinderveranstaltung", "298" );
      document.sosform.detail.options[6] = newOption;
      newOption = new Option( "anderer Bereich Bildende Kunst", "299" );
      document.sosform.detail.options[7] = newOption;
		  break;
		case "3":
		  newOption = new Option( "Orchester", "301" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Oper/Musical/Operette", "302" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Solo", "303" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "Band", "304" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "Kinderveranstaltung", "398" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "anderer Bereich Musik", "399" );
      document.sosform.detail.options[6] = newOption;
  		break;
		case "4":
		  var ouml = '&ouml;';

		  newOption = new Option( "Komödie/Trag" + ouml + "die", "401" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Stück/Volksstück", "402" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Kabarett", "403" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "Ballet/Tanztheater", "404" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "Strassentheater/Kleinkunst", "405" );
      document.sosform.detail.options[6] = newOption;
      newOption = new Option( "Kinder- und Jugendtheater", "498" );
      document.sosform.detail.options[7] = newOption;
      newOption = new Option( "anderer Bereich Theater", "499" );
      document.sosform.detail.options[8] = newOption;
  		break;
		case "5":
		  newOption = new Option( "Kulturgeschichte", "501" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Wissenschaft/Medizingeschichte", "502" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Soziokultur", "503" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "Archäologie/Geschichte", "504" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "Stadtplanung/Architektur", "505" );
      document.sosform.detail.options[6] = newOption;
      newOption = new Option( "Kinderveranstaltung", "598" );
      document.sosform.detail.options[7] = newOption;
      newOption = new Option( "anderer Bereich them. Ausst.", "599" );
      document.sosform.detail.options[8] = newOption;
	  	break;
		case "6":
		  newOption = new Option( "Vortrag Literatur/-wissenschaft", "601" );
      document.sosform.detail.options[2] = newOption;
      newOption = new Option( "Vortrag Bildende Kunst/Kulturwissenschaft", "602" );
      document.sosform.detail.options[3] = newOption;
      newOption = new Option( "Vortrag Musik/-wissenschaft", "603" );
      document.sosform.detail.options[4] = newOption;
      newOption = new Option( "Vortrag Theater/-wissenschaft", "604" );
      document.sosform.detail.options[5] = newOption;
      newOption = new Option( "Vortrag Architektur/Stadtgeschichte", "605" );
      document.sosform.detail.options[6] = newOption;
      newOption = new Option( "Vortrag Kulturmanagement/-politik", "606" );
      document.sosform.detail.options[7] = newOption;
      newOption = new Option( "Vortrag für Kinder", "698" );
      document.sosform.detail.options[8] = newOption;
      newOption = new Option( "anderer Bereich Vortrag", "699" );
      document.sosform.detail.options[9] = newOption;
		  break;
		case "7": //Infodienst/Newsletter
		  tr_detail_1.style.display = 'none';
			tr_detail_2.style.display = 'none';
    	break;
    
    case "8": //Sonstiges (Freitextangaben)
    	tr_section_freitext.style.display = '';
	
		  tr_detail_1.style.display 				= 'none';
			tr_detail_2.style.display 				= 'none';
			
			try{
				document.sosform.elements["section_freitext"].focus();	
			}
			catch(x){}
    	break;
    
    
		  default: alert("Geben Sie bitte den Bereich an!");
	}
}

function setCookie(name, value) {
  var today = new Date();
  var expires = new Date();
  if ( value == null ) {
    expires.setTime(today.getTime());
    document.cookie = name + "=" + "; expires=" + expires.toGMTString() + "; path=/";
  } else {
    expires.setTime(today.getTime() + 1000*60*60*24*365);
    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
  }
// document.cookie = name + "=" + escape(value) + ((expire == null) ? ";path=/" : ("; expires=" + expire.toGMTString())) + ';path=/'
// document.cookie = name + "=" + escape(value)
}

function getCookie(Name) {

  var value = "";
  var search = Name + "=";

  if (document.cookie.length > 0) {
  // if there are any cookies
    offset = document.cookie.indexOf(search);
    if (offset != -1) {
    // if cookie exists
    offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
        end = document.cookie.length;
      value = unescape( document.cookie.substring(offset, end) );
    }
  }
  return value;
}