/** 
 * get dynamic base url
 * 
 */
function displayNoImage(img, size)
{
	var url_no_img = url_theme + 'images/no_image/';
	var w = 0;
	var img_src = '';
	switch(size) {
		case 'small': img_src = url_no_img + 'large.jpg'; break;
		case 'normal': img_src = url_no_img + 'normal.jpg'; break;
		case 'large': img_src = url_no_img + 'large.jpg'; break;
		default: img_src = url_no_img + 'large.jpg'; w=size; break;
	}
	img.src = img_src;
	if(w != 0) img.width = w;
}

function limitChars(textid, limit, infodiv)
{
	var text = jQuery('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		jQuery('#' + infodiv).html('Sie können nicht mehr als '+limit+' Zeichen eingeben!');
		jQuery('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		jQuery('#' + infodiv).html('Sie haben noch '+ (limit - textlength) +' Zeichen.');
		return true;
	}
}


function autoHide(obj, liveTime)
{
	jQuery(obj).show('slow');
	setTimeout("jQuery('"+obj+"').hide('slow');", liveTime);
}

function getFileExtension($file)
{
	return ($file.substring($file.lastIndexOf('.') + 1)).toLowerCase();
}
function open_popup(url,popup_name,width,height)
{
	var left = Math.floor((screen.width - width) / 2);
	var top = Math.floor((screen.height - height) / 2);
	window.open(url,popup_name, 'height='+height+', width='+width+', left='+left+',top='+top+',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');
}

/**
 * check window is opened as popup
 * @author thanhnv
*/
function is_popup()
{
	return (window.opener && !window.opener.closed) ? true : false;
}

function open_popup_ajax(url,popup_name,width,height)
{
	var left = Math.floor((screen.width - width) / 2);
	var top = Math.floor((screen.height - height) / 2);
	
	var params = "width=" + width + "px,height=" + height + "px,left=" + left + "px,resize=1,scrolling=1";
	if(popup_name == '')
	{
		popup_name = 'HAASMEDIA';
	}
	ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", url, popup_name, params);
	//ajaxwin.onclose=function(){return window.confirm("Close window?")} //Run custom code when window is about to be closed
}
function redir(url)
{
	eval("location.href = '" + url + "'");
}
function redirParent(url)
{
	eval("opener.location.href = '" + url + "'");
	self.close();
}
function check_all(obj, objImage) 
{
	if (obj) {
		if (obj.length) {
			value = obj[0].checked==false?true:false;
			
			for (i=0;i<obj.length;i++)
				obj[i].checked = value;
		}
		else {
			value = obj.checked==false?true:false;
			obj.checked = value;
		}
		/**/
		if(objImage){
			objImage.src = (value) ? srcImageClearAll : srcImageCheckAll; 
		}
		
	}
}

function ClearSelectBox(obj)
{
	var NumState = obj.options.length;
	while(NumState > 0){
		NumState--;
		obj.options[NumState] = null;
	}
}



function stripslashes (str) {
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
            case '\\':
                return '\\';
            case '0':
                return '\0';
            case '':
                return '';
            default:
                return n1;
        }
    });
}


