var topZIndex=30;
var errorElement=null;
var commentbkVisible=false;

function addCommentForm(location, refid) {
 if (!commentbkVisible)	 viewcomments(location,refid);

if (document.getElementById('entryform')==null) {
 element = Builder.node('div',{id: 'entryform' ,style:'width:205px;height:180px;position:absolute;top:'+(Math.ceil(dimension[1]/2)-90)+'px;left:'+(Math.ceil(dimension[0]/2)-102)+'px;z-index:4;border:4px solid #CCCCCC;background-color:#FFFFFF;'});
 
 document.getElementById('yeahbaby').appendChild(element);
 Element.hide('entryform');
 Ebenen.push(element);
 }
 document.getElementById('entryform').style.zIndex=13;
 new Ajax.Updater('entryform', 'comment.php?action=entryForm&location='+location+'&refid='+refid, {asynchronous:true});
 new Effect.Appear('entryform')
 new Draggable('entryform',{handle:'entryformhandle'});
}

function addErrortoList(txt)
{ 
	if (errorElement != null) document.getElementById('errorDisplay').removeChild(errorElement);
	errorElement = document.getElementById('errorDisplay').appendChild(document.createTextNode(txt));
	new Effect.Highlight('errorDisplay',{color:'#FF0000'});
}

function putOnTop(element) {
  element.style.zIndex=topZIndex;
  topZIndex++;
}

function viewcomments(location, refid) {
window.scrollTo(0,0);	
document.getElementsByTagName('body')[0].style.overflow='hidden';
if (document.getElementById('commentbk') == null)  {
		create_content('commentbk',0,0,'absolute','');
		document.getElementById('commentbk').style.backgroundColor='#000000';
		document.getElementById('commentbk').style.width=dimension[0];
		document.getElementById('commentbk').style.height=dimension[1];
		document.getElementById('commentbk').style.zIndex=10;
}
if (document.getElementById('commentcontainer') == null) {
	element = Builder.node('div',{id: 'commentcontainer' ,style:'width:'+(dimension[0]-40)+'px;height:'+(dimension[1]-40)+'px;position:absolute;top:10px;left:10px;z-index:4;'});
  document.getElementById('yeahbaby').appendChild(element);
   } 
   document.getElementById('commentcontainer').style.zIndex=11;
   Element.hide('commentcontainer');  
    new Ajax.Updater('commentcontainer', 'comment.php?action=viewComments&location='+location+'&refid='+refid, {asynchronous:true});

    Element.setOpacity('commentbk',0.0);
    Element.show('commentbk');
     new Effect.Opacity('commentbk',
    { duration: 0.3, 
      transition: Effect.Transitions.linear, 
      from: 0.0, to: 0.75 });
      commentbkVisible=true;
   new Effect.Appear('commentcontainer'); 
}

function submitCommentForm(location, refid) {
 document.getElementById('commentXPos').value=getvfstyle(document.getElementById('entryform').style.left);
 document.getElementById('commentYPos').value=getvfstyle(document.getElementById('entryform').style.top);
 comform.submit();
}

function submitSuccessfull(location, refid) {
	new Ajax.Updater('commentcontainer', 'comment.php?action=viewComments&location='+location+'&refid='+refid, {asynchronous:true,onComplete:function(){
 	new Effect.Fade('entryform');
 	document.getElementsByTagName("body")[0].removeChild('entryform');
 }});
}


function closeEntryform() {
new Effect.Fade('entryform');

}

function closeComments(location) {
if (document.getElementById('entryform')!=null) new Effect.Fade('entryform');

new Effect.Fade('commentcontainer');
new Effect.Fade('commentbk');
commentbkVisible=false;
if (location==1) window.setTimeout("document.getElementsByTagName('body')[0].style.overflow='auto';",1000);

}