// JavaScript Document Optimized CSS V 1.2 by Colorado Web Solutions 12-30-2008


// From Original File located at http://lib.store.yahoo.net/lib/allheart/javascripts.js

var windowHandle = null;
var globalImage = null;
var globalImageWidth = null;
var globalImageHeight = null;
var globalCaption = null;
function myOpen(localImage,localCaption,imageWidth,imageHeight,windowWidth,windowHeight,xPos,yPos) {
    globalImage = localImage;
    globalCaption = localCaption;
    globalImageWidth = imageWidth;
    globalImageHeight = imageHeight;
    windowHandle = window.open('swatchpopup.html','windowName','width=' + windowWidth + ',height=' + windowHeight + ',left=' + xPos + ',top=' + yPos + 'screenX=' + xPos + ',screenY=' + yPos);
    if (!windowHandle.opener)
        windowHandle.opener = self;
}

function myOpen2(localImage,windowName,windowWidth,windowHeight,xPos,yPos) {
    globalImage = localImage;
    windowHandle = window.open('productpopup.html','windowName','width=' + windowWidth + ',height=' + windowHeight + ',left=' + xPos + ',top=' + yPos + 'screenX=' + xPos + ',screenY=' + yPos);
    if (!windowHandle.opener)
        windowHandle.opener = self;
}

var message="";
///////////////////////////////////


function clearDefaultandCSS(el) {
	if (el.defaultValue==el.value) el.value = ""
	// If Dynamic Style is supported, clear the style
	if (el.style) el.style.cssText = ""
}

function jumpto(x){
if (document.form1.jumpmenu.value != "null") {
	document.location.href = x
	}
}


function textEmbPopupScrubs()
     { mapWindow = window.open ('http://www.allheart.com/lib/allheart/embroiderypopup.html#scrubs','AllHeartEmbroiderySamples','width=440,height=500,top=10,left=180,scrollbars=yes,menubar=no')
     }

function textEmbPopupUlabs()
     { mapWindow = window.open ('http://www.allheart.com/lib/allheart/embroiderypopup.html#unisexlabcoats','AllHeartEmbroiderySamples','width=440,height=500,top=10,left=180,scrollbars=yes,menubar=no')
     }

function textEmbPopupWlabs()
     { mapWindow = window.open ('http://www.allheart.com/lib/allheart/embroiderypopup.html#womenslabcoats','AllHeartEmbroiderySamples','width=440,height=500,top=10,left=180,scrollbars=yes,menubar=no')
     }

function textEmbPopupMlabs()
     { mapWindow = window.open ('http://www.allheart.com/lib/allheart/embroiderypopup.html#menslabcoats','AllHeartEmbroiderySamples','width=440,height=500,top=10,left=180,scrollbars=yes,menubar=no')
     }

function emblemEmbPopup()
     { mapWindow = window.open ('http://www.allheart.com/lib/allheart/embmedemblempopup.html','AllHeartEmbroiderySamples','width=600,height=500,top=10,left=80,scrollbars=yes,menubar=no')
     }

// End from http://lib.store.yahoo.net/lib/allheart/javascripts.js


// Code added from http://lib.store.yahoo.net/lib/allheart/querystring.js


/* Client-side access to querystring name=value pairs
	Version 1.3
	28 May 2008
	
	License (Simplified BSD):
	http://adamv.com/dev/javascript/qslicense.txt
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

// Code from http://lib.store.yahoo.net/lib/allheart/querystring.js

// code from http://lib.store.yahoo.net/lib/allheart/allheart.js

function expandoptions(divno)	{
	if (document.getElementById('expand['+ divno +']').checked == true) {
		document.getElementById('showoptions['+ divno +']').innerHTML = document.getElementById('optionblock['+ divno + ']').innerHTML;
		document.getElementById('showoptions['+ divno +']').style.display =  'block';
	} else {
		document.getElementById('showoptions['+ divno +']').innerHTML = '';
		document.getElementById('showoptions['+ divno +']').style.display = 'none';
	}
}

function expandoptionslocal()	{
	if (document.getElementById('expandlocal').checked == true)	{
		document.getElementById('showoptions').innerHTML = document.getElementById('optionblock').innerHTML;
		document.getElementById('showoptions').style.display = 'block';
	} else {
		document.getElementById('showoptions').innerHTML = '';
		document.getElementById('showoptions').style.display = 'none';
	}
}

function ValidateOptionsMulti (formno) {
	var confirmation_string = '';
	var all_form_elements = document.forms['master-form['+ formno +']'].elements.length;
	for (i=0; i<all_form_elements; i++) {
		var element = document.forms['master-form['+ formno +']'].elements[i]; 
		if (element) {
			if ((element.name != 'vwcatalog') && (element.name != 'vwitem')) {
				if (element.value != '')
					confirmation_string = confirmation_string + element.title + ': ' + element.value + '\n';
			}
		}
	}

	var check_options = confirm ('Please confirm your selection:\n\n'+ confirmation_string +'\n\n');
	if (check_options)
		return true;
	else
		return false;
}

function ValidateOptions () {
	var confirmation_string = '';
	var all_form_elements = document.forms['master-form'].elements.length;
	for (i=0; i<all_form_elements; i++) {
		var element = document.forms['master-form'].elements[i]; 
		if (element) {
			if ((element.name != 'vwcatalog') && (element.name != 'vwitem')) {
				if (element.value != '')
					confirmation_string = confirmation_string + element.title + ': ' + element.value + '\n';
			}
		}
	}

	var check_options = confirm ('Please confirm your selection:\n\n'+ confirmation_string +'\n\n');
	if (check_options)
		return true;
	else
		return false;
}

function confirmation()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
	return true ;
else
	return false;
}

// isEmail (STRING s [, BOOLEAN emptyOK])
// whitespace characters
var whitespace = " \t\n\r";
 
//
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
function isValidEmail(s)
{
      if (isEmpty(s)) return false;
 
      // is s whitespace?
      if (isWhitespace(s)) return false;
 
      // there must be >= 1 character before @, so we
      // start looking at character position 1
      // (i.e. second character)
      var i = 1;
      var sLength = s.length;
 
      // look for @
      while ((i < sLength) && (s.charAt(i) != "@"))
      { i++
      }
 
      if ((i >= sLength) || (s.charAt(i) != "@")) return false;
      else i += 2;
 
      // look for .
      while ((i < sLength) && (s.charAt(i) != "."))
      { i++
      }
 
      // there must be at least one character after the .
      if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
      else return true;
}
 
// Check whether string s is empty.
function isEmpty(s)
{
      return ((s == null) || (s.length == 0))
}
 
// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace(s)
{
      var i;
 
    // Is s empty?
    if (isEmpty(s)) return true;
 
    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {
              // Check that current character isn't whitespace.
              var c = s.charAt(i);
 
              if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}
 
function checkForm() {
      if (!isValidEmail(document.subscribeForm.elements['Email Address'].value)) {
      document.subscribeForm.elements['Email Address'].style.backgroundColor='yellow';
              alert("Please enter a valid Email Address.(name@host.com)");
              document.subscribeForm.elements['Email Address'].focus();
              return false;
      }
}

// end code from http://lib.store.yahoo.net/lib/allheart/allheart.js
