//functions common to front and back ends

//function for form tips
function tipobject(tipid,tiplabel,tiptext,width,xoffset,yoffset){
this.tipid=tipid;
this.tiplabel=tiplabel;
this.tiptext=tiptext;
this.width=width;
this.xoffset=xoffset;
this.yoffset=yoffset;
}


function puttipimg(tiplabel){
 if((tiparray[tiplabel]) || (mode=="setup")){
 if(mode=="setup"){
onclickstring = "edittip(this)";
}
else
{
onclickstring = "";
}
	 		document.writeln('<img src="images/tipimg.gif" width="15" height="15" border="0" name="tip_'+tiplabel+'" onMouseOver="showtip(this);" onMouseOut="hidetip();" onclick="'+onclickstring+'"> ');
	 } 
}


function scrolly(){
//from quirksmode.org/viewport/compatability.html
if(self.pageYOffset){
// all browswers except explorer
y = self.pageYOffset;
}
else if(document.documentElement && document.documentElement.scrollTop){
// explorer 6 strict
y = document.documentElement.scrollTop;
}
else if(document.body){
// all other explorers
y = document.body.scrollTop;
}
return y;
}


function showtip(thetip){
thetip = thetip.name.replace(/tip_/,"");

if(!tiparray[thetip]){
return;
}

obj = tiparray[thetip];
tipbox.innerHTML= obj.tiptext;
tipbox.style.left=event.x-obj.xoffset;
tipbox.style.top=event.y+scrolly()-obj.yoffset;
//tipbox.style.top=event.y-Number(tipbox.style.height.replace(/px/,""));

if(obj.width){
tipbox.style.width=obj.width;
}
else
{
tipbox.style.width= tipwidthdefault;
}
tipbox.style.display = '';
}

function hidetip(){
tipbox.innerHTML= "";
tipbox.style.display = 'none';
}



function edittip(thetip){
thetip = thetip.name.replace(/tip_/,"");
if(tiparray[thetip]){
obj = tiparray[thetip];
tipid = obj.tipid;
}
else
{
tipid="";
}
location.href='admin_edittipform.php?tipid='+tipid+'&tiplabel='+thetip+'&tippagename='+tippagename;
}

