var panelID = "p1"
var numDiv = 8
var numRows = 2
var tabsPerRow = 4
var numLocations = numRows * tabsPerRow
var tabWidth = 120
var tabHeight = 30
var vOffset = 6
var hOffset = 40
var divLocation = new Array(numLocations)
var newLocation = new Array(numLocations)
   
for(var i=0; i<numLocations; ++i) {
 divLocation[i] = i
 newLocation[i] = i
}

function changeCursor(n)
{
	document.getElementById("p1tab"+n).style.cursor='hand';
}

function getDiv(s,i) {
 var div
 if(navigator.appName == "Microsoft Internet Explorer"
   && navigator.appVersion.charAt(0) < 5)
  div = document.all.item(panelID+s+i)
 else div = document.getElementById(panelID+s+i)
 return div
}
function setZIndex(div, zIndex) {
 div.style.zIndex = zIndex
}
function getLocation(i) {
 return divLocation[i]
}
function setLocation(i, j) {
 divLocation[i] = j
}
function getNewLocation(i) {
 return newLocation[i]
}
function setNewLocation(i, j) {
 newLocation[i] = j
}
function updatePosition(div, newPos) {
 div.style.top = (numRows-(Math.floor(newPos/tabsPerRow) + 1)) * (tabHeight-vOffset)
 div.style.left = (newPos % tabsPerRow) * tabWidth +
  (hOffset * (Math.floor(newPos / tabsPerRow)))
}
   
function selectTab(n,host) {
	var dt = new Date();
	var str = dt.getTime();
	var divStr="plpanel";
	if (n==''){
		n=0;
	}
	for (var i=0; i<=5; i++)
	{
		if (i==n){
			document.getElementById("plpanel"+n).style.display='inline';
			if ( n == 0 ){
					//contactus.txtName.focus();
					document.getElementById("txtName").focus();
			}
			else if ( n == 1 ){
					document.getElementById("txtFeedComment").focus();
			}
			else if ( n == 2 ){
					document.getElementById("txtReferName").focus();
			}

			
			
		}else{
			document.getElementById("plpanel"+i).style.display='none';
		}
	}
if(n<3){
	document.getElementById("captchaImgTab"+n).src="";	
	document.getElementById("captchaImgTab"+n).src=host+'extras/CaptchaSecurityImages.php?stTime='+str ;
}

//alert(document.getElementById("captchaImgTab"+n).src);

//alert(document.getElementById("captchaImgTab"+n).src);

//alert(document.getElementById("captchaImgTab"+n).id);

 // n is the ID of the division that was clicked
 // firstTab is the location of the first tab in the selected row
/* var firstTab = Math.floor(getLocation(n) / tabsPerRow) * tabsPerRow
 // newLoc is its new location
 for(var i=0; i<numDiv; ++i) {
   // loc is the current location of the tab
   var loc = getLocation(i)
   // If in the selected row
   if(loc >= firstTab && loc < (firstTab + tabsPerRow)) setNewLocation(i, loc - 
   firstTab)
   else if(loc < tabsPerRow) setNewLocation(i,firstTab+(loc % tabsPerRow))
   else setNewLocation(i, loc)
 }
 // Set tab positions & zIndex
 // Update location
 /*
 for(var i=0; i<numDiv; ++i) {
  var div = getDiv("tab",i)
  var loc = getNewLocation(i)
  updatePosition(div, loc)
  if(i == n) setZIndex(div, numLocations +1)
  else setZIndex(div,numLocations - loc)
  div = getDiv("panel",i)
  if(i == n) setZIndex(div, numLocations +1)
  else setZIndex(div, numLocations - loc)
  setLocation(i, loc)
 }*/
}

