

function getNews(newsid){
	var newWindow = window.open('/nieuws_detail.php?newsid=' + newsid,'nieuwsbericht','height=500,width=470, scrollbars=yes');
	newWindow.focus();
}


function openLogin() {
	

	win = window.open	("dealer_login.php", "loginwindow", "width=305,height=200");
	win.focus();	
}

function logout()  {
	
	document.location.href='index.php?logout=true';
	
}



function removeCommas(thePrice){
    if ( thePrice && thePrice.length ) {
		var containsComma = thePrice.indexOf(",") > -1;	
		containsComma ? convPrice = thePrice.replace(",", '.')*100/100 : convPrice = thePrice;
		//alert(convPrice);
		return convPrice;
    } else {
        return 0;
    }
}
	
function addCommas(thePrice){
	var thePrice = thePrice+''; // convert number to string
		var containsDot = thePrice.indexOf(".") > -1;	
		containsDot ? convPrice = thePrice.replace(".", ',') : convPrice = thePrice;
		return convPrice;
	}
	
	
function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString();
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".");

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}	


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') { 
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


