 /***************************************************
   The following functions are called in main.tpl */
   
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: searchResults.tpl, main.tpl
	   * 
	   * @param bool
	   * @since 2006-10-28
	   * @author Tschela Baumann
	   */
    
    function displayContactData(hide)
    {
      if(hide==1)
      {
	      Element.show($('showContactData'));
	      Element.hide($('contactData'));
      }
      else
      {
	      Element.hide($('showContactData'));
	      Element.show($('contactData'));
      }
    }
    
 /***************************************************
   The following functions are called in adedit.tpl */
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: adedit.tpl
	   * 
	   * @param none
	   * @since 2006-10-28
	   * @author Tschela Baumann
	   */
    
		function displayRegFields()
		{
		  if($('regType').value=='onetime') Element.hide($('regInfos'));
		  else  Element.show($('regInfos'));
		}


	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: adedit.tpl
	   * 
	   * @param none
	   * @since 2006-10-28
	   * @author Tschela Baumann
	   */
    
    function displayMainTypeFields()
    {
      if($('mainType').value == 'cargo')
      {
       Element.show($('adSeats'));
       Element.show($('adDimensions'));
      }
      else
      {
       Element.show($('adSeats'));
       Element.hide($('adDimensions'));
      }
    }
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: adedit.tpl
	   * 
	   * @param none
	   * @since 2006-10-28
	   * @author Tschela Baumann
	   */
    
    function displayTrainticketTypeSelection()
    {
      if($('transType').value == 'street') Element.hide($('trainticketTypeSelection'));
      else Element.show($('trainticketTypeSelection'));
    }
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: searchResults.tpl, searchResults.php
	   * 
	   * @param none
	   * @since 2006-10-29
	   * @author Tschela Baumann
	   */
    
    function toggleOldAdsTable(action)
    {
      if(action=='showOldAds')
      {
        Element.show($('hideOldAds'));
        Element.hide($('showOldAds'));
        Element.show($('oldAds'));
      }
      else
      {
        Element.hide($('hideOldAds'));
        Element.show($('showOldAds'));
        Element.hide($('oldAds'));
      }
    }
    
	  /**
	   * This function toggles DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: faq.tpl
	   * 
	   * @param faq ID
	   * @since 2006-10-31
	   * @author Tschela Baumann
	   */
    
    function toggleFAQ(faq)
    {
      Element.toggle($(faq));
    }
    
	  /**
	   * This function toggles DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: faq.tpl
	   * 
	   * @param faq ID
	   * @since 2006-10-31
	   * @author Tschela Baumann
	   */
    
    function toggleFAQCategory(category)
    {
      Element.toggle($(category));
    }
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: faq.tpl
	   * 
	   * @param none
	   * @since 2006-10-31
	   * @author Tschela Baumann
	   */
    
    function hideAllFAQCategories()
    {
      allCats = document.getElementsByClassName('faqCategory');
      for(i = 0; i < allCats.length; i++) {
        Element.hide(allCats[i]);
      }
    }
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: faq.tpl
	   * 
	   * @param none
	   * @since 2006-10-31
	   * @author Tschela Baumann
	   */
    
    function hideAllFAQs()
    {
      allFAQs = document.getElementsByClassName('faq');
      for(i = 0; i < allFAQs.length; i++) {
        Element.hide(allFAQs[i]);
      }
    }
    

	  /**
	   * This function calls an URL
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: searchResults.tpl
	   * 
	   * @param advertID
	   * @since 2006-11-01
	   * @author Tschela Baumann
	   */
    
    function resultRowLink(advertID)
    {
      window.location.href='index.php?page=searchResults&advertID='+advertID;
    }
    
	  /**
	   * This function hides DOM-Elements
	   * =!!!==> prototype.js requiered
	   *
	   * Called in: myfriends.tpl
	   * 
	   * @param none
	   * @since 2006-11-02
	   * @author Tschela Baumann
	   */
    
    function hideAllEditRating()
    {
      allEdits = document.getElementsByClassName('editRating');
      for(i = 0; i < allEdits.length; i++) {
        Element.hide(allEdits[i]);
      }
    }
    
    /**
    * Mask current didYouKnow info on index site and get next information
    * from database using ajax request
    *
	  * =!!!==> prototype.js requiered
	  *
    * Called in main.tpl
    *
    */
    
	  function AXAH_nextDidYouKnow(tipp_id,userID,userPwd)
	  {
			var theHttpRequest = getNewHttpObject();
		
			theHttpRequest.onreadystatechange = function() 
	    {
					 Element.show($('didYouKnow_ajaxloader'));
					 Element.hide($('didYouKnowContainer'));
				   if (theHttpRequest.readyState == 4) 
				   {
					   if (theHttpRequest.status == 200) 
					   {
						   $('didYouKnowContainer').innerHTML = theHttpRequest.responseText;
					   } else {
						   $('didYouKnowContainer').innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message:&nbsp;" + theHttpRequest.statusText +"<\/p>";
					   }
		         Element.hide($('didYouKnow_ajaxloader'));
					   Element.show($('didYouKnowContainer'));
				   }
			};
		  	
			theHttpRequest.open('GET', 'httpRequest/didyouknow.xhtml.php?tipp_id=' + tipp_id + '&user_id=' + userID + '&user_pwd=' + userPwd, true);
			theHttpRequest.send(false);
    }
    
    
    
 
  function confirmation(message, gotolocation,elselocation)
  {
    var answer = confirm (message);
 		if (answer== true)
	 	{
	   window.location= gotolocation;
	 	}
  }
  
  function checkWidgetMode()
  {
    //alert('Parent frames: '+parent.frames.length+'-'+(parent!=self?'isFrame':'noFrame'));
    if(document.URL.indexOf("?")>0) param = '&';
    else param = '?';
    
    if(parent!=self && $('widget-mode').value==0)
    {
      window.location.href=document.URL+param+'widget-mode=studylife';
    }
    else if(parent==self && $('widget-mode').value==1)
    {
      window.location.href=document.URL+param+'widget-mode=0';
    }
    else if(document.URL.indexOf("&widget-mode=0")>0)
    {
      window.location.href=document.URL.replace(/\&widget-mode=0/g,"");
    }
    else if(document.URL.indexOf("?widget-mode=0")>0)
    {
      window.location.href=document.URL.replace(/\?widget-mode=0/g,"");
    }
  }

   
