function showImageDef(c,id)
{
  imagediv.innerHTML = "";
  
  showDiv("imageview");
  //checkPos(true);
	
  imagediv.innerHTML =
  	"<table style=\"padding:10px;background:#FFFFFF;border: #CCCCCC 1px solid;\"><tr><td valign=center align=center><img id=previewpic onload=checkPos(false); onclick=\"hideDiv(\'imageview\');\" src='"+c+"/image/"+id+"/preview.jpg?width=580&height=580'></td></tr></table>";
}
function showImage(c,id,w,h)
{
  if ( ! w )
  {
     w = 720;
  }
  
  if ( ! h )
  {
    h = 480;
  }
  imagediv.innerHTML = "";
  
  showDiv("imageview");
  //checkPos(true);
	
  imagediv.innerHTML =
  	"<table style=\"padding:10px;background:#FFFFFF;border: #CCCCCC 1px solid;\"><tr><td valign=center align=center><img id=previewpic onload=checkPos(false); onclick=\"hideDiv(\'imageview\');\" src='"+c+"/image/"+id+"/preview.jpg?width=" + w + "&height=" + h +"'></td></tr></table>";
}
function checkPos(b)
{
  if ( document.all )
  {
  imageview.style.left = (document.body.offsetWidth/2) - (imageview.offsetWidth/2) + document.body.scrollLeft; 
  imageview.style.top = ((document.body.offsetHeight/2) - (imageview.offsetHeight/2)) + document.body.scrollTop;
  
  }
  else
  {
  
  newMargin = (-1 * (imageview.offsetHeight/2)) + document.body.scrollTop;
  if ( imageview.style.marginTop != newMargin )
  {
      imageview.style.marginTop = newMargin;
      
  }
  
  newMargin = (-1 * (imageview.offsetWidth/2)) + document.body.scrollLeft;
  if ( imageview.style.marginLeft != newMargin )
  {
      imageview.style.marginLeft = newMargin;
      
  }
  

  if  ( !imageview.style.top )
  {
  imageview.style.left = "50%";
  imageview.style.top = "50%";
  }
  

  }
}
function subStyle(obj,cn)
  {
   obj.className = cn;
  }


function props(obj)
  {
   for ( prop in obj) 
       {
        document.writeln( prop + " " + obj[prop] + "<BR>" );
       }
  }


function selectedIndex(e)
{
    for ( i = 0; i < e.length; i++ )
    {
        if ( e[i].checked ) 
        return i;
    }

    return -1;
}


function setAll(f,b,e)
{
  e = f[e];
  for (i = 0; i < e.length; i++)
  {
   e[i].checked = b.checked;
  }
}

function selectAll(who,e,b)
{
  f = document.forms[who];
  e = f[e];
  for (i = 0; i < e.length; i++)
  {
   e[i].checked = b.checked;
  }
}


function hl(obj,b)
{
  while (obj.tagName!="TR")
  {
    obj=obj.parentElement;
  }
 
  obj.className = ( b ) ? "row" : "";
}


function toggleDiv(id)
{
   if (document.getElementById)
   {
      if ( document.getElementById(id).style.display == "block" )
      {
         document.getElementById(id).style.display = "none";
      }
      else
      {
         document.getElementById(id).style.display = "block";
      }
   }
}

function showDiv(id)
{
   if (document.getElementById)
   {
      document.getElementById(id).style.display = "block";
   }
   else if (document.all)
   {
      document.all[id].style.display = "block";
   }
}

function hideDiv(id)
{
   if (document.getElementById)
   {
      document.getElementById(id).style.display = "none";
   }
   else if (document.all)
   {
      document.all[id].style.display = "";
   }
}

function vote(context,pt,who,objectType)
{ 
   var xmlHttp;
   try
   {
      //Firefox
      xmlHttp = new XMLHttpRequest();
   }
   catch (e)
   {
      //Internet Explorer
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
         try
         {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e)
         {
            return false;
         }
      }
    }


    xmlHttp.onreadystatechange = function()
    {
      if(xmlHttp.readyState==4)
      {
         if (  xmlHttp.responseText )
         {
            if (document.getElementById)
         	{
            	document.getElementById("f"+who).innerHTML = xmlHttp.responseText;
            	var d = document.getElementById("f"+who+"-r");
            	if ( d )
            	{
            		d.innerHTML = pt + "pt(s) today";
            	}
         	}
         	else if (xmlHttp.responseText)
         	{
            	document.all["f"+who].innerHTML = xmlHttp.responseText;
            	var d = document.all["f"+who+"-r"];
            	if ( d )
            	{
            		d.innerHTML = pt +"pt(s) today";
            	}
         	}	
         }
      }
    }
    
    xmlHttp.open("GET",context + "/rate?p=" + pt + "&id=" + who + "&t="+objectType,true);
    xmlHttp.send(null);
}

