/*  function: 	isDirect
	purpose:	to grab information from the querystring
	input:		the name of the variable that you want to pull
	output:		the value of the variable that was passed in */
	
	function isDirect( name )
	{
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if( results == null )
			return "";
		else
			return results[1];			
	}

/*	function: 	handleBackButton()
	purpose:	to change values of form (_mine) element to show that a back button was pressed 
	input:		nothing
	output:		nothing */

var x="1";  //used for detecting back button pressed
var isBack;  //used for detecting back button pressed

function handleBackButton(){
   isBack = (x != document._mine._a1.value);
   document._mine._a1.value=2;
   document._mine._a1.defaultValue=2;
}

/*	function: 	isBackButtonUsed()
	purpose:	show if the form values were changed in the form _mine returns either true or false 
	input:		nothing
	output:		boolean value */
	
function isBackButtonUsed(){
 return isBack;
}

/*	function: 	checkURL()
	purpose:	checks to see if the cookie value "url" is set; if the form _mine values have been changed (that means that the back button was press; reference the call to the function setCookie in the anchor tag); opens a window if all conditions are met
	input:		nothing
	output:		nothing */
	
function checkURL()
{
	if ( (getCookie('url') && isBackButtonUsed()) || isDirect('url') == "direct" )
	{		
		win1 = new Window('1', {className: "alphacube", minimizable: false, maximizable: false, resizable: false, width:500, height:270, top:200, left:400}); win1.getContent().innerHTML = "<div><img src='../../layer-Phone.gif' /></div>";  //the popup window
		win1.show();  //popup window
		//window.open('questions.html','questions','width=500,height=270,location=no,status=no');
		setCookie('url','');  //unset the url
	}
}

/**** normal setCookie and getCookie functions to set and retrieve values for and from a cookie ****/

function setCookie(c_url,value)
{
	var exdate=new Date();
	var expiredays = 30;  //sets the cookie for 30 days
	exdate.setDate(exdate.getDate()+expiredays);
	if ( getCookie(c_url) )
	{
		document.cookie=c_url+ "=" +escape(value)+";expires="+exdate.toGMTString();		
	}
	else
	{
		document.cookie=c_url+ "=" +escape(value)+";expires="+exdate.toGMTString();
	}
}

function getCookie(cookie_name)
{
  	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  	//only grabs the value of the variable cookie_name
  	if ( results )
    	return ( unescape ( results[2] ) );
  	else
    	return null;
}

function pNavMouseOver(obj){
/*
	img = document.getElementsByName('pNavImg');
	for(i=0; i < img.length; i++){
		img[i].style.visibility='hidden';
		//alert(img[i].parentNode.getAttribute('class'));
	}//end for(i)
*/
	//obj.childNodes[0].setAttribute('style', 'visibility:visible');
	obj.childNodes[0].style.visibility = "visible";
	obj.className = "primNav_line";
}//end pNavMouseOver

function pNavMouseOut(obj){	
	//obj.childNodes[0].setAttribute('style', 'visibility:hidden');
	obj.childNodes[0].style.visibility = "hidden";
	obj.className = "";
}//end pNavMouseOut

var omitformtags = ["input", "textarea", "select"];

function disableselect(e) {
  for (i = 0; i < omitformtags.length; i++) {
    if (omitformtags[i] == (e.target.tagName.toLowerCase())) {
      return;
    }
  }
  return false;
}

function reEnable() {
  return true;
}

function noSelect() {
  if (typeof document.onselectstart != "undefined") {
    document.onselectstart = new Function ("return false");
    if (document.getElementsByTagName) {
      tags = document.getElementsByTagName('*');
      for (j = 0; j < tags.length; j++) {
        for (i = 0; i < omitformtags.length; i++) {
          if (tags[j].tagName.toLowerCase() == omitformtags[i]) {
            tags[j].onselectstart = function() {
              document.onselectstart = new Function ('return true')
            }
            if (tags[j].onmouseup !== null) {
              var mUp=tags[j].onmouseup.toString();
              mUp = 'document.onselectstart=new Function (\'return false\');\n'+mUp.substr(mUp.indexOf('{')+2,mUp.lastIndexOf('}')-mUp.indexOf('{')-3);
              tags[j].onmouseup = new Function(mUp);
            }
            else {
              tags[j].onmouseup = function() {
                document.onselectstart = new Function ('return false');
              }
            }
          }
        }
      }
    }
  }
  else {
    document.onmousedown = disableselect;
    document.onmouseup = reEnable;
  }
}

//window.onload=noSelect;


