var images = new Array();
var first = 0;
var last = 0;
var current = 1;
var curentOfAll = '';
var mypreloadImage=new Image();
function checkForm(form)
  {
    // validation fails if the input is blank
  //  var itemsChecked = checkArray(form, "data[]");

     if(form.name.value == '') {
     alert("Error: Name is empty.");
  
      return false;
    }
    
    if(form.comment.value == '') {
     alert("Error: Comment is empty.");
     
      return false;
    }

    return true;
  }
  
function trimAll(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function searchText( search_text, element_id ){    
    search_text = trimAll(search_text);
    
    if( search_text == '' ){
        document.getElementById(element_id).disabled = true;    
    }
    else {
        document.getElementById(element_id).disabled = false;
    }
}
  
function showtab(active, passive, activeLink, passiveLink,active_class,passive_class) {
	document.getElementById(active).style.display='';
	document.getElementById(passive).style.display='none';
	
	document.getElementById(activeLink).className=active_class; 
	document.getElementById(passiveLink).className=passive_class; 
	return false;
	
	/*//lets hide everything
	document.getElementById('tab1').style.display='none';
	document.getElementById('tab2').style.display='none';
	document.getElementById('tab3').style.display='none';
	document.getElementById('tab4').style.display='none';
	document.getElementById('t'+'t1').className=''; 
	document.getElementById('t'+'t2').className=''; 
	document.getElementById('t'+'t3').className=''; 
	document.getElementById('t'+'t4').className=''; 
	//lets show active
	document.getElementById(ative).style.display=''; 
	document.getElementById('t'+ative).className='active'; 
	return false;*/
}

function resize(img, name) { 
img.width = getImgWidth(img.src)
if(img.width > 211) { 
  //img.style.height = parseInt(img.height - (img.width - 211 ) * (img.width / img.height)) + "px"; 
  //img.style.width = "211px"; 
  //document.images['show'].width = parseInt(img.height - (img.width - 211 ) * (img.width / img.height)); 
  document.images[name].width = 211;
} 
img.height = getImgHeight(img.src)
if(img.height > 160) { 
  //img.style.height = parseInt(img.height - (img.width - 211 ) * (img.width / img.height)) + "px"; 
  //img.style.width = "211px"; 
  document.images[name].height = 160;
  //document.images['show'].width = parseInt(img.width - (img.height - 160 ) * (img.height / img.width)); ;
}
img.style.position = "static"; 
img.style.visibility = "visible"; 
}

function getImgHeight(imgSrc){
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	return height;
}
function getImgWidth(imgSrc){
	var newImg = new Image();
	newImg.src = imgSrc;
	var width = newImg.width;
	return width;
}

var pic = null
var popImg = null  // use this when referring to pop-up image
var picTitle = null
var imgCount = 0
var imgWinName = "popImg"

function openPopImg(picName, windowTitle, windowWidth, windowHeight){
  closePopImg()
  picTitle = windowTitle;
  imgWinName = "popImg" + imgCount++ //unique name for each pop-up window
  popImg = window.open(picName, "",
           "toolbar=no,scrollbars=no,resizable=no,width=" 
           + (parseInt(windowWidth)+30)  + ",height=" 
           + (parseInt(windowHeight)+20)) ;
	   
  	if(windowWidth ==0)
		popImg.resizeBy(700, 500);
	popImg.document.write('<html><head><title>'+windowTitle+'</title> <SCRIPT language="JavaScript"> pic1= new Image();  pic1.src="'+picName+'"; </SCRIPT> </head><body>') ;	
	popImg.document.write('<a href="http://www.pcthreat.com/download-spyhunter.html"><img style="border:0 px;" src="'+picName+'" alt="" /></a>') ;
	popImg.document.write('</body></html>') ;	
  }
function closePopImg(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popImg != null) if(!popImg.closed) popImg.close() 
  }
function setStatus(msg){
  status = msg;
  return true;
}


function getArray(img_array, first1, last1){
  first = first1;
  images = img_array;
  last = last1;
  current=1;
  if(last>1)
	setCurentOfAll();
}
function nextImg(img_name, dir, fullPath){
  if(current < last){
    current++;
    setCurentOfAll();
    document[img_name].src = dir + images[current-1];
    document['prev'].src = fullPath + 'left.gif';
  }
  if(current >= last){
    document['next'].src = fullPath + 'right_empty.gif';
  }
  
} 
function prevImg(img_name, dir, fullPath){
  if(current > first+1){
    current--;
    setCurentOfAll();
    document[img_name].src = dir + images[current-1];
    document['next'].src = fullPath + 'right.gif';
  }
  if(current <= first+1){
    document['prev'].src = fullPath + 'left_empty.gif';
  }
  
}
function setCurentOfAll(){
  curentOfAll = (current) + ' of '+ last+' ';
  document.getElementById('blabla').innerHTML = curentOfAll;
}

