
function confirmLink(theLink, theMessage)
{
	var confirmMsg  = theMessage;
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} 

function PopUp()
{
	var URL = "./../messages/templates/html/pmpopup.tpl";
	var Name = "popup";
	var Fensteroptionen = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0";
	var Breite = 150;
	var Hoehe = 150;
	window.open(URL, 'Name', Fensteroptionen + ',width=' + Breite + ',height=' + Hoehe);
}

function setPointer(theRow, thePointerColor)
{
    if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
        return false;
    }

    var row_cells_cnt           = theRow.cells.length;
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function


function formatCurrency(num) 
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.00000000001);
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))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + ',' + cents);
}

function swapImage(imgName, imgSrc, picName) {
  if (document.images) document.images[imgName].src = imgSrc;
  if (document.images) document.images[imgName].id = picName;
}

function openXl(name) 
{
  url = "./shop.php?action=viewXxlPic&item_pic=" + name;	
  window.open(url, "_blank","location=ne,scrollbars=auto,toolbar=no,width=450,height=300");
}

function jumpToPage (targetpage, aktpage, formularname)
{
  document.formularname.check.value = aktpage ;
  document.formularname.action.value = targetpage ;
  document.formularname.submit() ;
}

function imposeMaxLength(Object, MaxLen, charLeftElId)
{
  var charLeft = MaxLen - (Object.value.length+1);
  if (charLeft<0)
  	charLeft=0;
  	
  document.getElementById(charLeftElId).innerHTML = charLeft;
  return (Object.value.length < MaxLen);
}

function checkLength(Object, MaxLen)
{
	return (Object.value.length < MaxLen);	
}