
var divName = "theLayer";
var globalDiv;
var deviationX= 1;

function searchDev()
{

	createNewDiv(130, 56, '<b> &nbsp;  Select Collection</b>&nbsp;&nbsp;<input type="image" src="/images/close.gif" width="16" height="14" alt="" border="0" onclick ="showDiv(false)"></br></br>');
	globalDiv.style.left = 850 + "px";
    globalDiv.style.top =  100 + "px";
  
    
    var textValue = document.getElementById("researchSearchFor").value
    var searchProduct = document.getElementById("searchProductValue")
    var tableDisplay = document.getElementById("collectionTable")
    var subNewTable = searchProduct.cloneNode(true);
	document.getElementById("SearchForDiv").value =textValue
	subNewTable.removeAttribute("style");
	globalDiv.appendChild(subNewTable);
	showDiv(true)


}


function submitCollectionForm(value)
{


	var text =document.getElementById("researchSearchFor").value
	if (text == " Powered by Google")
		{
		
		}
		
		else
		
		{
		
			document.getElementById("searchProductType").value = value
			document.form2.submit()
			
		}
	
}


function createNewDiv(width, height, text)

 {    
    if (!globalDiv)
     
     {
        var newDiv = document.createElement("div");
        newDiv.setAttribute("id", divName);
        newDiv.id = divName;        
        document.body.appendChild(newDiv);		
	 }
    
	
	if (globalDiv != null)
	{
		while (globalDiv.childNodes.length > 0)
		 {
		    globalDiv.removeChild(globalDiv.childNodes[0]);
		 }  
	}
	 
	 var contentDiv = document.createElement("div");	
	 contentDiv.innerHTML = text 		
	 divFlag = true;        
	 globalDiv = document.getElementById(divName)
     

	globalDiv.innerHTML = contentDiv.innerHTML
	globalDiv.style.background = "#E1E5E4";
    globalDiv.style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
    globalDiv.style.padding = "2px";
    globalDiv.style.border = "1px solid #808080";
    globalDiv.style.fontSize = "11px";                          
    globalDiv.style.position = "absolute";
    globalDiv.style.overflow = "hidden"; 
    
    var browserName=navigator.appName; 
    
    if (browserName=="Microsoft Internet Explorer")
	{ 
        isIE = true;
         
    }
    else
	{ 
        isIE = false; 
    }

    if(parseInt(deviationX) != 0)
	{
        globalDiv.style.left = posX + 5+ parseInt(deviationX) + "px";
        globalDiv.style.top = posY + 10 + "px";
    }
    else 
	{             
        globalDiv.style.left = posX + "px";
        globalDiv.style.top =  posY + "px";        
    }
    

    globalDiv.style.width = parseInt(width) + "px";
    globalDiv.style.height = parseInt(height) + "px";
   
}


var isIE ; // Detect if the browser is IE or not. If it is not IE, we assume that the browser is FireFox.
var posX = 0 // Temporary variables to hold mouse x pos
var posY = 0 // Temporary variables to hold mouse y pos


function MouseDown()
{
 
	var browserName=navigator.appName;
 
	if (browserName=="Microsoft Internet Explorer")
	{ 
	 isIE = true;
	}
	else
	{ 
	 isIE = false; 
	}

	// If Firefox -- that is, !IE -- then set up for mouse capture
	//if (!IE) document.captureEvents(Event.MOUSEMOVE)
	if (!isIE) document.captureEvents(Event.MOUSEDOWN)

	// Set-up to use getMouseXY function onMouseMove //document.onmousedown = getMouseXY; To capture click on the document 
	var x = document.getElementsByTagName("a");

	for(i = 0; i < x.length; i++)
	{
	 x[i].onmousedown = getMouseXY;
	} 


}

// Main function to retrieve mouse x-y pos.s
function getMouseXY(event) 
{
    var targ;
 
 if (!isIE) 
	{
	 targ = event.target;
	} 
 else
	{
	 targ = window.event.srcElement;
	}

 if (isIE) // grab the x-y pos.s if browser is IE
	{ 
	 posX = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
	 posY = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;

	} 
 else // grab the x-y pos.s if browser is Firefox
	{  
	 posX = event.pageX;
	 posY = event.pageY;
	}  

 // catch possible negative values in NS4
 if (posX < 0){posX = 0}
 if (posY < 0){posY = 0}  

 return true
}


function showDiv(show) {
    var div = document.getElementById(divName);

    if(show == true) 
		{    
		    div.style.visibility = "visible";
		    divFlag = false;        
		}
    else 
		{
		    div.style.visibility = "hidden";
		    
		}
}

function closeDiv(status)
 {
	if(divFlag == true)
		{
			showDiv(true);
		}
	else
		{
		    showDiv(false);
		}
}


function submitForm(form)

	{

		
		var value = document.getElementById("researchSearchFor").value
		
		if (value==' Powered by Google')
			{
				
				return false;
			
			}
			
		else
			{
				
				return false;
			} 
		
	}


function blurResearchFinder()

	{
		var value = document.getElementById("researchSearchFor").value
		if (value.length >0 )
			{
			}
		else
			{
				var Googlevalue = document.getElementById("researchSearchFor")
				
				Googlevalue.className ="google"
				Googlevalue.setAttribute('class','google')
				document.getElementById("researchSearchFor").value =" Powered by Google"
			}
		
	}
	
	
function clickResearchFinder()

	{
		var Googlevalue = document.getElementById("researchSearchFor")
		var value = document.getElementById("researchSearchFor").value
		
		if (value==" Powered by Google")
			{
				document.getElementById("researchSearchFor").value =""
				Googlevalue.className ="";
				Googlevalue.removeAttribute("class")
				
				
			}
		else
			{
				//alert(value);
			}
	}
