﻿function SendFeedback(url) {
  var destination = url.replace("RES",screen.width+"x"+screen.height);
  var mywindow=window.open(destination,'surveywindow','width=720,height=610,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,left=50,top=50');
}
function SelectAll() {
  for (ii=0; ii<document.forms[0].length; ii++)
  {
    if ( document.forms[0].elements[ii].type == "checkbox")
    {
			document.forms[0].elements[ii].checked = !document.forms[0].elements[ii].checked;
		}
	}
}
function SetFocus()
{ 
  var UserControl;
  var UserControls = new Array();
  var ControlsBase = "ctl00_ContentPlaceHolder1_";
  UserControls[0] = ControlsBase + "LoginTextBox";
  UserControls[1] = ControlsBase + "EmailTextBox";
  UserControls[2] = ControlsBase + "AnswerTextBox";
  UserControls[3] = ControlsBase + "TimeFrameDropDownList"; 
  UserControls[4] = ControlsBase + "PasswordCurrentTextBox";
  UserControls[5] = ControlsBase + "NewShipToFormView_AliasTextBox";
  UserControls[6] = ControlsBase + "FormViewNewAccount_EMailTextBox";
  UserControls[6] = ControlsBase + "AccountFormView_SalutationDropDownList";
  UserControls[7] = ControlsBase + "FormViewNewAccount_SalutationDropDownList";
  UserControls[8] = ControlsBase + "FormViewNewAccount_SendMeNewsCheckBox";
  UserControls[9] = ControlsBase + "ShipToFormView_AliasTextBox";
  UserControls[10] = ControlsBase + "CustomerNumberTextBox";
  UserControls[11] = ControlsBase + "ItemNumber1TextBox";

  for (UserControl in UserControls)
  {
    if ( document.getElementById( UserControls[UserControl] ) != null )
    {
      document.getElementById( UserControls[UserControl] ).focus(); 
      if ( UserControls[UserControl] == UserControls[0])
      {
        if(document.getElementById( UserControls[UserControl] ).value != "")
        {
          document.getElementById( ControlsBase + "PasswordTextBox" ).focus();
        }
      }     
      break;
    }
  }
}

function ExpandCollapse (elementRef, classExpand, classCollapse) 
{ 
  if (document.getElementById(elementRef).className == classExpand) {
  document.getElementById(elementRef).className = classCollapse  }  
  else { document.getElementById(elementRef).className = classExpand }
}

//function CompanyFirstNameChanger (firstnameid, elementRef, classExpand, classCollapse) 
//{ 
//  if (document.getElementById(elementRef).className == "hide") {
//  document.getElementById(elementRef).className = "show"  }  
//  else { document.getElementById(elementRef).className = "hide" }

//  if ( document.getElementById(firstnameid).innerHTML == "First name" ) 
//  { document.getElementById(firstnameid).innerHTML = "Company name" }  
//  else { document.getElementById(firstnameid).innerHTML = "First name" }
//}

function GoTo( url , target )
{
  eval[target + "window.location = " + url];
}

function popUp(URL) 
{
  var id = "Cart";
  var newwindow;
  newwindow = eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=100,height=200,left = 590,top = 412');");
  if (window.focus) {newwindow.focus();}
}

function isBlank(s) 
{
  return (isEmpty(s) || isWhitespace(s))
}

function isEmpty(s) 
{
  return ((s == null) || (s.length == 0))
} 

function isWhitespace(s) 
{
    var i;
    var whitespace = "\t\n\r\f";
  if (isEmpty(s)) 
  {
    return true;
  }
  for (i = 0; i < s.length; i++) 
  {   
    var c = s.charAt(i);
    if (whitespace.indexOf(c) == -1)
    { 
      return false;
    }  
  }
  return true;
}

//validate keyword search text box
function validateKeyword(field)
{	
  s = document.getElementById(field).value;
	if( s != null )
	{
		if( !isEmpty(s) )
		{	return true;	}
		else 
		{	return false;	}	
	}
}
function CheckEmptyTextBoxes()
{
  var goodtogo = true;
  var focflag;
  for (ii=0; ii<document.forms[0].length; ii++)
  {
    if ( (document.forms[0].elements[ii].type == "text") != -1 )
    {
        if (isEmpty(document.forms[0].elements[ii].value))
        {
            goodtogo = false;
            focflag = document.forms[0].elements[ii].name;
        }
    }           
  }
  if ( goodtogo )
  {
    return true;
  }
  else
  {
    document.forms[0].elements[focflag].focus();
    alert("You have left one of the required fields blank.");                    
    return false;
  }
}
function CheckImage(img){
	if (typeof document.getElementById(img) != "undefined"){
		var coming_soon = "/Images/spacer.gif";
		var brokenImage = document.getElementById(img.id);
		brokenImage.setAttribute("src" , coming_soon);
	}
}

function PlaceOrderProgress()
{
  SetImageButtonDisabled('ctl00_ContentPlaceHolder1_PlaceOrderImageButton', '/images/button_checkout_processing.gif');
  SetImageButtonDisabled('ctl00_ContentPlaceHolder1_PlaceOrderImageButton1', '/images/button_checkout_processing.gif');
}

function RegisterProgress()
{
  if (Page_ClientValidate())
  {
    SetImageButtonDisabled('ctl00_ContentPlaceHolder1_FormViewNewAccount_buttonFinishStep2', '/images/button_processing.gif');
  }
}

function AddShipToProgress()
{
  if (Page_ClientValidate())
  {
    SetImageButtonDisabled('ctl00_ContentPlaceHolder1_NewShipToFormView_InsertShipToImageButton', '/images/button_processing.gif');
  }
}

function AddBloodSubjectProgress()
{
  if (Page_ClientValidate())
  {
    SetImageButtonDisabled('ctl00_ContentPlaceHolder1_NewBloodSubjectFormView_InsertBloodSubjectImageButton', '/images/button_processing.gif');
  }
}

function CheckOutAddShipToProgress()
{
  if (Page_ClientValidate())
  {
    SetImageButtonDisabled('ctl00_ContentPlaceHolder1_NewShipToFormView_InsertShipToImageButton', '/images/button_processing.gif');
  }
}

function SetImageButtonDisabled(id, replaceImageSrc)
{
   document.getElementById(id).onclick = new Function("return false;");
   document.getElementById(id).src = replaceImageSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//function popUpVerisign(url) {
//		sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
//		self.name = "mainWin";
//	}

function SiteSeal(img, type) {
    if (window.location.protocol.toLowerCase() == "https:") { var mode = "https:"; } else { var mode = "http:"; }
    var host = location.host;
    var baseURL = mode + "//seals.networksolutions.com/siteseal_seek/siteseal?v_shortname=" + type + "&v_querytype=W&v_search=" + host + "&x=5&y=5";
    document.write('<a href="#" onClick=\'window.open("' + baseURL + '","' + type + '","width=450,height=500,toolbar=no,location=no,directories=no,\
status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no");return false;\'>\
<img src="' + img + '" style="border:none;" oncontextmenu="alert(\'This SiteSeal is protected\');return false;"></a>');
}




  
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input, len, e)
 {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input)
   {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}