function openWin(UR,x,y) {
	ew=window.open(UR,"Edit","width="+x+",height="+y+",status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
	ew.focus();
}
function openWin2(UR,x,y,name) {
	ew=window.open(UR,name,"width="+x+",height="+y+",status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
	ew.focus();
}
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 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 popup_photo(photo_id) {
	url="<%getValueOf:siteHttp%>popup_image.php?photo_id="+photo_id;
	window.open(url,'popupWindow','toolbar=no,location=yes,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 open_photo_gallery(id) {
	x=800;
	y=600;
	UR="<%getValueOf:siteHttp%>car_gallery/?id="+id;
	openWin(UR,x,y);
}
Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++)  {
		if(this[i] == p_val) return true;
	}
	return false;
}
function getElementPosition(elemId) {
	var elem = document.getElementById(elemId);
	var w = elem.offsetWidth;
	var h = elem.offsetHeight;
	var l = 0;
	var t = 0;
	while(elem) {
		l += elem.offsetLeft;
		t += elem.offsetTop;
		elem = elem.offsetParent;
	}
	return {"left":l, "top":t, "width": w, "height":h};
}
function check_email(email) {
    var template = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z])+$/;
    email = drop_spaces(email);
    if (template.test(email)) return true;
    else return false; 
}
function drop_spaces(str) {
    var newstr = trim(str);
    return newstr.replace(/(\s)+/g, ""); 
}
function trim(str) {
    var newstr = str.replace(/^\s*(.+?)\s*$/, "$1");
    if (newstr == " ") {
        return "";
    }
    return newstr;
}
