var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
 if(isdrag) {
   dobj.style.left = nn6 ? (tx + e.clientX - x) + "px" : (tx + event.clientX - x) + "px";
   dobj.style.top  = nn6 ? (ty + e.clientY - y) + "px" : (ty + event.clientY - y) + "px";

   return false;
 }
}

function selectmouse( e ) {
   var fobj       = nn6 ? e.target : event.srcElement;
   var topelement = nn6 ?  "HTML"  :  "BODY" ;
   while (fobj.tagName != topelement && fobj.className !=  "thepopup" ) {
     fobj = nn6 ? fobj.parentNode : fobj.parentElement;
   }
   if (fobj.className== "thepopup" ) {
   isdrag = true;
   dobj = document.getElementById("hidden_popup");
   tx = parseInt(dobj.style.left+0);
   ty = parseInt(dobj.style.top+0);
   x = nn6 ? (e.clientX) : (event.clientX);
   y = nn6 ? (e.clientY) : (event.clientY);
   document.onmousemove=movemouse;
   return false;
	 }
}

function dynamicPopupShow()
{
 document.getElementById("darkLayer").style.display = "block";
 // document.getElementById("theflash").style.visibility = "hidden";
  document.getElementById("hidden_popup").style.display= "block";
//sent inital position
  var thewindow = document.getElementById("hidden_popup");
  thewindow.style.left = "150px"; 
  thewindow.style.top  = "50px";
//end
}

function dynamicPopupClose() {
  document.getElementById("darkLayer").style.display = "none";
 //document.getElementById("theflash").style.visibility = "visible";
 document.getElementById("hidden_popup").style.display =  "none" ;
}

function messageAlert(message,location)
{
	if (confirm(message))
	{ //ok go there
		window.location=location;
	}
}



document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
//end pop-up//

function AjaxPost(TargetFile,PostId,ResponseId,DoSubmit) {
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
       xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
	       xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

   xmlHttpReq.open('POST', TargetFile, true);
   xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
              document.getElementById(ResponseId).innerHTML = xmlHttpReq.responseText;
			  if (DoSubmit)
			    document.thesearchform.submit();
        }
    }
    xmlHttpReq.send(PostId + '=' + document.getElementById(PostId).value); //Something=blah&something2=blah2
	
}
//menu fix
startList = function() { 
var allelements = document.getElementsByTagName("ul");
  for(var counter = 0;counter<allelements.length;counter++)
  {
    if (allelements[counter].className=="menu" || allelements[counter].className=="level1" || allelements[counter].className=="subMenu")
       fix(allelements[counter]);
  }
 
} // end startlist

function fix(navRoot) {
if (document.all&&document.getElementById) {
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI" && node.className!="spacer") {
	node.onmouseover=function() { this.className="over";  }
    node.onmouseout=function() { this.className=this.className.replace("over", "");  }
   } // end id LI
  } //end for
 } //end if
} // end function
window.onload=startList;

//Change level of subscription  
function HomePreload(imagefilenames) {
 	var args = imagefilenames.split(',');
	var animage = new Image();
	var images = [];
	for(var i=0; i<args.length; i++) {
	    animage.src = "./images/" + args[i];
	    images.push(animage);
	    
	}
 }

function ChangeLevel()
{

  var TheElement = document.getElementById('numberofusers');
  var TheIndustry = document.getElementById('industry');
  TheElement.disabled=false;
  if (!TheIndustry.value.indexOf("CMO") || !TheIndustry.value.indexOf("CRO"))
   {
    
    TheElement.options[0].text="1-10";
    TheElement.options[1].text="10-20";
    TheElement.options[2].text="20+";

  }
  else
  {
    TheElement.options[0].text="1-3";
    TheElement.options[1].text="3-10";
    TheElement.options[2].text="10+";

   }
 }
 //Show Hide
  function showhide(parentId,theId)
  {
    var theElement = document.getElementById(theId);
	var theParent = document.getElementById(parentId);
	if (theElement.style.display=="none")
	 { 
	  theParent.innerHTML=" <img src=\"/images/graphics/minus_icon.png\" border=\"0\" align=\"texttop\">";
	  theElement.style.display="block";
	 
	 }
	else
	{
	  theParent.innerHTML=" <img src=\"/images/graphics/plus_icon.png\" border=\"0\" align=\"texttop\">";
	 theElement.style.display="none";
	 }
  }
  function hide(theIds)
  {
    var theIdsArray = theIds.split(',');
	for (counter=0;counter<theIdsArray.length;counter++)
	{
	  var theElement = document.getElementById(theIdsArray[counter]);
      theElement.style.display = "none";
	}
  }
  
function hideall(theIds,theParents)
{
    var theIdsArray = theIds.split(',');
    for (counter=0;counter<theIdsArray.length;counter++)
	{
	    if (theIdsArray[counter].length>1) // keep javascript from blowing up
		{
		    var theElement = document.getElementById(theIdsArray[counter]);
		    theElement.style.display = "none";
		}
	}
    var theParentsArray = theParents.split(',');
    for (counter=0;counter<theParentsArray.length;counter++)
	{
	    if (theParentsArray[counter].length>1) // keep javascript from blowing up
		{
		    var theParent = document.getElementById(theParentsArray[counter]);
		    theParent.innerHTML=" <img src=\"../images/graphics/plus_icon.png\" border=\"0\" align=\"texttop\">";
		}
	}
}

function showall(theIds,theParents)
{
    var theIdsArray = theIds.split(',');
    for (counter=0;counter<theIdsArray.length;counter++)
	{
	    if (theIdsArray[counter].length>1)
		{
		    var theElement = document.getElementById(theIdsArray[counter]);
		    theElement.style.display = "block";
		}
	}
    var theParentsArray = theParents.split(',');
    for (counter=0;counter<theParentsArray.length;counter++)
	{
	    if (theParentsArray[counter].length>1) // keep javascript from blowing up
		{
		    var theParent = document.getElementById(theParentsArray[counter]);
		    theParent.innerHTML=" <img src=\"../images/graphics/minus_icon.png\" border=\"0\" align=\"texttop\">";
		}	
	}
}