// JavaScript Document


// Form Submit ... Code

function submitSearch(formname){
	document.forms[formname].submit();
}

// JavaScript Document


function isDigit(c){
	return ((c >= "0") && (c <= "9"))
}  
var dropdowncontent={
 	delaybeforehide: 10, //set delay in milliseconds before content box disappears onMouseout (1000=1 sec)
	disableanchorlink: true, //when user clicks on anchor link, should it be disabled?
	ajaxloadingmsg: "Loading content. Please wait...", 
	ajaxbustcache: true, //Bust cache when fetching pages?

	getposOffset:function(what, offsettype)
	{
		return (what.offsetParent)? what[offsettype]+this.getposOffset(what.offsetParent, offsettype) : what[offsettype]
	},

	isContained:function(m, e)
	{
		var e=window.event || e
		var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
		while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
		if (c==m)
			return true
		else
			return false
	},

	show:function(anchorobj, subobj, e){
		if (!this.isContained(anchorobj, e)){
			var foo = anchorobj.id;
			var beginIndex = (anchorobj.id.length - 1);
			var i = "";
			var loop = "true";
			for(n = beginIndex; n > 0; n--){
				if(loop == "true"){
					if(isDigit(foo.charAt(n)))
						i = foo.charAt(n) + i;
					else
						loop = "false";
				}
			}
			
			if(anchorobj.offsetWidth>50)
			{
			var horizontaloffset=50//calculate user added horizontal offset
			}
			else
			{
				var horizontaloffset=anchorobj.offsetWidth;
			}
			if(anchorobj.offsetHeight>-47)
			{
				var verticaloffset=-35
			}
			else
			{
				var verticaloffset=(subobj.dropposition)? +(anchorobj.offsetHeight) : 0;
			}
			//var verticaloffset=(subobj.dropposition[0]=="top")? -(subobj.offsetHeight-anchorobj.offsetHeight) : -47; //calculate user added vertical offset
			subobj.style.left=this.getposOffset(anchorobj, "offsetLeft") + horizontaloffset + "px"
			subobj.style.top=this.getposOffset(anchorobj, "offsetTop")+verticaloffset+"px"
			//alert(anchorobj.offsetHeight)
			subobj.style.clip=(subobj.dropposition[1]=="top")? "rect(auto auto auto 0)" : "rect(0 auto 0 0)" //hide drop down box initially via clipping
			subobj.style.visibility="visible"
			subobj.startTime=new Date().getTime()
			subobj.contentheight=parseInt(subobj.offsetHeight)
			if (typeof window["hidetimer_"+subobj.id]!="undefined") //clear timer that hides drop down box?
				clearTimeout(window["hidetimer_"+subobj.id])
			this.slideengine(subobj, (subobj.dropposition[1]=="top")? "up" : "down")
		}
		ChangeText(i)
	},

	curveincrement:function(percent){
		return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
	},

	slideengine:function(obj, direction){
		var elapsed=new Date().getTime()-obj.startTime //get time animation has run
		if (elapsed<obj.glidetime){ //if time run is less than specified length
			var distancepercent=(direction=="down")? this.curveincrement(elapsed/obj.glidetime) : 1-this.curveincrement(elapsed/obj.glidetime)
			var currentclip=(distancepercent*obj.contentheight)+"px"
			obj.style.clip=(direction=="down")? "rect(0 auto "+currentclip+" 0)" : "rect("+currentclip+" auto auto 0)"
			window["glidetimer_"+obj.id]=setTimeout(function(){dropdowncontent.slideengine(obj, direction)}, 10)
		}
		else{ //if animation finished
			obj.style.clip="rect(0 auto auto 0)"
		}
	},
	hide:function(activeobj, subobj, e){
		if (!dropdowncontent.isContained(activeobj, e)){
			window["hidetimer_"+subobj.id]=setTimeout(function(){
				subobj.style.visibility="hidden"
				subobj.style.left=subobj.style.top=0
				clearTimeout(window["glidetimer_"+subobj.id])
			}, dropdowncontent.delaybeforehide)
		}
	},
 init:function(anchoridA, pos, glidetime)
 {
	 	for(var i =0; i<anchoridA.length;i++)
		{
			var anchorid = anchoridA[i];
			
			var anchorobj=document.getElementById(anchorid)
			var subobj=document.getElementById(anchorobj.getAttribute("rel"))
			var subobjsource=anchorobj.getAttribute("rev")
			if (subobjsource!=null && subobjsource!="")
				this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel"))
			subobj.dropposition=pos.split("-")
			subobj.glidetime=glidetime || 1000
			subobj.style.left=subobj.style.top=0
			anchorobj.onmouseover=function(e){dropdowncontent.show(this, subobj, e);}
			anchorobj.onmouseout=function(e){dropdowncontent.hide(subobj, subobj, e)}
			if (this.disableanchorlink) anchorobj.onclick=function(){}
			subobj.onmouseout=function(e){dropdowncontent.hide(this, subobj, e)}
		}
 }
}

