/* ############# Fensteranpassung (linksbündig bei kleiner Auflösung 800x600) ############# 
function OffsetWidth()
 {
  	if(document.body.offsetWidth < 840){
		  document.getElementById("container").style.margin = "0px auto 0px 5px";
	}
  	else document.getElementById("container").style.margin = "0px auto 0px auto";
}
*/

$(document).ready(function(){
          
		 $("a.scrolltop").click(function() {
                     $(this).removeAttr('href');
                     $.scrollTo( 0, 4000);				 
		     //$.scrollTo( 0, 500, { easing:'elasout' });
		 });

         				 
});

/* ############# Veränderung des Layouts durch den User ##############

function changefontSize(){
	//alert(document.body.style.fontSize);
	if (document.body.style.fontSize  == '18px') document.body.style.fontSize='14.4px';   
    else document.body.style.fontSize = '18px';	
	sndReq(document.body.style.fontSize);
	
}*/

function changebgColor(input) {
	//alert(input);
	
	document.getElementById('header').style.backgroundImage = 'url(/wp-content/themes/technical/images/layout/bg_'+input+'.png)';
	document.getElementById('container_inside').style.backgroundImage = 'url(/wp-content/themes/technical/images/layout/bg_'+input+'.png)';
	
        if(input == "schwarz" || input == "blau" || input == "gruen"){
             document.getElementById('content').style.color = '#aaa';          
        }
        else {
             document.getElementById('content').style.color = '#222';            
        }
 
	sndReq(input);
}

function changetextbgColor(input) {
	//alert(input);
	
	document.getElementById('textoutput').style.backgroundColor= input;

        if(input == "#000000"){
             document.getElementById('content').style.color = '#aaa';           
        }
        else if(input == "#ffffff") {
             document.getElementById('content').style.color = '#222';            
        }
        else {
             document.getElementById('content').style.color = '#888'; 
        }        
	
	sndReq(input);
}

//################ Ajax ################################
var resObjekt = null; //Object-Variable deklarieren
function sndReq(input){
		//alert(input);
		/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
		window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
		@end @*/
		
		resObjekt = new XMLHttpRequest();		
		var text = 'input=' + encodeURIComponent(input);
		resObjekt.open('post','/wp-content/themes/technical/bgcolor.php',true);
		resObjekt.setRequestHeader("Content-type", "application/x-www-form-urlencoded, charset=UTF-8") ;
    	resObjekt.setRequestHeader("Content-length", text.length);
		resObjekt.onreadystatechange=handleResponse;
		resObjekt.send(text);
}

/*
function nachladen(){
	if(resObjekt.readyState != 4){
		document.getElementById("spinner").style.display = "block";
		window.setTimeout("nachladen()", 1000); //rekusiver Selbstaufruf
	}
	document.getElementById("spinner").style.display = "none";
	handleResponse(); 
}
*/

function handleResponse(){	
	if(resObjekt.readyState == 4 ){
		//document.getElementById("colorbutton").innerHTML = resObjekt.responseText; 
	}

}

	
//################# Ajax ENDE ############################################



