function showWhirlpoolNavi(){

    var whirlpool_navi = "<div id=\"anschrift\"><h1>Anschrift &amp; Ausstellungsräume</h1><a href=\"http://www.emotion-24.de\">www.emotion-24.de</a> <br />Emotion Warenhandels GmbH <br />Am Wall 165 - 167 <br />D - 28195 Bremen <br />Tel. 0421 - 2469510</div>";
    var logo = '<div id="logo-emotion"><img alt="Whirlpools-24" src="templates/emotion/img/logo_whirlpools24_grau_bg.gif"></div>';
    
    var img = "<div id='klempnermeister'><img src=\"templates/emotion/img/klempner_whirlpools.jpg\" alt=\"www.emotion-24.de, Von Fachleuten in Bremen gebaut\" /></div>";
    
    
    
    /*$("#powersearch").hide();
     $('#namenssuche').hide();
     $('#head_navi').hide();
     $('#logo-oben').hide();*/
    //$('.menu').hide();
    
    //$('#powersearch').replaceWith(img);
    
    
    $('#logo-emotion').replaceWith(logo);
    
}


var selected;
var submitter = null;


function submitFunction(){
    submitter = 1;
}

function popupWindow(url){
    window.open(url, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}



function selectRowEffect(object, buttonSelect){
    if (!selected) {
        if (document.getElementById) {
            selected = document.getElementById('defaultSelected');
        }
        else {
            selected = document.all['defaultSelected'];
        }
    }
    
    
    
    if (selected) 
        selected.className = 'moduleRow';
    
    object.className = 'moduleRowSelected';
    selected = object;
    
    
    
    // one button is not an array
    if (document.getElementById('payment'[0])) {
        document.getElementById('payment'[buttonSelect]).checked = true;
    }
    else {
        //document.getElementById('payment'[selected]).checked=true;
    }
    
}



function rowOverEffect(object){

    if (object.className == 'moduleRow') 
        object.className = 'moduleRowOver';
    
}



function rowOutEffect(object){

    if (object.className == 'moduleRowOver') 
        object.className = 'moduleRow';
    
}



function popupImageWindow(url){
    window.open(url, 'popupImageWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}



function check_form_optional(form_name){

    var form = form_name;
    
    
    
    var firstname = form.elements['firstname'].value;
    var lastname = form.elements['lastname'].value;
    var street_address = form.elements['street_address'].value;
    
    
    
    if (firstname == '' && lastname == '' && street_address == '') {
        return true;
    }
    else {
        return check_form(form_name);
    }
    
}



Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function round(val, places) {

    m = 1;

    for(i=0; i<places; i++) {

        m = m * 10;

    }

    var result=Math.round(val*m)/m;

    return result;   

}

function showLayer(group, prod_no){

	if(image_scrolling) {

		toggleScrolling();

	}

	$('#image_container > div').hide();

	$('#conf_product_' + group + '_' + prod_no).show();

	$('#image_container').show();

	$('#image_layer').show();

}



function hideLayer(){

	if(image_scrolling == false) {

		toggleScrolling();

	}

	$('#image_container').hide();

	$('#image_layer').hide();

}





function showRateTable(el) {

	var rate_table = $('#rate_table');

	//alert(el.position().left + ' ' + el.position().top);

	rate_table.show();

}



function hideRateTable() {

	$('#rate_table').hide();

}



function getY() {

	// all except Explorer

	if (self.pageYOffset){

		y = self.pageYOffset;

	}

	// Explorer 6 Strict

	else if (document.documentElement && document.documentElement.scrollTop){

		y = document.documentElement.scrollTop;

	}

	// all other Explorers

	else if (document.body){

		y = document.body.scrollTop;

	}

	

	return(y);

}

$('document').ready(function(){
	$('input[name="products_qty"]').keyup(
		function(){
	$('input[name="products_qty"]').val($(this).val());
	});
	
    $('a.ajax').click(function(e) {
		e.preventDefault();
        var url = this.href + ' td.main';
        var dialog_div = $('<div style="display:none;"></div>');
        dialog_div.appendTo('body');
        //console.log(dialog);
        // load remote content

        dialog_div.load(
            url, 
            {},
            function (responseText, textStatus, XMLHttpRequest) {
				$(this).dialog({modal: true,
								resizable: false,
								width: 780});
            }
        );

    });

    $('a.prospekt').click(function(e) {
		e.preventDefault();
        var url = this.href + ' td.main';
        var dialog_div = $('<div style="display:none;"></div>');
        dialog_div.appendTo('body');
        //console.log(dialog);
        // load remote content

        dialog_div.load(
            url, 
            {},
            function (responseText, textStatus, XMLHttpRequest) {
				$(this).dialog({modal: true,
								resizable: true,
								width: 780,
								title: 'Unser aktueller Prospekt',
								resize: function(event, ui){
									var new_width = ui.size.width - 22;
									var new_height = new_width * 0.7;
									
									$(this).find('#prospekt_112011').css({height: new_height + 'px', width: new_width + 'px'});
								}});
            }
        );

    });

});

function updateProductsQty(editedBox){
	$('input[name="products_qty"]').val(editedBox.val());
}

function formatCurrency(num, decimal_places, decimal_point, thousands_point) {

    num = num.toString().replace(/\$|\,/g,'');

    if(isNaN(num)) 

        num = "0";

    sign = (num == (num = Math.abs(num)));

    num = Math.floor(num*100+0.50000000001);

    cents = num%100;

    num = Math.floor(num/100).toString();

    if(cents<10)

        cents = "0" + cents;

    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

        num = num.substring(0,num.length-(4*i+3))+thousands_point+

    num.substring(num.length-(4*i+3));

    return (((sign)?'':'-') + num + decimal_point + cents);

};
