
//Pop-under window II- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script

//specify URLs to randomly select from and pop-under
var popunder=new Array();
popunder[0]="http://www.newgrip.com/banner_wrist_support.html";

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="scrollbars=yes,status=no,resizable=yes,width=750,height=500";

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=1;

// used for popup divs to show-hide 
function modiv(divid,onoff){

	return;  // turned this function OFF per alan's request. Will reuse later when refined.
	
	var thediv = document.getElementById(divid);
	if(onoff == 'show')
		thediv.style.display = 'block';
	else
		thediv.style.display = 'none';

}

function get_cookie(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end));
      }
   }
  return returnvalue;
}

function loadornot(){
	if (get_cookie('popunder')==''){
		loadpopunder();
		document.cookie="popunder=yes";
	}
}

function loadpopunder(){
	win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"ngrip",winfeatures);
	win2.blur();
	if(window.focus)
		window.focus();
}
/*  POPUNDERS THANKFULLY DISCONTINUED
if (once_per_session==0)
	loadpopunder();
else
	loadornot();
*/
	
function PopWin(url, wname, w, h, pl, pt) {
	var winX = pl;
	var winY = pt;
	// Nav 4 gives true screen pos %, while default assumes % on 640X480
	if (parseInt(navigator.appVersion) >= 4) {
		winX = (screen.availWidth - w)*pl*.01;
		winY = (screen.availHeight - h)*pt*.01;
//		alert(screen.availHeight +' '+ winY + ' ' + winX + navigator.appVersion);
	}
	
	var pWin = window.open(url, "wname",'scrollbars=yes,status=no,dependent,resizable=yes,width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
	if (pWin.focus) {
		pWin.focus();
	}
}



/* other functions not likely to be used */

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
