// JavaScript Document
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
  with (document){ if (getElementById){
    var obj = getElementById(objId);} if (obj) obj.value = newText;
  }
}

function filterByZipcode()
{
	var frm = document.frmFilterByZipcode;
	
	if(frm.zipcode.value.length == 4) {
		var params = $('frmFilterByZipcode').serialize();
		
		$('tblContainer').innerHTML = 'Loading...';
		ajaxRequest(
			'?mod=company&task=list&requestMode=ajax&' + params, 
			'get',
			'text', 
			'tblContainer',
			'innerHTML',
			'','');
	}
}

function addNewCat()
{
	var f = document.frmInsertCat;
	if(f.category_name.value == '') {
		alert('Please enter Category Name!');
		return false;
	} 
	
	$('popupAlert').innerHTML = 'Ihr Vorschlag wurde gesendet!';
	var params = $('frmInsertCat').serialize();
	ajaxRequest(
		'?mod=basket&task=remove&requestMode=ajax' + params, 
		'post',
		'nothing', 
		'',
		'',
		"autoHide('#popupAlert', 5000);",'');
}

function addToBasket(company_id)
{
	$('popupAlert').innerHTML = 'Ihr Wohlf&uuml;hl Partner wurde vorgemerkt!';
	
	ajaxRequest(
		'?mod=basket&task=add&requestMode=ajax&company_id=' + company_id, 
		'get',
		'nothing', 
		'',
		'',
		"autoHide('#popupAlert', 5000);",'');
}

function removeFromBasket(company_id)
{
	$('basket_item_' + company_id).hide();
	$('popupAlert').innerHTML = 'Vormerkung gel&ouml;scht!';
	autoHide('#popupAlert', 5000);
	
	ajaxRequest(
		'?mod=basket&task=remove&requestMode=ajax&company_id=' + company_id, 
		'get',
		'nothing', 
		'',
		'',
		'','');
}

function ClickHereToPrint(){
    try{ 
        var oIframe = document.getElementById('ifrmPrint');
        var oContent = document.getElementById('main1').innerHTML;
        var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
        if (oDoc.document) oDoc = oDoc.document;
		oDoc.write("<html><head><title>title</title>");
		oDoc.write("</head><body onload='this.focus(); this.print();'>");
		oDoc.write(oContent + "</body></html>");	    
		oDoc.close(); 	    
    }
    catch(e){
	    self.print();
    }
}
