var links = document.getElementsByTagName('a');

for (var i = 0; i < links.length; i++)
	if (links[i].className == 'dpthumb')
	{
		var img = links[i].getElementsByTagName('img')[0];		
		img.state = 'small';
		img.smallSrc = img.getAttribute('src');
		img.alt = img.getAttribute('alt');
		img.smallWidth = parseInt(img.getAttribute('width'));
		img.smallHeight = parseInt(img.getAttribute('height'));
		img.largeSrc = img.getAttribute('src');
		img.largeWidth = '50';
		img.largeHeight = '50';
		img.ratio = img.smallHeight / img.smallWidth;
		links[i].onmouseover = scale;
		links[i].onmouseout = scale;
	}else if (links[i].className == 'S_dpthumb')
	{
		var img = links[i].getElementsByTagName('img')[0];		
		img.state = 'small';
		img.smallSrc = img.getAttribute('src');
		img.alt = img.getAttribute('alt');
		img.smallWidth = parseInt(img.getAttribute('width'));
		img.smallHeight = parseInt(img.getAttribute('height'));
		img.largeSrc = img.getAttribute('src');
		img.largeWidth = '50';
		img.largeHeight = '50';
		img.ratio = img.smallHeight / img.smallWidth;
		links[i].onmouseover = S_scale;
		links[i].onmouseout = S_scale;
	}
	
function scale()
{
	var img = this.getElementsByTagName('img')[0];	
	var DCid = img.alt;
	
	img.src = img.smallSrc;
	
	if (! img.preloaded)
	{
		img.preloaded = new Image();
		img.preloaded.src = img.largeSrc;
	}

	var interval = window.setInterval(scaleStep, 10);
	return false;
	
	function scaleStep()
	{
		var step = 10;
		var width = parseInt(img.getAttribute('width'));
		var height = parseInt(img.getAttribute('height'));
		
		if (img.state == 'small')
		{
		updateDPinfo(DCid);
			width += step;
			height += Math.floor(step * img.ratio);
			
			img.setAttribute('width', width);
			img.setAttribute('height', height);
			
			if (width > img.largeWidth - step)
			{
				img.setAttribute('width', img.largeWidth);
				img.setAttribute('height', img.largeHeight);
				img.setAttribute('src', img.largeSrc);
				window.clearInterval(interval);
				img.state = 'large';
			}
		}
		else
		{
		
		document.getElementById('DPinfo').innerHTML = "";
			width -= step;
			height -= Math.floor(step * img.ratio);

			img.setAttribute('width', width);
			img.setAttribute('height', height);
			
			if (width < img.smallWidth + step)
			{
				img.setAttribute('width', img.smallWidth);
				img.setAttribute('height', img.smallHeight);
				img.src = img.smallSrc;
				window.clearInterval(interval);
				img.state = 'small';
			}
		}
	}			
}



function S_scale()
{
	var img = this.getElementsByTagName('img')[0];	
	var DCid = img.alt;
	
	img.src = img.smallSrc;
	
	if (! img.preloaded)
	{
		img.preloaded = new Image();
		img.preloaded.src = img.largeSrc;
	}

	var interval = window.setInterval(scaleStep, 10);
	return false;
	
	function scaleStep()
	{
		var step = 10;
		var width = parseInt(img.getAttribute('width'));
		var height = parseInt(img.getAttribute('height'));
		
		if (img.state == 'small')
		{
		updateS_DPinfo(DCid);
			width += step;
			height += Math.floor(step * img.ratio);
			
			img.setAttribute('width', width);
			img.setAttribute('height', height);
			
			if (width > img.largeWidth - step)
			{
				img.setAttribute('width', img.largeWidth);
				img.setAttribute('height', img.largeHeight);
				img.setAttribute('src', img.largeSrc);
				window.clearInterval(interval);
				img.state = 'large';
			}
		}
		else
		{
		
		document.getElementById('DPinfo').innerHTML = "";
			width -= step;
			height -= Math.floor(step * img.ratio);

			img.setAttribute('width', width);
			img.setAttribute('height', height);
			
			if (width < img.smallWidth + step)
			{
				img.setAttribute('width', img.smallWidth);
				img.setAttribute('height', img.smallHeight);
				img.src = img.smallSrc;
				window.clearInterval(interval);
				img.state = 'small';
			}
		}
	}			
}




function browseItem(list,element,level){  // usage <a href = "#" onclick="browseItem('categories','cat_list','1'); " >

//update page elements  getInfo.php?flv='+ video +'&return=all
get_item_info('http://www.hightechhigh.org/dc/browser.php?find='+list+'&level='+level+'',element,'<div class ="spinner" align ="center"> <br><br><br><br><br><br><h1><img src = "spinner.gif"></h1></div>');

}


function updateComments(element,a_reqID){  // usage <a href = "#" onclick="browseItem('categories','cat_list','1'); " >

//update page elements  getInfo.php?flv='+ video +'&return=all
get_item_info('http://www.hightechhigh.org/dc/getInfo.php?a_reqID='+a_reqID+'',element,'<div class ="spinner" align ="center"> <br><h1><img src = "spinner.gif"></h1></div>');

}

function get_item_info(url, pageElement,callMessage) {
     document.getElementById(pageElement).innerHTML = callMessage;
     try {
     req = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
     req.onreadystatechange = function() {responseDC(pageElement);};
     req.open("GET",url,true);
     req.send(null);
  }

function responseDC(pageElement) {
   var output = '';
   if(req.readyState == 4) {
      if(req.status == 200) {
         output = req.responseText;
         SPLIToutput = output.split("|");
         document.getElementById(pageElement).innerHTML = SPLIToutput[0];
         }
      }
  }
  
  
  
  
var xmlHttp

function showResult(str)
{
if (str.length==0)
 { 
 document.getElementById("results").innerHTML="";
 return
 }

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 

var url="browser.php"

url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("results").innerHTML=xmlHttp.responseText;
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function toggleDisplay(target) {

	if (document.getElementById){
		var togglin = document.getElementById( target );
		if(togglin.style.display == "inline"){
			togglin.style.display = "none";
		}else{
			togglin.style.display = "inline";
		}
	}
}
