//(C) Stephen Daly
// www.stephendaly.org
// Date: 11/3/2008

// Checks if the browsers is IE or another.
// document.all will return true or false depending if its IE
// If its not IE then it adds the mouse event
if (!document.all)
document.captureEvents(Event.MOUSEMOVE)

// On the move of the mouse, it will call the function getPosition
document.onmousemove = getPosition;

// These varibles will be used to store the position of the mouse
var X = 0
var Y = 0

// This is the function that will set the position in the above varibles 
function getPosition(args) 
{
  // Gets IE browser position
  if (document.all) 
  {
    X = event.clientX + document.body.scrollLeft;
    Y = event.clientY + document.body.scrollTop;
  }
  
  // Gets position for other browsers
  else 
  {  
    X = args.pageX
    Y = args.pageY
  }  
}
function backgroundFilter()
{
    var div;
    
    if(document.getElementById)
    // Standard way to get element
    div = document.getElementById('backgroundFilter'); 
    else if(document.all) 
    // Get the element in old IE's 
    div = document.all['backgroundFilter']; 
    
    // if the style.display value is blank we try to check it out here 
    if(div.style.display==''&&div.offsetWidth!=undefined&&div.offsetHeight!=undefined)
    {
        div.style.display = (div.offsetWidth!=0&&div.offsetHeight!=0)?'block':'none'; 
    }
    
    // If the background is hidden ('none') then it will display it ('block').
    // If the background is displayed ('block') then it will hide it ('none').
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';
}

function popUpAuthor()
{

    var div;
document.getElementById("popupWindow").style.visibility ="visible";
    if(document.getElementById)
    // Standard way to get element
    div = document.getElementById('popupWindow'); 
    else if(document.all) 
    // Get the element in old IE's 
    div = document.all['popupWindow']; 
 //div = document.all['windowcontent']; 
   

    // if the style.display value is blank we try to check it out here 
    if(div.style.display==''&&div.offsetWidth!=undefined&&div.offsetHeight!=undefined)
    {
        div.style.display = (div.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; 
    }
    // If the PopUp is hidden ('none') then it will display it ('block').
    // If the PopUp is displayed ('block') then it will hide it ('none').
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';
    
    // Off-sets the X position by 15px
   if (document.all) 
  {
    X = event.clientX + document.body.scrollLeft;
    Y = event.clientY + document.body.scrollTop;
  }
  
  // Gets position for other browsers
  else 
  {  
    X = args.pageX
    Y = args.pageY
  }  
      

    // Sets the position of the DIV
    div.style.left = X+'px';
    div.style.top = Y+'px';
       window.setTimeout("closeDiv();", 5000);
}
function popUp(attribute,Author)
{
var mytest = "";
document.getElementById("popupWindow").style.visibility ="visible";
if(searchattribute.length==0) return;
        else
        {
             for(var j=0;j<searchattribute.length;j++) 
		     {
		        if (searchattribute[j].id ==attribute)
		        {
                    if(searchattribute[j].AuthorImage=="images/Author/")
		            {
		                var author='<table><tr><td align="left" width="30%"><img height="100" width="100" src="images/author/nouser.jpg" alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div> </font></td></tr></table>';
		                var desc=searchattribute[j].AuthorDescription;
		                $('popupBody').innerHTML=author;
		            }
                    else if(searchattribute[j].AuthorImage=="images/Editor/")
                    {
	                      var author='<table><tr><td align="left" width="30%"><img height="100" width="100" src="images/author/nouser.jpg" 				alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div> 				</font></td></tr></table>';
	                      var desc=searchattribute[j].AuthorDescription;
	                      $('popupBody').innerHTML=author;
	                }
		            else
		            {
		                var author='<table><tr><td align="left" width="30%"><img height="100" width="100" src="'+ searchattribute[j].AuthorImage +'" alt="Author Image" /></td><td align="left" valign="top" width="70%"><font size="2"> <div id="LoadDescription" ></div> </font></td></tr></table>';
                        var desc=searchattribute[j].AuthorDescription;  
                        $('popupBody').innerHTML=author;
                        mytest = "test";
                    
                    }
                }
             }
          }
           
    var div;
    if (mytest =="")
    {
        var author='<tr><td align="left" width="30%"><img height="100" width="100" src="images/author/nouser.jpg" alt="Author Image" /></td><td colspan="2" align="left" valign="top" width="70%"><font size="2"></font></td></tr>';
        $('popupBody').innerHTML=author;
    }    
       
    var div;
    if (mytest =="")
    {
         var author='<tr><td align="left" width="30%"><img height="100" width="100" src="images/author/nouser.jpg" alt="Author Image" /></td><td colspan="2" align="left" valign="top" width="70%"><font size="2"></font></td></tr>';

         $('popupBody').innerHTML=author;
          
    }    

    if(document.getElementById)
    // Standard way to get element
    div = document.getElementById('popupWindow'); 
    else if(document.all) 
    div = document.all['popupWindow']; 
   if (Author==1)
	{
         clientSideInclude("LoadDescription", "admin/PageContent/Author/"+ attribute +"/"+ desc);
    }
    else if (Author==3)
	{
         
       
          clientSideInclude("LoadDescription","admin/PageContent/Editor/"+ attribute +"/"+ desc);
    }
    if(div.style.display==''&&div.offsetWidth!=undefined&&div.offsetHeight!=undefined)
    {
        div.style.display = (div.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; 
    }
    // If the PopUp is hidden ('none') then it will display it ('block').
    // If the PopUp is displayed ('block') then it will hide it ('none').
    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block';

  if (document.all) 
  {
    X = event.clientX + document.body.scrollLeft;
    Y = event.clientY + document.body.scrollTop;
  }
  
  // Gets position for other browsers
  else 
  {  
    X = args.pageX
    Y = args.pageY
  }  

    // Off-sets the X position by 15px
    // Sets the position of the DIV
    div.style.left = X+'px';
    div.style.top = Y+'px';
window.setTimeout("closeDiv();", 5000);


}
function closeDiv(){
document.getElementById("popupWindow").style.visibility = "hidden";

}
function clientSideInclude(id, url) 
{

  var req = false;
  if (window.XMLHttpRequest) 
  {
    try 
    {
      req = new XMLHttpRequest();
    } catch (e) 
    {
      req = false;
    }
  } else if (window.ActiveXObject)
   {
    try 
    {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) 
    {
      try 
      {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) 
      {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);


 if (!element)
 {
  return;
 }
  if (req) 
  {
    req.open('GET', url, false);
    req.send(null);
    if(req.status=="200")
    {   
    element.innerHTML = req.responseText;
    }
    else
    {
        url="admin/PageContent/Products/Empty.html";
        req.open('GET',url,false);
        req.send(null);
        element.innerHTML = req.responseText;
    }
  } 
  else 
  {
    element.innerHTML =
   "Sorry, your browser does not support " +
    "XMLHTTPRequest objects. This page requires " +
    "Internet Explorer 5 or better for Windows, " +
    "or Firefox for any system, or Safari. Other " +
    "compatible browsers may also exist.";
  }
}