function ChangeText(i){
	document.getElementById("popupContent").innerHTML = document.getElementById("hid" + i).innerHTML;
}



// below script for popup window in library_results_tr page.. End here............. 

/* COMMENTED OUT BY PABLO ON MARCH 10

/////////////////////////////////////////////// PNG Fix Starts here /////////

function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
   
   function CorrectCurrentPNG(argId,argNewSrc) 
   {

	     var img = document.getElementById(argId);
		 img.src=argNewSrc;
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML

	     
   }
if(window.attachEvent)
	window.attachEvent("onload", correctPNG);

/////////////////////////////////////////////// PNG Fix End here /////////

*/

// Script used for Solutions Selector Page starts here and created by Amit Kumar

function SwitchSolutionBox(id) 
{
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.solutionBox = document.getElementById(id); // ID of the solutionBox element
	this.boxAll = this.solutionBox.getElementsByTagName("div"); // div used as container for solutionBox
	this.boxOpeningSpeed = 100; // box sliding speed(Iy should not be less then 1)
	this.oneSmOnly = true; // Expanded one solutionBox at a time
}
SwitchSolutionBox.prototype.init = function() 
{
	var mainInstance = this;
	for (var i = 0; i < this.boxAll.length; i++)
		this.boxAll[i].getElementsByTagName("span")[0].onclick = function() 
		{
			mainInstance.toggleMenu(this.parentNode);
		}	
}
SwitchSolutionBox.prototype.toggleMenu = function(submenu) 
{
	if (submenu.className == "solutionSelectorclosed")
		this.openMenu(submenu);
	else
		this.closeMenu(submenu);
}
SwitchSolutionBox.prototype.openMenu = function(submenu) 
{
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.boxOpeningSpeed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() 
		{
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else 
		{
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
		}
	}, 100);
	this.closeOthers(submenu);
}
SwitchSolutionBox.prototype.closeMenu = function(submenu) 
{
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.boxOpeningSpeed * submenu.getElementsByTagName("table").length);
	var mainInstance = this;
	var intId = setInterval(function() 
		{
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "solutionSelectorclosed";
		}
	}, 100);
}
SwitchSolutionBox.prototype.closeOthers = function(submenu) 
{
	if (this.oneSmOnly) 
	{
		for (var i = 0; i < this.boxAll.length; i++)
			if (this.boxAll[i] != submenu && this.boxAll[i].className != "solutionSelectorclosed")
				this.closeMenu(this.boxAll[i]);
	}
}
// Script used for Solutions Selector Page ends here and created by Amit Kumar








// below script for popup window in Innovation award page Starts here............. 

