
//////////////////////Suche####################

function sendform(formname,funcname,order){
	Element.update('updateDiv','<div id="ajaxloader"><img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" /></div>');
	$('updateDiv').style.display='block';
	var params = Form.serialize($(formname));
	new Ajax.Updater('updateDiv', foreignUrl+'suchfunctions.cfm?funcname='+funcname+'&order='+order, {asynchronous:true, parameters:params, evalScripts:true});
	
}


function doemptysearch(superbid){
	Element.update('suchtext1','');
	Element.update('suchausgabe','<div id="ajaxloader"><img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" /></div>');
	$('suchausgabe').style.display='block';
	new Ajax.Updater('suchausgabe', foreignUrl+'sucheaction_new.cfm?newsearch=1', {asynchronous:true, evalScripts:false});
	updateTheSearchform('','','','','',superbid);
	Element.update('suchtext1','');
}


////////////Suche bei der grossen Firmensuche
function doTheSearch(sort,order,startrow,superbid){
	Element.update('suchausgabe','<div id="ajaxloader"><img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" /></div>');
	$('suchausgabe').style.display='block';
	var params = Form.serialize($('detailsuche'));
	new Ajax.Updater('suchausgabe', foreignUrl+'sucheaction_new.cfm?sort='+sort+'&dir='+order+'&startrow='+startrow+'&superbid='+superbid, {asynchronous:true, parameters:params, evalScripts:true});
	}
var merkLetztesDetail = 0;
var aktuellesDetail = 0;

function sucheDetail(fid,e,s){
	aktuellesDetail = s;
	var cfg = document.getElementById(merkLetztesDetail);
	if(merkLetztesDetail !=0 && cfg != null){
		$(merkLetztesDetail).style.display='none';
		Element.update(merkLetztesDetail,'');
		
		}
	merkLetztesDetail = s;
	
	var myxy = getXY(e);
	$(s).style.display='block';
	Element.update(s,'<div id="ajaxloader"><img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" /></div>');
	var url = foreignUrl+'sucheDetail.cfm?fid='+fid;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText;
					Element.update(s,response);
				},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	
	}




//Bewertung
function sendrating(){
	var params = Form.serialize($('rateform'));
	new Ajax.Updater('updateDivrate', foreignUrl+'insert_voting.cfm', {asynchronous:true, parameters:params, evalScripts:true});
}
//Detailkontakt
function sendkontakt(){
	var params = Form.serialize($('detailkontaktform'));
	new Ajax.Updater('detailkontaktformwait', foreignUrl+'kontaktdetail.cfm', {asynchronous:true, parameters:params, evalScripts:true});
}


