String.prototype.leftTrim = function () {
return (this.replace(/^\s+/,""));
};
String.prototype.rightTrim = function () {
return (this.replace(/\s+$/,""));
};

String.prototype.basicTrim = function () {
return (this.replace(/\s+$/,"").replace(/^\s+/,""));
};
var ajaxLoading = "<p style=\"margin:30px auto; width:155px;color:black;font-size:11px;font-weight:bold; height:65px; background:#ffffff; border: 1px solid #a1a1a1\" align=\"center\"> <br/>... Daten werden geladen ...<br/> <br/>  <img src=\"/images/ajax_loading.gif\" /></p>";

function makeHttpRequest(url, callback_function, targetArea, method , return_xml, return_json)
{
	var http_request = false;

	if( !method ) {
		method = 'GET';
	}
	
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	http_request = new XMLHttpRequest();
	if (http_request.overrideMimeType) {
		http_request.overrideMimeType('text/xml');
	}
	} else if (window.ActiveXObject) { // IE
	try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
	}

	if (!http_request) {
		alert('Unfortunatelly you browser doesn\'t support this feature.');
		return false;
	}

	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				
				if(return_json)	{
					text = 	http_request.responseText;
					eval(callback_function + '(text)');
				} else if (return_xml) {
					eval(callback_function + '(http_request.responseXML)');
				} else {
					eval(callback_function + '(http_request.responseText,' + 'targetArea)'  );
				}
			} else {
				alert('There was a problem with the request.(Code: ' + http_request.status + ')');
			}
		}
	}
	http_request.open(method, url, true);
	http_request.send(null);
}


function showContent(text, targetArea) {
	document.getElementById(targetArea).innerHTML = text;
}

function showSearchContent(text, targetArea) {
	
	var strlen = text.length;
	if ( strlen > 0) {
		document.getElementById(targetArea).innerHTML = text;
		document.getElementById('cardSearchText').readonly = false;
		document.getElementById('cardSearchText').focus = true;
	}
}

function setStartContent(folder)
{
	if(document.getElementById('home_menu_content'))
	{
		makeHttpRequest('themes/'+folder+'/home/content_1.ajax', 'showContent','home_menu_content');
	}
}


var faqid= '';
var classname;

function showFaq(ID)
{
	var actElement = document.getElementById('dataset_'+ID);

	var actClassName = actElement.className;

	if(faqid != '')
	{
		if(document.getElementById('dataset_'+faqid))
		{
			document.getElementById('dataset_'+faqid).className= 'hide';
		}
	}

	if(actClassName == "show")
	{
		classname='hide';
	}
	else
	{
		classname='show';
		faqid = ID;
	}
	actElement.className= classname;
}

var faq_menu_id = '';
function setFaqMenu(ID)
{
	if (ID != faq_menu_id)
	{
		if(faq_menu_id != '')
		{
			if(document.getElementById('faq_category_'+faq_menu_id))
			{
				document.getElementById('faq_category_'+faq_menu_id).className='faq_menu';
			}
		}
		document.getElementById('faq_category_'+ID).className='faq_menu_sel';
		faq_menu_id = ID;
	}
}

function hightlightFaqMenu(ID)
{
	var menuPoint 			=	document.getElementById('faq_category_'+ID)
	var menuPointclassName  = 	menuPoint.className;

	if(menuPointclassName == 'faq_menu')
	{
		menuPoint.className = 'faq_menu_sel';
	}
	else
	{
		if(ID != faq_menu_id)
		{
			menuPoint.className = 'faq_menu';
		}
	}
}
var foundtype="";
function check_howfound(foundtype)
{
	
	if(foundtype == 9)
	{
		document.getElementById('howfound_comment').style.display = "block";
	}
	else
	{
		document.getElementById('howfound_comment').style.display = "none";
	}
}


var billingtTypes = new Array();
billingtTypes[1]  = new Array (1, 2, 3);
billingtTypes[2]  = new Array (2, 4);
billingtTypes[3]  = new Array (2, 5);


function checkBillingFormular(ID)
{
	var billingtType="";
	if(ID == 1 || ID == 4)
	{
		billingtType = 1;
	}
	else if (ID == 2 || ID == 3 || ID == 5)
	{
		billingtType = 2;
	}
	else if (ID == 6)
	{
		billingtType = 3;
	}
	else
	{
		billingtType = 0;
	}


	for (var i=1;i<=5;i++)
	{
		document.getElementById('Billing_'+i).className = "hide";
	}

	if(billingtType != 0 )
	{
		var act_BillingTypes = billingtTypes[billingtType];

		for (var j = 0; j < act_BillingTypes.length; j++)
		{
			var id = act_BillingTypes[j];
			document.getElementById('Billing_'+ id).className = "show_1";
		}
	}
}



function checkCustomer( value )
{
	if (value == true)
	{
		document.getElementById('customernumber').disabled=false;
	}
	else
	{
		document.getElementById('customernumber').disabled=true;
	}
}

function clearIDNumber()
{
	var element = document.getElementById('idnumber');
	var value = element.value;
	if(value === "XXX-XXXXXXX-XX-X")
	{
		element.value  = "";
	}
}


var customerData_1 = "";
var customerData_2 = "";

function check_customerDataChange(value, checked)
{
	if(value == 1 )
	{
		if ( checked == true)
		{
			document.getElementById('customerData_1').className="show_1";
			customerData_1 = 1;
		}
		else
		{
			document.getElementById('customerData_1').className="hide";
			customerData_1 = 0;
		}
	}
	else
	{
		if (checked == true)
		{
			document.getElementById('customerData_2').className="show_1";
			customerData_2 = 1;
		}
		else
		{
			document.getElementById('customerData_2').className="hide";
			customerData_2 = 0;
		}
	}
}



 

