var 
timerInterval=500; //[ms]


function OJ_getWindowHeight (){
	if (window.innerHeight) return window.innerHeight;
	else return document.documentElement.clientHeight;
}
function OJ_getWindowWidth (){
	if (window.innerWidth) return window.innerWidth;
	else return document.documentElement.clientWidth;
}
function OJ_init (){
	ww=OJ_getWindowWidth ();
	wh=OJ_getWindowHeight ();
	request(ww,wh);
	OJ_watch (ww, wh);
  
  
}
function OJ_watch (ww, wh){
	if ((OJ_getWindowWidth()!= ww)||(OJ_getWindowHeight()!= wh)) OJ_init ();
	else window.setTimeout('OJ_watch ('+ww+','+wh+')',timerInterval);
}



function request(ww,wh){
	var xmlHttp = null;
  var status;
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
	    xmlHttp = new XMLHttpRequest();
	}
	if (!xmlHttp) {
	    // Internet Explorer 6 und älter
	    try {
	        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch(e) {
	        try {
	            xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch(e) {
	            xmlHttp  = null;
	        }
	    }
	}
  
  
	if (xmlHttp) {
	    xmlHttp.open('GET', 'lib/request.php?mode=request'+'&ww='+ww+'&wh='+wh, true);
	    xmlHttp.onreadystatechange = function (ww,wh) {
	        if (xmlHttp.readyState == 4) {
           response(xmlHttp.responseText);
	        }
	    };
      xmlHttp.send(null);
	}  
}

function response(ret){
  
	var temparray=ret.split("&");
	result=new Array();
	
	for (i=0;i<temparray.length;i++){
		temp=temparray[i].split("=");
		//document.write(i,temparray[i],"<br/>");
		
		//  window.document.getElementById(temp[0]).style.width=temp[2];
		result[i]=temp[1];
		//alert(result[i]);
	
	}
	//document.getElementById("topBar").style.width="300px";
	document.getElementById("topBar").style.width=result[3]-result[5]+'px';
	document.getElementById("topBar").style.height=result[0]+'px';
	document.getElementById("headerNavi").style.marginTop=result[0]-70+'px';
	document.getElementById("content").style.width=result[3]-result[5]+'px';
	document.getElementById("leftCol").style.height=result[2]+'px';
	document.getElementById("centerCol").style.width=result[4]-result[5]+'px';
	document.getElementById("centerCol").style.height=result[2]+'px';

	document.getElementById("rightCol").style.height=result[2]+'px';
	document.getElementById("bottomBar").style.width=result[3]-result[5]+'px';
	document.getElementById("bottomBar").style.height=result[1]+'px';
	
	/**
	0 headerHeight  180
	1 footerHeight  200
	2 contentHeight 250
	3 totalWidth    910
	4 contentWidth  525
	5 offsetWidth   184
	*/
}

function decrypt(string){

	key="barmaley";
	array_alphabet=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","@","-",".",":","_","%");
	var result="";

	for(i=0;i<string.length;i++){
		var j=0;
		while(j<array_alphabet.length&&string.charAt(i)!=array_alphabet[j])j++;
			position_char=j;
			j=0;
			//alert(string.charAt(i));
		while(j<array_alphabet.length&&key.charAt(i%key.length)!=array_alphabet[j])j++;
			position_key=j;
			position=(position_char-position_key)%array_alphabet.length;
			if(position<0)position+=array_alphabet.length;

			//alert(key.charAt(i%key.length));
			result+=array_alphabet[position];
			//alert(array_alphabet[position]);

	}
	document.location.href=decodeURIComponent(result);
}


function CheckSubmitQ() {
   // alert("hallo");
	
	 error = false;
	 for(var i=1;i<=10;i++){	
		 var obj=document.getElementsByName("wi"+i);
		 if (!is_checked(obj)) {
			obj[2].focus();
			 error = true;
			 if(document.getElementsByName("lang")[0].value==2){
				 alert('Bitte geben Sie die Wichtigkeit aller Kriterien an.');
			 }else {
				 alert('Please indicate the importance of all criteria.');
			 }
			 return false;
		 }
	 }
	 
	 for(var i=1;i<=10;i++){	
		 var obj=document.getElementsByName("zu"+i);
		 if (!is_checked(obj)) {
			obj[2].focus();
			 error = true;
			 if(document.getElementsByName("lang")[0].value==2){
				 alert('Bitte sagen Sie uns wie zufrieden Sie sind!.');
			 }else{
				 alert('please tell, how satisfied you are!.');
			 }
			 return false;
		 }
	 }
	 for(var i=1;i<=2;i++){	
		 var obj=document.getElementsByName("so"+i);
		 if (!is_checked(obj)) {
			obj[1].focus();
			 error = true;
			 if(document.getElementsByName("lang")[0].value==2){
				 alert('Bitte geben Sie Ihre Enschätzung zu Empfehlung und Zusammenarbeit an.');
			 }else{
				 alert('please evaluate if cooperation is recommended.');
			 }
			 return false;
		 }
	 }
	 
	 var obj=document.getElementsByName("zuall");
	 if (!is_checked(obj)) {
		obj[2].focus();
		 error = true;
		 if(document.getElementsByName("lang")[0].value==2){
			 alert('Bitte geben Sie Ihr Gesamturteil ab.');
		 }else{
			 alert('please state your overall opinion.');
		 }
		 return false;
	 }
	 
	 error = false;
	 if ( document.getElementsByName("client")[0].value == '' ) {
		 document.getElementsByName("client")[0].focus();
		 error = true;
		 if(document.getElementsByName("lang")[0].value==2){
			 alert('Bitte geben Sie Ihren Firmennamen ein.');
		 }else{
			 alert('please specify your company´s name.');
		 }
		 return false;
	 }
	 
	if ( !error ) {
		document.qform.submit();
	}
}

function is_checked(radioButtons){
	for(var i=0;i<radioButtons.length;i++){ 
		if (radioButtons[i].checked == true) return true;
	}
	return false;
}