/// bei der grossen Suche wird der untere Bereich der Suchmaske aktualisert
function updateTheSearchform(fidliste,kidlist,bidlist,sekidlist,awbidlist,superbid){
	Element.update('suchefeature','<div id="ajaxloader"><img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" /></div>');
	$('suchefeature').style.display='block';
	var url = foreignUrl+'suchefeature.cfm?fidliste='+fidliste+'&kidlist='+kidlist+'&bidlist='+bidlist+'&sekidlist='+sekidlist+'&awbidlist='+awbidlist+'&superbid='+superbid;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('suchefeature',response);
						
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
	/// anderen TAb in der Suche Detailansicht zeigen
function showTabViste(box){
	$('box1').style.display='none';
	$('tabbox1').className = "TabbedPanelsTab";

	$('box2').style.display='none';
	$('tabbox2').className = "TabbedPanelsTab";
	$('box3').style.display='none';
	$('tabbox3').className = "TabbedPanelsTab";
	$('box4').style.display='none';
	$('tabbox4').className = "TabbedPanelsTab";
	
	$(box).style.display='block';
	$('tab'+box).className = "TabbedPanelsTab TabbedPanelsTabSelected";
}

//// drucken nur eines Containers
function printDiv(strid){
	var divContent = document.getElementById(strid);
	var WinPrint =
	window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(divContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
	//divContent.innerHTML=strOldOne;
}

function addCloseButton(){
		/*var x = document.createElement('a');
		x.addClassName('MainClose');

      	if( x.attachEvent ){
   			x.attachEvent('onclick', 'closeMain(); return false;');
        } else {
   	      x.setAttribute('onclick', 'closeMain(); return false;');
         }
		
		 
		  x.setAttribute('onclick', 'closeMain(); return false;');
		  x.onclick = function() {closeMain(); return false;};
		 x.href='';
		 var y = document.createElement('img');
		 y.src ='../images/action_stop.gif';
		 x.appendChild(y);
		 $('maindiv').appendChild(x);
*/	
$('MainClose').style.display='block';
	
	}
function closeMain(){
	$('maindiv').style.display='none';
	$('MainClose').style.display='none';
	}	
//////////////////////MAIN####################
function ShowItemID(funcname,id){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
	$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname+'&id='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
//////////////////////MAIN####################
function ShowItemID_ID(funcname,id1,id2){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname+'&id1='+id1+'&id2='+id2;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
//////////////////////MAIN####################
function sendformDIV(formname,funcname,div){
	Element.update(div,'<div id="ajaxloader"><img src="images/ajax-loader.gif" /></div>');
	$(div).style.display='block';
	var params = Form.serialize($(formname));
	new Ajax.Updater(div, 'mainfunctions.cfm?funcname='+funcname, {asynchronous:true, parameters:params, evalScripts:false});
	

}
//////////////////////ADMIN////////////


function ShowAdminNextlevel(div,funcname,parent,bid,level){
	
	if($(div).style.display == 'none'){
		Element.update(div,'<img src="../images/ajax-loader.gif" />');
		$(div).style.display='block';
		var url = 'adminfunctions.cfm?funcnum='+funcname+'&parent='+parent+'&bid='+bid+'&level='+level;
		var myAjax = new Ajax.Request(
			url, 
				{method: 'POST', 
					onSuccess: function(response){
						var response = response.responseText
							Element.update(div,response);
						},
					onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
				});
	}
	else{
		$(div).style.display='none';
		}
}


function ShowMainNextlevel(div,funcname,parent,bid,level,fid){
	
	if($(div).style.display == 'none'){
		Element.update(div,'<img src="../images/ajax-loader.gif" />');
		$(div).style.display='block';
		var url = 'mainfunctions.cfm?funcnum='+funcname+'&parent='+parent+'&bid='+bid+'&level='+level+'&fid='+fid;
		var myAjax = new Ajax.Request(
			url, 
				{method: 'POST', 
					onSuccess: function(response){
						var response = response.responseText
							Element.update(div,response);
						},
					onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
				});
	}
	else{
		$(div).style.display='none';
		}
}

//MAIN wenn Kompetenzen abgewählt werde, muss das in den hidden fields obendrüber auch weggenommen werden
function KompetenzHiddenUpdate(id){
	
	if ($('in'+id).checked ==false){
		 $('outkomp'+id).removeChild($('hid_'+id));
		}
	}
	
	//////////////////////ADMIN////////////
function ShowAdminItemID(funcname,id){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'adminfunctions.cfm?funcnum='+funcname+'&id='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}


//////////////////////MAIN####################
function ShowItem(funcname){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
//////////////////////ADMIN////////////

function setOnline(fid,onlinestate){
	Element.update('setOnline'+fid,'<img src="../images/ajax-loader.gif" />');
	$('setOnline'+fid).style.display='block';
	var url = 'adminfunctions.cfm?funcnum=changeonlinestate&id1='+fid+'&id2='+onlinestate;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						if(response ==1){
							var re ="<a href=\"\" onclick=\"setOnline('"+fid+"','0'); return false;\"><img src=\"../images/flag_green.gif\" /></a>";	
							}
						else{
							var re ="<a href=\"\" onclick=\"setOnline('"+fid+"','1'); return false;\"><img src=\"../images/flag_red.gif\" /></a>";	
							}
						Element.update('setOnline'+fid,re);
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
function ShowAdminItem(funcname){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'adminfunctions.cfm?funcnum='+funcname;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
//////////////////////ADMINstart////////////
function ShowAdminItemDiv(funcname,div){
	Element.update(div,'<img src="../images/ajax-loader.gif" />');
	
	var url = 'adminfunctions.cfm?funcnum='+funcname;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(div,response);
						new Effect.toggle(div);
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
//////////////////////ADMIN start////////////
function ShowAdminItemDivID(funcname,div,id){
	Element.update(div,'<img src="../images/ajax-loader.gif" />');
	
	var url = 'adminfunctions.cfm?funcnum='+funcname+'&id='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(div,response);
						new Effect.toggle(div);
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	//////////////////////ADMIN start////////////
function ShowAdminItemDivID_ID(funcname,div,id,id2){
	Element.update(div,'<img src="../images/ajax-loader.gif" />');
	
	var url = 'adminfunctions.cfm?funcnum='+funcname+'&id1='+id+'&id2='+id2;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(div,response);
						new Effect.toggle(div);
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
//////////////////////ADMINPERSON a-z////////////
function ShowADMINPERSONa_z(nachname,startrow){
	Element.update('personendiv','<img src="../images/ajax-loader.gif" />');
	$('personendiv').style.display='block';
	if(nachname.length!=0){
		var url = 'adminfunctions.cfm?funcnum=personoverview&nachname='+nachname+'&startrow='+startrow;
	}
	else{
		var url = 'adminfunctions.cfm?funcnum=personoverview&startrow='+startrow;
		}
		
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('personendiv',response);
					},
				
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});

	}
	
//////////////////////ShowADMINFirmaa_z////////////
function ShowADMINFirmaa_z(firma,startrow,branche,sorty,dir){
	Element.update('Firmendiv','<img src="../images/ajax-loader.gif" />');
	$('Firmendiv').style.display='block';
	if(firma.length!=0){
		var url = 'adminfunctions.cfm?funcnum=firmashow&firma='+firma+'&startrow='+startrow+'&branche='+branche+'&sort='+sorty+'&dir='+dir;
	}
	else{
		var url = 'adminfunctions.cfm?funcnum=firmashow&startrow='+startrow+'&branche='+branche+'&sort='+sorty+'&dir='+dir;
		}
		
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('Firmendiv',response);
					},
				
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});

	}
//////////////////////ShowADMINFirmaSort////////////
function ShowADMINFirmaSort(sorty,dir,branche){
	Element.update('Firmendiv','<img src="../images/ajax-loader.gif" />');
	$('Firmendiv').style.display='block';
		var url = 'adminfunctions.cfm?funcnum=firmashow&sort='+sorty+'&dir='+dir+'&branche='+branche;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('Firmendiv',response);
					},
				
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});

	}
	
function ShowADMINFirmaBranche(el){
	Element.update('Firmendiv','<img src="../images/ajax-loader.gif" />');
$('Firmendiv').style.display='block';
		//var b = el.options[el.selectedIndex].value;
		
		var url = 'adminfunctions.cfm?funcnum=firmashow&branche='+el+'&startrow=1';
	
		
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('Firmendiv',response);
					},
				
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});

	}
	
 function selectWert(sObj) {
		with (sObj) return options[selectedIndex].value;
	  }
