// Hypertools CMS
// global.js V1.1

// default functions
function setContent(obj,ded,output) {
	tmp = findObj(obj,'');
	tmp.innerHTML = output;
}

function doSubmit(cartAct) {
	obj = findObj('cartAct');
	obj.value = cartAct;
	//obj2 = findObj('frmCart');
	document.frmCart.submit();
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

// image functions
function doImgPop(imgSrc,imgAlt) {
	window.open("viewImage.asp?image="+ imgSrc,'viewImage','toolbar=no,location=no,status=no,resizable=yes,width=300,height=300');
}

function doImgMain(objID,imgSrc,imgAlt) {
	tmp = findObj(objID,'');
	tmp.src = "../media/wsdindex.html"+ imgSrc;
	tmp.alt = imgAlt;
}
function doImgInline(imageName,evtObj) {
	//actObj = findObj(evtObj,'');

	//var picObj = new getObj('picpreviewimg');
	picObj = findObj('picpreviewimg','');
	picObj.src='../media/wsdindex.html'+ imageName;
	
	var newX = findPosX(evtObj);
	var newY = findPosY(evtObj);

	//picObjFrame = findObj('picpreview','');
	var picObjFrame = new getObj('picpreview');
	picObjFrame.style.top = (newY+15) + 'px';
	picObjFrame.style.left = newX + 'px';
	picObjFrame.style.visibility = 'visible';
	}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
	}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
	}

function getObj(name) {
 if (document.getElementById) {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 } else if (document.all) {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 } else if (document.layers) {
	   if (document.layers[name]) {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   } else {
	    this.obj = document.layers.picpreview.layers[name];
	    this.style = document.layers.picpreview.layers[name];
	   }
	}
}	
function closeImageObj() {
	var picObjFrame = new getObj('picpreview');
	//picObjFrame = findObj('picpreview','');
	picObjFrame.style.visibility = 'hidden';
	
	var picObj = new getObj('picpreviewimg');
	//picObj = findObj('picpreviewimg','');
	picObj.src='gfx_site/loading_thumb.gif'
	}