var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
var transitionState = 0;
function hidebox(){
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	
	if (ns6){
		document.showimage.visibility="hide"
	}
	else if (ie4){
		crossobj.filters[0].Apply();
		if (transitionState == '0')
			transitionState = 1;
		else
			transitionState = 0;
		crossobj.style.visibility="hidden"
		crossobj.filters[0].Play();	
	}
	else if (ns4){
		crossobj.filters[0].Apply();
		if (transitionState == '0')
			transitionState = 1;
		else
			transitionState = 0;
		document.showimage.visibility="hide"
		crossobj.filters[0].Play();
	}
}

function showhidebox(h){
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	//loginobj =ns6? document.getElementById("loginbox") : document.all.showimage

	xPos = document.getElementById("loginbox").offsetLeft; 
	tempEl = document.getElementById("loginbox").offsetParent; 
	while (tempEl != null)  
    	{ 
          		xPos += tempEl.offsetLeft; 
          		tempEl = tempEl.offsetParent; 
      	} 
    
	yPos = document.getElementById("loginbox").offsetTop; 
	tempEl = document.getElementById("loginbox").offsetParent; 
	while (tempEl != null)  
    	{ 
          		yPos += tempEl.offsetTop; 
          		tempEl = tempEl.offsetParent; 
      	} 
	//to place the login box to the destinated position
	crossobj.style.left = (xPos - 139) + "px";
	crossobj.style.top = (yPos + 0) + "px";
	// if firefox
	if (ns6){
		crossobj.style.visibility = h
	}
	// else if IE 
	else if (ie4){
		crossobj.filters[0].Apply();
		if (h=='hidden') // if to hide box, then change the motion to move forward.
			crossobj.filters[0].motion= "forward"
		else // if to show box, then change the motion to move backward.
			crossobj.filters[0].motion= "reverse"

		if (transitionState == '0')
			transitionState = 1;
		else
			transitionState = 0;
		crossobj.style.visibility = h
		crossobj.filters[0].Play();	
	}
	else if (ns4){
		crossobj.filters[0].Apply();
		if (transitionState == '0')
			transitionState = 1;
		else
			transitionState = 0;
		document.showimage.visibility = h
		crossobj.filters[0].Play();
	}	
	
}

function validateField(objForm)
{
	var srch = trimStr(objForm.Search.value);
	if (srch.length < 2)
	{
		alert ('Please enter a keyword with at least 2 characters to search');
		return false;	
	} 
	else
	{
		return true;
	}
}

function trimStr(sStr)
{
		var retStr   = "" ;
		var lLoop = true;
		var first = -1;
		var last  = sStr.length;
		for(var i=0; i < sStr.length && lLoop; i++){
			if(sStr.charAt(i) != " ") lLoop = false;
			else	first = i;
		}
		lLoop = true;
		for(var i=sStr.length-1; i>= 0 && lLoop; i--){
			if(sStr.charAt(i) != " ") lLoop = false;
			else	last = i;
		}
		for(var i=first+1; i<last; i++)
			retStr += sStr.charAt(i);
		return (retStr);
}