//////////////////////	
function ShowItemCalender(funcname,date,calendarButton){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						calstart(date,calendarButton);
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
function ShowItemCalender2(funcname,date,calendarButton,date2,calendarButton2){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						calstart(date,calendarButton);
						calstart(date2,calendarButton2);
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
	
function ShowItemCalender2ID(funcname,date,calendarButton,id){
	Element.update('maindiv','<img src="../images/ajax-loader.gif" />');
		$('maindiv').style.display='block';
	var url = 'mainfunctions.cfm?funcnum='+funcname+'&proid='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('maindiv',response);
						new Effect.Appear('maindiv');
						calstart(date,calendarButton);
						addCloseButton();
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
	
	
//////////////////////SucheDetail####################
function SucheDetailID(funcname,id){
	Element.update('featurediv','<img src="http://www.kompetenzatlas-hessen.de/images/ajax-loader.gif" />');
	$('featurediv').style.display='block';
	var url = foreignUrl+'suchefunctions.cfm?funcnum='+funcname+'&id='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update('featurediv',response);
						new Effect.Appear('featurediv');
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
////////////////////////////////////////////////////////////////77777

//////////////////////dbtabs/Produkte.cfm
function ShowItemIDProdukte(divname,bid,proid){
	Element.update(divname,'<img src="../images/ajax-loader.gif" />');
	$(divname).style.display='block';
	var url = 'mainfunctions.cfm?funcnum=produkteigenschaften&bid='+bid+'&proid='+proid;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(divname,response);
						new Effect.Appear('Eigenschaftenfieldset');
						
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}
	
function ShowItemIDProdukteAW(divname,bid,proid){
	Element.update(divname,'<img src="../images/ajax-loader.gif" />');
	$(divname).style.display='block';
	var url = 'mainfunctions.cfm?funcnum=Anwenderbranche&bid='+bid+'&proid='+proid;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(divname,response);
						new Effect.Appear('Anwendungsbranchenfieldset');
						
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}

	
function populateSecondSelect(firstselect,secondselect,funcname){
	Element.update(secondselect,'<img src="../images/ajax-loader.gif" />');	
	$(secondselect).style.display='block';
	var url = 'adminfunctions.cfm?funcnum='+funcname+'&id='+firstselect;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						Element.update(secondselect,response);
						
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}


function datepick(element){
		var datepicker	= new DatePicker({
		relative	: element,
		language	: 'de'
		});
		
}
function verifychange(text,box) {
		ask_user = confirm('Sind Sie sicher, dass Sie '+text+' aendern wollen?');
if (ask_user == true){
		box.checked = true;
		return true;
		}
		
else
		return false;
}
function verifydelete(text) {
		ask_user = confirm('Sind Sie sicher, dass Sie '+text+' loeschen wollen?');
if (ask_user == true)
		return true;
else
		return false;
}
function verifyupload(text) {
			ask_user = confirm('Sind Sie sicher dass Sie '+ text+' loeschen wollen?');
	if (ask_user == true)
			return true;
	else
			return false
}


	////////////////////////////////////////////////////////////////77777
function calstart(date,calendarButton){
	Calendar.setup({
          dateField      : date,
          triggerElement : calendarButton
		  
        })	
}

function deleteproduktbild(id){
	var url = 'mainfunctions.cfm?funcnum=deleteproduktbild&id='+id;
	var myAjax = new Ajax.Request(
		url, 
			{method: 'POST', 
				onSuccess: function(response){
					var response = response.responseText
						new Effect.Fade('produktbilddelete');
					},
				onFailure: function(){alert('Ein Fehler ist aufgetreten...'+response)}
			});
	}


//Checkt ob wenigstens eine checkbox ausgewählt wurde.
function isOneCheckboxActive(FormName, FieldName){
	if(!document.forms[FormName]){
		return false;
	}
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes){
		return false;
	}
	//Check ob es nur einer ist
	
	if(!isNaN(objCheckBoxes.value) || objCheckBoxes.value.length > 1){
		if(objCheckBoxes.checked ==false){
			alert("Waehlen Sie bitte mindestens eine Branche aus!");
			return false;
		}
	}
	//oder mehrere, die sich dann als Nodelist verhalten
	else {
		
		var countCheckBoxes = objCheckBoxes.length;
		
		var merker = 0;
		for(var i = 0; i < countCheckBoxes; i++){
			if(objCheckBoxes[i].checked == true){
				merker = merker +1;
			}
		}
		if(merker == 0){
			alert("Waehlen Sie bitte mindestens eine Branche aus!");
			return false;
		}
	}
	return 1;
}  

function googlemaps(){           
		var geocoder = new GClientGeocoder();
		var map;
		
		function init() {
			document.getElementById('Ort').onkeyup = function(e) {
				geocode();
			}
			document.getElementById('Strasse').onkeyup = function(e) {
				geocode();
			}
			load();		
			geocode();						
		}

		function load() {
		  if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
		//map.addControl(new GSmallMapControl());
		//map.addControl(new GMapTypeControl())	
			//map.setCenter(new GLatLng(50.086446,8.238373), 13);
		  }
		}
		
		
		function geocode() {
			var location = document.getElementById('Ort').value;
			var street = document.getElementById('Strasse').value;
			var latNode = document.getElementById('lat');
			var lngNode = document.getElementById('lon');
			
			
			var address = street + ',' + location ;
			
			  geocoder.getLatLng(
				address,
				function(point) {
				  if (!point) {
					document.getElementById('map').style.display = 'none';
					document.getElementById('maperkl').style.display = 'block';
					//alert(address + " nicht gefunden");
					} else {
					document.getElementById('map').style.display = 'block';
					document.getElementById('maperkl').style.display = 'none';
				  latNode.value = point.x;
				  lngNode.value = point.y;
					map.setCenter(point, 13);
					var marker = new GMarker(point);
					map.clearOverlays();
					map.addOverlay(marker);
					//marker.openInfoWindowHtml(address);
				  }
				}
			  );
	
		
		
		}
	document.onunload = GUnload();
	setTimeout(function() {init();}, 2000);
}

function randomnumber(){
	var ran_unrounded=Math.random(2)*50000;
	var ran_number=Math.floor(ran_unrounded);
	return ran_number;
}


function showpop(text,e,div2Add){
	myid = div2Add+'1222';
	var ret='<table  style="VISIBILITY: visible; width: 200px;" cellspacing="0" cellpadding="0" width="200" border="0" zindex="1000"><tbody><tr style="height: 100%" valign="top"><td style="vertical-align: top; height: 100%; border:none; padding:0" align="right" width="20"><table style="height: 100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="border:none; padding:0; font-size: 1px; padding-top: 8px;" valign="top" align="right"><div style="border-top: black 1px solid; font-size: 1px; left: 1px; width: 15px; POSITION: relative"><div style="overflow: hidden; border-left: black 1px solid; width: 14px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 13px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 12px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 11px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 10px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 9px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 8px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 7px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 6px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 5px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 4px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 3px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 2px; height: 1px; background-color: lemonchiffon"></div><div style="overflow: hidden; border-left: black 1px solid; width: 1px; height: 1px; background-color: lemonchiffon"></div></div></td></tr></tbody></table></td><td style="border:none; padding:0;padding-RIGHT: 5px; border-top: black 1px solid; padding-left: 5px; padding-bottom: 5px; border-left: black 1px solid; padding-top: 5px; border-bottom: black 1px solid; background-color: lemonchiffon" width="20"><img src="http://www.kompetenzatlas-hessen.de/images/popup/achtung.gif" alt="Achtung" border="0" /></td><td style="border:none; padding:0;padding-RIGHT: 5px; border-top: black 1px solid; padding-left: 5px; font-size: 10px; padding-bottom: 5px; padding-top: 5px; border-bottom: black 1px solid; font-family: verdana; background-color: lemonchiffon" width="100%"><span style="text-decoration:none">'+ text +'</span></td><td style="border:none; padding:0;border-RIGHT: black 1px solid; padding-RIGHT: 2px; border-top: black 1px solid; padding-left: 2px; padding-bottom: 2px; vertical-align: top; padding-top: 2px; border-bottom: black 1px solid; background-color: lemonchiffon; text-align: right"><img style="cursor: pointer" src="http://www.kompetenzatlas-hessen.de/images/popup/close1.gif" border="none" alt="close" /></td></tr></tbody></table>';
	
	
	/* // position where mousemove fired
    var xPos    =  e? e.pageX : window.event.x;
	var yPos    =  e? e.pageY : window.event.y;
	// for ie add scroll position
	if (document.all && !document.captureEvents) {
	    xPos    += document[docEl].scrollLeft;
	    yPos    += document[docEl].scrollTop;
    }*/
	var myxy = getXY(e);
	var newdiv = document.createElement('div');
	
	newdiv.setAttribute('id',myid);
	newdiv.innerHTML =ret;
	newdiv.style.left=(myxy[0]+10)+"px";
	newdiv.style.top=(myxy[1])+"px";
	//alert(newdiv.style.left+' '+newdiv.style.top)
	newdiv.style.visibility='visible';
	newdiv.style.position='absolute';
	 if (document.layers) routeEvent(e);

	document.getElementById(div2Add).appendChild(newdiv);
	}
	
function showNeutralPop(text,e,div2Add){
	myid = div2Add+'1222';
	var ret='<table  class="showNeutralPop"  style="VISIBILITY: visible; width: 200px;" cellspacing="0" cellpadding="0" width="200" border="0" zindex="1000"><tbody><tr style="height: 100%" valign="top"><td style="vertical-align: top; height: 100%; border:none; padding:0" align="right" width="20"><table style="height: 100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="border:none; padding:0; font-size: 1px; padding-top: 8px;" valign="top" align="right"><div style="border-top: black 1px solid; font-size: 1px; left: 1px; width: 15px; POSITION: relative"><div style="overflow: hidden; border-left: black 1px solid; width: 14px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 13px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 12px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 11px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 10px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 9px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 8px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 7px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 6px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 5px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 4px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 3px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 2px; height: 1px; "></div><div style="overflow: hidden; border-left: black 1px solid; width: 1px; height: 1px; "></div></div></td></tr></tbody></table></td><td  class="showNeutralPopInner" style="padding:0;padding-RIGHT: 5px; border-top: black 1px solid; padding-left: 5px; padding-bottom: 5px; padding-top: 5px; border-bottom: black 1px solid; font-family: verdana; " width="100%"><span style="text-decoration:none">'+ text +'</span></td></tr></tbody></table>';
	
	
	/* // position where mousemove fired
    var xPos    =  e? e.pageX : window.event.x;
	var yPos    =  e? e.pageY : window.event.y;
	// for ie add scroll position
	if (document.all && !document.captureEvents) {
	    xPos    += document[docEl].scrollLeft;
	    yPos    += document[docEl].scrollTop;
    }*/
	var myxy = getXY(e);
	var newdiv = document.createElement('div');
	
	newdiv.setAttribute('id',myid);
	newdiv.innerHTML =ret;
	newdiv.style.left=(myxy[0]+10)+"px";
	newdiv.style.top=(myxy[1])+"px";
	//alert(newdiv.style.left+' '+newdiv.style.top)
	newdiv.style.visibility='visible';
	newdiv.style.position='absolute';
	 if (document.layers) routeEvent(e);

	document.getElementById(div2Add).appendChild(newdiv);
	}

function getXY(e){
	var posx=0,posy=0;
  	var mousePos = new Array();
	if(e==null) e=window.event;
	if(e.pageX || e.pageY){
    	posx=e.pageX; posy=e.pageY;
    }
	else if(e.clientX || e.clientY){
    	if(document.documentElement.scrollTop){
        	posx=e.clientX+document.documentElement.scrollLeft;
        	posy=e.clientY+document.documentElement.scrollTop;
        }
    	else{
        	posx=e.clientX+document.body.scrollLeft;
        	posy=e.clientY+document.body.scrollTop;
        }
    }
  // posx and posy contain the mouse pos; Return them both
  mousePos[0] = posx;
  mousePos[1] = posy;
  return mousePos;
}

function closepopup(divNum) {
	var divNum = divNum+'1222';
	var t = document.getElementById(divNum);
	t.parentNode.removeChild(t);
}


function hidekgids(commaSeparatedValueList){
	var valueArray = commaSeparatedValueList.split(",");
	for(var i=0; i<valueArray.length; i++){
		Effect.toggle('kgid'+valueArray[i]);
	}
}
/************Funktion für POPUP Bubble************************/
// Original:  Nannette Thacker -->
//http://www.shiningstar.net -->
	
function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		
		return false;
	}
	else
	{
		 
		return true;
	}
}

  //bei klick alle checkboxen anhaken
  function checkAllBoxes(classname){
		var cbs = document.body.getElementsByTagName("INPUT");
		for (var i = 0; i < cbs.length; i++){
			if(cbs[i].className == classname) cbs[i].checked = (cbs[i].checked ? false : true);
		}
	}
  
  //textarea length
