// JavaScript Document
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE");
   var version = parseFloat(arVersion[1]);

   if ((version >= 5.5) && (version < 7)) 
   {
      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).toUpperCase() == "PNG") && (img.className!="pngHidden"))
         {
            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 correctHiddenPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE");
   var version = parseFloat(arVersion[1]);

   if ((version >= 5.5) && (version < 7) && (document.body.FILT)) 
   {
      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).toUpperCase() == "PNG") && (img.className=="pngHidden"))
         {
            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 showPopup(popupName){
	var popup=document.getElementById(popupName);
	popup.className=popup.className.replace(/hidden/gi, "visible");
	correctHiddenPNG();
	return false;
}
function hidePopup(popupName){
	var popup=document.getElementById(popupName);
	popup.className=popup.className.replace(/visible/gi, "hidden");
	return false;
	
}

var xmlHttp;
function ajaxFunction()
  {
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
  }

function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};

function submitFeedback(where, formName, popupName){
	var formRef=document.getElementById(formName);
	if (formRef.feedbackMessage.value=='') {alert("Please type a message"); return false;}
	
	var strQuery="";

	var els = formRef.elements;
	for(var no=0;no<els.length;no++){
		strQuery=strQuery+"&"+els[no].name+"="+ encodeURI(""+els[no].value);
	}
	
	ajaxFunction();

	xmlHttp.onreadystatechange=function()
      {
		if(xmlHttp.readyState==4){
        	//x.innerHTML=xmlHttp.responseText;
		}
      }

	if (where.search("=") != -1){
		strURL=where + strQuery;
	}
	else {
		strURL=where + "?" + strQuery;
	}
	
	xmlHttp.open("GET", noCache(strURL),true);		
    xmlHttp.send(null);	

	return hidePopup(popupName);
}


