// JavaScript Document

	dojo.require("dojo.io.script"); 	

	function getWetterbilder() {
		dojoGet('../businessLogic/ajax/getWetterbilder.php', 'Wetterbilder');
    }
	
	function getChat() {
		dojoGet('../businessLogic/ajax/getChatLogin.php', 'Chat');
    }
	
	function getNews() {
		dojoGet('../businessLogic/ajax/getNews.php', 'News');
    }
	
	function getLinks() {
		dojoGet('../businessLogic/ajax/getLinks.php', 'Links');
    }
	
	function getDownloads() {
		dojoGet('../businessLogic/ajax/getDownloads.php', 'Downloads');
    }
	
	
	function dojoGet(url, label){
	            dojo.xhrGet ({
                // Location of the HTML content we want to grab
                url: url,
				useCache: false, 
       			preventCache: true ,
        
                // Called when the page loaded successfully
                load: function (data) { 
					if(dojo.byId('multimedia_main') != null){
						dojo.byId('multimedia_main').innerHTML = data;
						dojo.byId('aktuelle_auswahl').innerHTML = label;
					}
				},
        
                // Called if there was an error (such as a 404 response)
                error: function (data) { }
            });
		}
		
		
	
	function chatLogin(user) {
		if(user){
			dojo.xhrGet ({
                // Location of the HTML content we want to grab
                url: '../businessLogic/ajax/getChat.php',
				useCache: false, 
       			preventCache: true ,
        
                // Called when the page loaded successfully
                load: function (data) { 
					if(dojo.byId('multimedia_main') != null){
						dojo.byId('multimedia_main').innerHTML = data;
						chat.document.location="../opensource/flashchat/flashchat.php?username=" + user;
					}
				},
        
                // Called if there was an error (such as a 404 response)
                error: function (data) { }
            });
		} else {
			alert("Bitte geben Sie einen Usernamen ein!");	
			document.login.username.focus();
		}
	}
	
	function chatPopupLogin(user) {
		if(user){
			window.open('../opensource/flashchat/flashchat.php?username=' + user + '');	
		} else {
			alert("Bitte geben Sie einen Usernamen ein!");	
			document.login.username.focus();
		}
	}
	
	function changeHeight(iframe)
      {
        try
        {
          var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
          if (innerDoc.body.offsetHeight) //ns6 syntax
          {
             iframe.height = innerDoc.body.offsetHeight + 15; //Extra height FireFox
          }
          else if (iframe.Document && iframe.Document.body.scrollHeight) //ie5+ syntax
          {
             iframe.height = iframe.Document.body.scrollHeight;
          }
        }
        catch(err)
        {
         
        }
      }
	  
	  	function showImageUpload(){
			dojo.xhrGet ({
                // Location of the HTML content we want to grab
                url: '../businessLogic/ajax/getImageUpload.php',
				useCache: false, 
       			preventCache: true ,
        
                // Called when the page loaded successfully
                load: function (data) { 
					$.modal(data);
				},
        
                // Called if there was an error (such as a 404 response)
                error: function (data) { }
            });
		}
		
		var getUserOnlineReady = true;
		function getUserOnline() {
			if(getUserOnlineReady == true){
				getUserOnlineReady = false;
				dojo.xhrGet ({
					// Location of the HTML content we want to grab
					url: '../businessLogic/ajax/getUserOnline.php',
					useCache: false, 
					preventCache: true ,
			
					// Called when the page loaded successfully
					load: function (data) { 
						//nothing to do
					},
			
					// Called if there was an error (such as a 404 response)
					error: function (data) { }
				});
			}
			setTimeout("getUserOnline()", 30000);
        }
		getUserOnline();
		
		function showDownloads(id){
			dojo.xhrGet ({
                // Location of the HTML content we want to grab
                url: '../businessLogic/ajax/getDownloadsCat.php?id=' + id,
				useCache: false, 
       			preventCache: true ,
        
                // Called when the page loaded successfully
                load: function (data) { 
					$.modal(data);
				},
        
                // Called if there was an error (such as a 404 response)
                error: function (data) { }
            });
		}