function CheckMaxLength(Object, MaxLen){
  if(Object.value.length > MaxLen){     
	alert("Bitte maximal "+MaxLen+" Zeichen eingeben!");
	Object.value = Object.value.substring(0, MaxLen);
  }
}
function ListToArray(l,d){		
		var r,a,i;			
		if(!d){d = ",";}		
		r = [];

		a = l.split(d);			
		for(i=1; i <= a.length; i++){
			r[i] = a[i - 1];
		}			
		return r;	
	}
	


///////////zeige an wieviele Zeichen alle Felder zusammen haben
function checktotallen(textfields,maxlen,formid){
	//textfields = Liste mit Feldern die Überprüft werden
	//maxlen = max Anzahl der Zeichen für alle
	//formname = id des Forms, leer lassen wenn kein submit gewünscht wird
	textfields = ListToArray(textfields);
	var mylen = 0;//ausgerechnete länge
	//wenn hier Fehler kommt mit textfields[i] =null, dann ist der Feldname gross geschrieben
	for(var i=1; i<textfields.length; i++){
		mylen = mylen + $(textfields[i]).value.length;
	}
	if (mylen > maxlen){
		alert("Sie haben "+mylen+" Zeichen eingegeben. Bitte maximal "+maxlen+" Zeichen fuer alle Felder eingeben!");
		return false;
	}
	else{
		if(formid.length != 0){
			var myForm = document.getElementById(formid);
			myForm.submit();
			}
		else{
			return true;	
			}
		
	}
}

