function SymError(){
	return true;
}
window.onerror = SymError;

function newPnInf(DOM)
{
	open_window(DOM + '/index.php?p=misc&do=pnpop','pn',500,300,0);
}

function open_window(meineSeite,meinName,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	Fenster = window.open(meineSeite,meinName,settings);
}

function elemX (element) {
	var x = 0;
	while (element) {
		x += element.offsetLeft;
		element = element.offsetParent;
	}
	return x;
}

function elemY (element) {
	var y = 0;
	while (element) {
		y += element.offsetTop;
		element = element.offsetParent;
	}
	return y;
}

function getWidth (element) {
	return element.offsetWidth;
}

function getHeight (element) {
	return element.offsetHeight;
}

function elemObj(elementId) {
	if (document.all)
		return document.all[elementId];
	else if (document.getElementById)
		return document.getElementById(elementId);
	else
		return null;
}

function switch_img(DATA,ID){
	document.getElementById('img').innerHTML = '<a href="javascript:ImgBrowser(' + ID + ');"><img src="' + DATA + '" alt="" border="0" /></a>';
}

function switch_img_popup(DATA,ID){
	document.getElementById('img').innerHTML = '<img src="' + DATA + '" alt="" border="0" />';
}

function ImgBrowser(ID,DOM){
	window.open(DOM + 'index.php?p=misc&do=shopimgages&prodid=' + ID, ID, 'width=700,height=600,top=0,left=0');
}

function mergeProduct(ID,RED,CID,DOM){
	window.open(DOM + 'index.php?redir=1&p=misc&do=mergeproduct&prodid=' + ID + '&red=' + RED + '&cid=' + CID, 'merge_win', 'scrollbars=1,width=950,height=750,top=0,left=0');
}


function paymentInf(ID,DOM){
	window.open(DOM + 'index.php?p=misc&do=payment_info&id=' + ID,'paymentinf','width=800,height=550,top=0,left=0,scrollbars=1');
}


function check_search_field(){
	if(document.getElementById('s_x').value != '' && document.getElementById('s_x').value.length < 2){
		document.getElementById('small_search_hidden_div').style.display='';
		return false;
	} else {
		document.getElementById('small_search_hidden_div').style.display='none';
	}	
}

function openAdmin(DOM){
	open_window(DOM + 'admin/index.php','Admin',980,780,1);
}

function getActiveText(msg){
	selectedText = (document.all) ? document.selection.createRange().text : window.getSelection();if (msg.createTextRange) msg.caretPos = document.selection.createRange().duplicate();return true;
}

function unametofield(theuser) {
	opener.document.f.tofromname.value = '' + theuser + '';
	window.close();
}

function add_code(NewCode){
    document.f.text.value += NewCode;
    document.f.text.focus();
}
