window.onerror = null;

function addBookmark(url, title){
  if (!url) url = location.href;
  if (!title) title = document.title;
  
  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else return;
  return;
}
function addtobasket(id,refid){
	document.location="mybas.php?c=add&id="+id;
	result2Div = document.getElementById(refid);
	result2Div.innerHTML = '<div id="' + refid + '"> </div>';
	alert('Product added to collection.');
}
function remtobasket(id){
	var oldlocation = document.location;
	document.location="mybas.php?c=rem&id="+id;
	alert('Product deleted from collection.');
	document.location = oldlocation;
}
function langset(a) { 
	test = getQueryVariable();
	f = "index.php?lang="+a;
	for(i in test){
		if ((i != 'lang') & (i != ''))  {f = f + '&' + i + '=' + test[i]; } 
	}
	window.location.replace(f);
}
function getQueryVariable() {
	var query = window.location.search.substring(1);  
	var vars = query.split("&");
	var arr = new Array(); 
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		arr[pair[0]] = pair[1];
	}
	return arr;
}


//add string class
if ('undefined' == typeof String.prototype.ltrim) {
  String.prototype.ltrim = function() {
    return this.replace(/^\s+/, '');
  }
}
if ('undefined' == typeof String.prototype.rtrim) {
  String.prototype.rtrim = function() {
    return this.replace(/\s+$/, '');
  }
}
if ('undefined' == typeof String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  }
}

function getBounds(element){
	var left = element.offsetLeft;
	var top = element.offsetTop;
	for (var parent = element.offsetParent; parent; parent = parent.offsetParent)  {
		left += parent.offsetLeft - parent.scrollLeft;
		top += parent.offsetTop - parent.scrollTop
	}
	return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}
function getClientWidth(){
	return document.compatMode=="CSS1Compat" && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function getClientHeight(){
	return document.compatMode=="CSS1Compat" && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function getBodyScrollTop(){
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function getBodyScrollLeft(){
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}



function show_props(obj) { 
 var result = ""
 for (var i in obj) { 
	if (obj[i]){ result += obj + "." + i + " = " + obj[i] + "\n"}
 }   
	alert (result);
}