//einfach nur Hilfe, check ob isArray   
function isArray(obj) {
  if (obj == null) return false;
  return obj.constructor == Array;
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789";
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Bitte tragen Sie nur Zahlen \""
alertsay = alertsay + checkOK + "\" in das Feld ein."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Bitte geben Sie einen Wert groesser oder "
alertsay = alertsay + "gleich \"" + minval + "\" und kleiner als oder "
alertsay = alertsay + "gleich \"" + maxval + "\" in das Feld."
alert(alertsay);
return (false);
}
}

function submitenter(myfield,e,superbid)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   doTheSearch('firma','ASC','1',superbid);
   return false;
   }
else
   return true;
}

//fuer NAce und Kompetenzen
function changeNaceIcon(did){

	if(document.getElementById('minus'+did).style.display=='block'){
		 document.getElementById('minus'+did).style.display='none';
		 document.getElementById('plus'+did).style.display='block';
		 }
	else{
		 document.getElementById('minus'+did).style.display='block';
		 document.getElementById('plus'+did).style.display='none';
		}
	}
	
	function dsform_select_move(this_select){
	select_id=this_select.id.split('_');
	this_value=this_select.value;
	active_value=$('active_'+select_id[2]).value.split(',');
	if (this_value!=''){
		if (select_id[1]=='inactive'){
			if($('active_'+select_id[2]).value=='')
				active_value[0]=this_value;
			else
				active_value[active_value.length]=this_value;			
		}
		else if (select_id[1]=='active'){
			new_value=new Array();
			for(k=0;k<active_value.length;k++){
				if(active_value[k]!=this_value){
					new_value[new_value.length]=active_value[k];
				}
			}
			active_value=new_value;
		}
		$('active_'+select_id[2]).value=active_value;
		dsform_select_move_init(select_id[2]);
	}
}

