// JavaScript Document
var d = new Array();
var si;
var nw;
var test="";
var movob;

//var movob = new {}array(new Move()function move() {});

var mX;
var mY;
var sX;
var sY;
var ajaxout='ajaxout';

function MoveObject(id) {
	this.obj = document.getElementById(id);

	this.w=300;
	this.l=500;

	this.left = mX-this.w+"px";
	this.top = mY-this.l+"px";

this.obj.style.left = this.left;
this.obj.style.top = this.top;

/*
	movob.style.width = w+"px";
	movob.style.top = mY-l+"px";
	movob.style.left = mX-l+"px";
	movob.obj.style.width = w+"px";
	movob.obj.style.top = mY-l+"px";
	movob.obj.style.left = mX-l+"px";*/
	this.move = function () {this.obj.style.left = this.left; this.obj.style.top = this.top;};
	this.show = function () {this.obj.style.display="block";}// this.obj.style.margin = "10px";}
	this.hide = function () {this.obj.style.display="none";}// this.obj.style.margin = "10px";}

}

function largeImg(prod,img) {
	prod = escape(prod);
	img = escape(img);
	purl ='popup.php?img='+img + "&prod=" + prod;
	nw = window.open(purl, 'fe', "width=400,height=500,scrollbars=auto,menubar=no,resizable=yes,status=yes");
	nw.focus();
	return false;
}


function openWindow(url) {
  	var out = window.open(url, 'new', "");
		return false;
}


function showDetails(id) {
  movob = document.getElementById(id);
//  movob = new MoveObject(id);
//  movob.move();
  movob.style.display='block';
	//	objmove();
}

function hideDetails(id) {
  movob = document.getElementById(id);
//movob.hide();
//	movob.obj.style.display = "none";
//  movob = new MoveObject(id);
//  movob.move();
  movob.style.display='none';
}

function objmove() {
//	if (movob) movob.move();

	w=300;
	l=w+100;

/*	movob.style.width = w+"px";
	movob.style.top = mY-l+"px";
	movob.style.left = mX-l+"px";
*/	movob.obj.style.width = w+"px";
	movob.obj.style.top = mY-l+"px";
	movob.obj.style.left = mX-l+"px";


}
function getMouseXY(e) {
  if(!e)e=window.event;
  mX = (e.pageX || e.clientX);
  mY = (e.pageY || e.clientY);

  sX = (e.screenX || e.clientX);
  sY = (e.screenY || e.clientY);
//	w=parseFloat(movob.style.width);

	objmove();
	self.defaultStatus=mX+":"+mY + "-"+sX+":"+sY;
	return true;
}
//	document.onmousemove = getMouseXY;


function layerHeight(id,h) {
  l = document.getElementById(id);
	l.style.height = h;
}

function layerWidth(id,w) {
  l = document.getElementById(id);
	l.style.width = w;
}

function layerHeight(id,h) {
  l = document.getElementById(id);
	l.style.height = h;
}


function toggleLinkText(id) {
  l = document.getElementById(id);
	test = l.innerHTML;

	if (test!="X") {
		l.innerHTML="X";
		return;
		}
	l.innerHTML="&laquo;";
}

function toggleWidthHeight(id) {
  l = document.getElementById(id);

	if ((l.style.width=="200px") && (l.style.height=="200px")){
		l.style.width = "20px";
		l.style.height = "20px";
		return;
		}

	if (l.style.width!="200px") l.style.width = "200px";
	if (l.style.height!="200px") l.style.height = "200px";
}

function absTop(el) {
	return (el.offsetParent)?
	el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}




 function findPos(id,prop)
      {
  pdc = document.getElementById(id).style;
	pdc.visibility="visible";
	pdc.display="block";
        var obj, propval, prop="top";
        if (document.documentElement && document.defaultView)
        {
          obj=document.getElementById(id);
          propval=document.defaultView.getComputedStyle(obj,"").getPropertyValue(prop); // in eine Zeile
          return(prop+": "+propval);
        }
        else
        {
          return("Ihr Browser unterstuetzt diese W3C-DOM-Methode nicht.");
        }
		pdc.top=parseInt(propval) - 100 + "px";
		self.defaultStatus=pdc.top;
	return false;
      }

function addbookmark(url) {
	if (document.all) window.external.AddFavorite(url,document.title);
}

var	nr='';
var	bigimgurl='';

	function show_big_img(url) {
	  bigimgurl=url;
		ajax_widget_bigimg();
	}

	function ajax_widget_bigimg( originalRequest ) {
		var myAjax = new Ajax.Request(
		  'ajax_bigimg.php?img='+bigimgurl,
		  { method: 'get', onComplete: ajax_zeige_bigimg }
		);

	}
	function ajax_zeige_bigimg( originalRequest ) {
	  document.getElementById('ajaxout').innerHTML = originalRequest.responseText;
		Tip ("<img src='"+bigimgurl+"'>",PADDING,4 , LEFT,true , OFFSETY,-300 , CLOSEBTN,true , CLICKSTICKY,true);
	}





//var nr;
	function show_widget_category_map(pnr) {
	  document.nr = pnr;
		ajax_widget_category_map();
	}

	function ajax_widget_category_map( originalRequest ) {
		var myAjax = new Ajax.Request(
		  "admin/widget_catgegory_map.php?ProductId=" + document.nr,
		  { method: 'get', onComplete: ajax_zeige_ergebnis }
		);
	}

	function ajax_zeige_ergebnis( originalRequest ) {
	  document.getElementById(ajaxout).innerHTML = originalRequest.responseText;
//
	  TagToTip ('ajaxout', TITLE,'Produkt / Kategorie verschieben', ABOVE,true , CLOSEBTN,true , CLICKSTICKY,true, STICKY,true);
	}


function getwidth(id) {
	return document.getElementById(id).width +"px";
}

var imgpreserv = new Array();
		imgpreserv.src = '';
		imgpreserv.width = '';
		imgpreserv.height = '';

function operafiximgheight(id) {
  	tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != "undefined");
		if (!tt_op) return;
		imgpreserv.src = document.getElementById(id).src;
		imgpreserv.width = document.getElementById(id).width;
		imgpreserv.height = document.getElementById(id).height;
		document.getElementById(id).src=imgpreserv.src;
		document.getElementById(id).width=imgpreserv.width;
		document.getElementById(id).height=imgpreserv.height;
}

function chimg (img,src) {
	var nimg = new Image();
	nimg.src = src;
	document.images[img].src = nimg.src;
}