function transpose(context,op,who)
{ 
   var xmlHttp;
   try
   {
      //Firefox
      xmlHttp=new XMLHttpRequest();
   }
   catch (e)
   {
      //Internet Explorer
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
         try
         {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e)
         {
            return false;
         }
      }
    }
    
    xmlHttp.onreadystatechange = function()
    {
      if(xmlHttp.readyState==4)
      {
         if (  xmlHttp.responseText )
         {
             if (document.getElementById)
             {
                document.getElementById("t"+who).innerHTML = 
                
                "<IMG id='image"+who+"' class=thumb HSPACE=4 VSPACE=4 SRC='" + context + "/files/thumbnail/"+who+"?p=small&t=" + new Date() + "'>";
                //document.getElementById("image"+who).src = document.getElementById("image"+who).src;//innerHTML = xmlHttp.responseText;
             }
             else if (xmlHttp.responseText)
             {
                document.all["image"+who].innerHTML = "<IMG id='image"+who+"' class=thumb HSPACE=4 VSPACE=4 SRC='" + context + "/files/thumbnail/"+who+"?p=small&t=" + new Date() + "'>";
             }
         }
      }
    }
    
    xmlHttp.open("GET",context + "/imagetranspose?op=" + op + "&id=" + who,true);
    xmlHttp.send(null);
}

function transpose2(context,op,who)
{ 
   var xmlHttp;
   try
   {
      //Firefox
      xmlHttp=new XMLHttpRequest();
   }
   catch (e)
   {
      //Internet Explorer
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
         try
         {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e)
         {
            return false;
         }
      }
    }
    
    xmlHttp.onreadystatechange = function()
    {
      if(xmlHttp.readyState==4)
      {
         if (  xmlHttp.responseText )
         {
             if (document.getElementById)
             {
                document.getElementById("t"+who).innerHTML = 
                
                "<IMG id='image"+who+"' class=thumb HSPACE=4 VSPACE=4 SRC='" + context + "/sharefiles/thumbnail/"+who+"?p=small&t=" + new Date() + "'>";
                //document.getElementById("image"+who).src = document.getElementById("image"+who).src;//innerHTML = xmlHttp.responseText;
             }
             else if (xmlHttp.responseText)
             {
                document.all["image"+who].innerHTML = "<IMG id='image"+who+"' class=thumb HSPACE=4 VSPACE=4 SRC='" + context + "/sharefiles/thumbnail/"+who+"?p=small&t=" + new Date() + "'>";
             }
         }
      }
    }
    
    xmlHttp.open("GET",context + "/shareimagetranspose?op=" + op + "&id=" + who,true);
    xmlHttp.send(null);
}

function quicksearch(context,handler,q)
{ 
   var xmlHttp;
   try
   {
      //Firefox
      xmlHttp=new XMLHttpRequest();
   }
   catch (e)
   {
      //Internet Explorer
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
         try
         {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e)
         {
            return false;
         }
      }
    }
    
    xmlHttp.onreadystatechange = function()
    {
      if(xmlHttp.readyState==4)
      {
         if (  xmlHttp.responseText )
         {
             if (document.getElementById)
             {
                document.getElementById("sresults").innerHTML = xmlHttp.responseText;
             }
             else if (xmlHttp.responseText)
             {
                document.all["sresults"].innerHTML = xmlHttp.responseText;
             }
         }
      }
    }

    xmlHttp.open("GET",context + "/am/search-" + handler + ".html?q=" + q,true);
    xmlHttp.send(null);
}

function filterData(o,w)
{
	selectedIndex = o.selectedIndex;
	data = filterData.datasets[o.id];
	dataset = data[selectedIndex];
	selectIn = ( document.getElementById ) ? document.getElementById(w) : document.all[w];
	selectIn.options.length = 0;
	for ( i = 0; i < dataset.length; i++ )
	{
		selectIn.options[i] = new Option(dataset[i],dataset[i]);
	}
}
filterData.datasets = new Object();