//fuer Produkteigenschaften
function changeEigenschaftenIcon(did){

	if(document.getElementById('minusX'+did).style.display=='block'){
		 document.getElementById('minusX'+did).style.display='none';
		 document.getElementById('plusX'+did).style.display='block';
		 }
	else{
		 document.getElementById('minusX'+did).style.display='block';
		 document.getElementById('plusX'+did).style.display='none';
		}
	}
	
	function dsform_select_move(this_select){
	select_id=this_select.id.split('_');
	this_value=this_select.value;
	active_value=$('active_'+select_id[2]).value.split(',');
	if (this_value!=''){
		if (select_id[1]=='inactive'){
			if($('active_'+select_id[2]).value=='')
				active_value[0]=this_value;
			else
				active_value[active_value.length]=this_value;			
		}
		else if (select_id[1]=='active'){
			new_value=new Array();
			for(k=0;k<active_value.length;k++){
				if(active_value[k]!=this_value){
					new_value[new_value.length]=active_value[k];
				}
			}
			active_value=new_value;
		}
		$('active_'+select_id[2]).value=active_value;
		dsform_select_move_init(select_id[2]);
	}
}

function dsform_select_move_init(id){
	active_value=$('active_'+id).value.split(',');
	select_active=$('select_active_'+id);
	select_inactive=$('select_inactive_'+id);
	dsform_select_move_option_name=eval('dsform_select_move_option_name_'+id);
	dsform_select_move_option_value=eval('dsform_select_move_option_value_'+id);
	for (i=select_active.length-1;i>=0;i--){
		select_active.options[i]=null;
	}
	for (i=select_inactive.length-1;i>=0;i--){
		select_inactive.options[i]=null;
	}
	for (i=0;i<dsform_select_move_option_value.length;i++){
		this_select=0;
		for(k=0;k<active_value.length;k++){
			if(active_value[k]==dsform_select_move_option_value[i]){
				this_select=1;
				break;
			}
		}
		if(this_select==0){
			select_inactive.options[select_inactive.length]=new Option(dsform_select_move_option_name[i],dsform_select_move_option_value[i],false,true);
		}
	}
	for(k=0;k<active_value.length;k++){
		for (i=0;i<dsform_select_move_option_value.length;i++){		
			if(active_value[k]==dsform_select_move_option_value[i]){
				select_active.options[select_active.length]=new Option(dsform_select_move_option_name[i],dsform_select_move_option_value[i],false,true);
				break;
			}
		}
	}
	select_active.selectedIndex=0;
	select_inactive.selectedIndex=0;
}