var dropdowncontentnew={
 	delaybeforehide: 1, //set delay in milliseconds before content box disappears onMouseout (1000=1 sec)
	disableanchorlink: true, //when user clicks on anchor link, should it be disabled?

	getposOffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getposOffset(what.offsetParent, offsettype) : what[offsettype]
	},

	isContained:function(m, e){
		var e=window.event || e
		var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
		while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
		if (c==m)
			return true
		else
			return false
	},

	show:function(anchorobj, subobj, e)
	{
		if (!this.isContained(anchorobj, e))
		{
			var tmpX = 0;
			var tmpY = 0;
	
			if (!e) var e = window.event;
	
			if (e.pageX || e.pageY)
			{
				tmpX = e.pageX;
				tmpY = e.pageY;
			}
			else if (e.clientX || e.clientY)
			{
				tmpX = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
				tmpY = e.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;
			}

			subobj.style.left = tmpX+0+"px";
			subobj.style.top = tmpY-38+"px";
			subobj.style.visibility="visible"
			subobj.startTime = new Date().getTime()
			subobj.contentheight=parseInt(subobj.offsetHeight)
			
			if (typeof window["hidetimer_"+subobj.id]!="undefined") //clear timer that hides drop down box?
				clearTimeout(window["hidetimer_"+subobj.id])
			this.slideengine(subobj, (subobj.dropposition[1]=="top")? "up" : "down")			
		}
	},

	curveincrement:function(percent){
		return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
	},

	slideengine:function(obj, direction){
		var elapsed=new Date().getTime()-obj.startTime //get time animation has run
		if (elapsed<obj.glidetime){ //if time run is less than specified length
			var distancepercent=(direction=="down")? this.curveincrement(elapsed/obj.glidetime) : 1-this.curveincrement(elapsed/obj.glidetime)
			var currentclip=(distancepercent*obj.contentheight)+"px"
			obj.style.clip=(direction=="down")? "rect(0 auto "+currentclip+" 0)" : "rect("+currentclip+" auto auto 0)"
			window["glidetimer_"+obj.id]=setTimeout(function(){dropdowncontentnew.slideengine(obj, direction)}, 10)
		}
		else{ //if animation finished
			obj.style.clip="rect(0 auto auto 0)"
		}
	},

	hide:function(activeobj, subobj, e){
		if (!dropdowncontentnew.isContained(activeobj, e)){
			window["hidetimer_"+subobj.id]=setTimeout(function(){
				subobj.style.visibility="hidden"
				subobj.style.left=subobj.style.top=0
				clearTimeout(window["glidetimer_"+subobj.id])
			}, dropdowncontentnew.delaybeforehide)
		}
	},

 	init:function(anchorid, pos, glidetime){
		var anchorobj=document.getElementById(anchorid)
		var subobj=document.getElementById(anchorobj.getAttribute("rel"))
		var subobjsource=anchorobj.getAttribute("rev")
		if (subobjsource!=null && subobjsource!="")
			this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel"))
		subobj.dropposition=pos.split("-")
		subobj.glidetime=glidetime || 1000
		subobj.style.left=subobj.style.top=0
		anchorobj.onmouseover=function(e){dropdowncontentnew.show(this, subobj, e)}
		anchorobj.onmouseout=function(e){dropdowncontentnew.hide(subobj, subobj, e)}
		if (this.disableanchorlink) anchorobj.onclick=function(){return false}
		subobj.onmouseout=function(e){dropdowncontentnew.hide(this, subobj, e)}	
		
		// Capture the mouse move position
		if (document.layers) document.captureEvents(Event.MOUSEMOVE);
	}
}
// below script for popup window in Innovation award page .. End here............. 


// below script for expand-contract functionality in Data Domain page .. start here ............. 

function switchMenuDom(obj,obj01) {
	var el = document.getElementById(obj);
	var im = document.getElementById(obj01);
	if ( el.style.display != "block" ) {
		 el.style.display = 'block';
		 im.src="http://media.netapp.com/designimages/minus-6x5.gif";
		
	}
	else {
		el.style.display = 'none';
		im.src="http://media.netapp.com/designimages/plus-6x5.gif";
		
	}
	
}


// below script for expand-contract functionality in Data Domain page .. start here ............. 


