// pop up label thumbnail
function viewLabel(order_id, label_id, bottle_id) {
	// if the bottle ID is 1 then they need to see all 3 labels
	if (bottle_id == 1)
		var atts = "width=1100,height=600,scrollbar,scrollbars,resizable";
	else
		var atts = "width=400,height=600,scrollbar,scrollbars,resizable";
	var url = "label_pop.php?o=" + order_id + "&l=" + label_id + "&b=" + bottle_id;
	var labelPop = window.open(url, "labelPop", atts);
	labelPop.focus();
	}

// pop up window to build big label
function buildLabel(order_id, label_id, type_id, wine_sku, bottle_id) {
	var atts = "width=300,height=300,scrollbar,scrollbars,resizable";
	var url = "download.php?line=1&oid=" + order_id + "&lid=" + label_id + "&tid=" + type_id + "&wid=" + wine_sku + "&bid=" + bottle_id;
	var labelPop = window.open(url, "labelPop", atts);
	labelPop.focus();
	}

// validates form fields
function validate(objForm) {
	var PatternsDict = new Object();
	PatternsDict.zipPat = /\d{5}(-\d{4})?/;  // matches zip codes
	PatternsDict.emailPat = /.*@.*\..*/;  // matches email addresses
	PatternsDict.notEmptyPat = /.{1,}/;  // matches at least one character
	PatternsDict.numberPat = /\d/;  // matches numbers only
	PatternsDict.pwPat = /^\D{1}\S{5,11}$/;  // matches between 6 and 12 characters with non-digit leading
	PatternsDict.currencyPat = /\$\d{1,3}(,\d{3})*\.\d{2}/;  // matches currency with commas
	PatternsDict.timePat = /^([1-9]|1[0-2]):[0-5]\d$/;  // matches times

	var elArr = objForm.elements;
	for(var i=0; i<elArr.length; i++)
	with(elArr[i]) { 
		var v = elArr[i].VALIDATOR; 
		if(!v) continue; 
		
		var thePat = PatternsDict[v]; 
		var gotIt = thePat.exec(value); 
		if(!gotIt) {
			var returnStr;
			returnStr = "The " + name + " field is invalid, this field is required in order to submit this form.  Please try again!";
			alert(returnStr);
			return false;
			}
		} 
	return true;
	}
	
//pass variables to individual label pages
function passLabel(label,default_msg1,default_msg2,default_msg3)
	{
		document.passLabel.action=label;		
		document.passLabel.default_msg1.value = default_msg1;
		document.passLabel.default_msg2.value = default_msg2;
		document.passLabel.default_msg3.value = default_msg3;
		document.passLabel.submit();
	}
	
function viewHelp(anchor)
{
	document.helpTag.action = 'help.php#'+anchor;
	var viewHelp=window.open('help.php#'+anchor,'viewHelp','toolbar=no,width=400,height=600,directories=no,status=yes,scrollbars=no,resize=no,menubar=no');
	document.helpTag.submit();
	viewHelp.focus();
}


function redirectNew(link, alt)
{
	document.redirectNew.action = 'redirect.php';
	document.redirectNew.link.value = link;
	document.redirectNew.alt.value = alt;
	document.redirectNew.submit();
}


/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null) {
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
		}
	return totaloffset;
	}

function overlay(curobj, subobjstr, opt_position){
	if (document.getElementById) {
		var subobj=document.getElementById(subobjstr)
		subobj.style.display=(subobj.style.display!="block")? "block" : "none";
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0);
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
		subobj.style.left=xpos+"px";
		subobj.style.top=ypos+"px";
		return false;
		}
	else
		return true
	}

function overlayclose(subobj) {
	document.getElementById(subobj).style.display="none";
	}
	

	
	





