// JavaScript Document
function flash01()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="942" height="365">\n');
document.write('<param name="movie" value="swfs/landingpage.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/landingpage.swf" wmode="transparent"  quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="942" height="365"></embed>\n');
document.write('</object>\n');
}
function flash02()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_winery.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_winery.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash03()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_clubduplin.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_clubduplin.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash04()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_visit.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_visit.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash05()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_thebistro.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_thebistro.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash06()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_dinnertheater.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_dinnertheater.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash07()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_news.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_news.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash08()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_contact.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_contact.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash09()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_wines.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_wines.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
function flash10()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="955" height="150">\n');
document.write('<param name="movie" value="swfs/banner_store.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/banner_store.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="955" height="150"></embed>\n');
document.write('</object>\n');
}
var parent = new Array();
parent = location.href.split("?");
//if(parent[1].split("&") != null){
var variables = parent[1].split("&");
//document.write(variables.length);
if(variables.length >= 4){
//document.write("find wine name");
var url = location.href;
var flashvar = new Array();
flashvar = url.split("winename=");
var urlname = flashvar[1];
var wine = urlname.replace(/#/,"");
}
if(variables.length == 1){
var wine = "here";
}
//document.write(wine);
//}
//
function flash11()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="200">\n');
document.write('<param name="movie" value="swfs/winename.swf?myVar=' + wine + '">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/winename.swf?myVar=' + wine + '" quality="high" wmode="transparent" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="200"></embed>\n');
document.write('</object>\n');
}
function flash12()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="490" height="400">\n');
document.write('<param name="movie" value="swfs/image-gallery-our-club-family.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/image-gallery.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="400"></embed>\n');
document.write('</object>\n');
}
function flash13()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="490" height="400">\n');
document.write('<param name="movie" value="swfs/image-gallery-online-tour.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/image-gallery-online-tour.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="400"></embed>\n');
document.write('</object>\n');
}
function flash14()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="490" height="400">\n');
document.write('<param name="movie" value="swfs/image-gallery-our-story.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/image-gallery-our-story.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="400"></embed>\n');
document.write('</object>\n');
}
function flash15()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="490" height="400">\n');
document.write('<param name="movie" value="swfs/image-gallery-dinner-theatre.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/image-gallery-dinner-theatre.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="400"></embed>\n');
document.write('</object>\n');
}
function flash16()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="490" height="400">\n');
document.write('<param name="movie" value="swfs/image-gallery-bistro.swf">\n');
document.write('<param name="quality" value="high">\n');
document.write('<param name="wmode" value="transparent"/>\n');
document.write('<embed src="swfs/image-gallery-bistro.swf" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="490" height="400"></embed>\n');
document.write('</object>\n');
}
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////

//New Store

///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
function updatequantity(quan){
	
	var addtocart = document.getElementById("buynowlink").href;
	var urlarray = addtocart.split("&");
	urlarray[4] = "Quantity="+quan;
	var newurl = urlarray.join("&");
	//alert(newurl);
	document.getElementById("buynowlink").href = newurl;
	//alert(document.getElementById("buynowlink").href);
}
function displaymenu(value){
	document.getElementById("Top_nav_Id").style.display = value; 

}
function loadtabarea(info){
	//alert(info);
	document.getElementById("tab1area").style.display = 'none';
	document.getElementById("tab2area").style.display = 'none';
	document.getElementById("tab3area").style.display = 'none';
	document.getElementById(info).style.display = 'block';
	//alert(info);
	
}
function loadproductimage(image){
	//alert(document.getElementById("productlargeimage").src);
	document.getElementById("productlargeimage").src = "uploads/"+image;
	document.getElementById("productlargeimage").alt = "uploads/"+image.replace("large","largeZoom");
	
}

///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////

//End New Store

///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////

function gotomain(){
window.location="http://www.duplinwinery.com/";
}
// Copyright 2006-2007 javascript-array.com
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
// open hidden layer
function mopen(id){	
// cancel close timer
//alert(id);
	mcancelclosetime();
// close old layer
	if(ddmenuitem) {
		ddmenuitem.style.display = 'none';
	}
	if(ddmenuitem2) {
		ddmenuitem2.style.display = 'none';
	}
// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.display = 'block';
}
// close showed layer
function mclose(){

	if(ddmenuitem) {
		ddmenuitem.style.display = 'none';
		ddmenuitem2.style.display = 'none';
		
	}
}
// go close timer
function mclosetime(){
	closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime(){
//alert('mcancelclosetime');
	if(closetimer){
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
var timeout2	= 500;
var closetimer2	= 0;
var ddmenuitem2	= 0;
// open hidden layer
function mopen2(id){	
// cancel close timer
//alert(id);
	mcancelclosetime2(id);
	document.getElementById(id).style.display = 'block';
// close old layer
	//if(ddmenuitem2 == id) {
	//	document.getElementById(id).style.display = 'block';
	//	ddmenuitem2 = id;
	//}else{
	//	ddmenuitem2.style.display = 'none';
	//	ddmenuitem2 = id;
	//}
	
}

// close showed layer
function mclose2(id){
//alert('mclose2');
	document.getElementById(id).style.display = 'none';
	//if(ddmenuitem2) {
		//ddmenuitem2.style.display = 'none';
	//}
}
// go close timer
function mclosetime2(){
	closetimer2 = window.setTimeout(mclose2, timeout2);
}
// cancel close timer
function mcancelclosetime2(){
	if(closetimer2){
		window.clearTimeout(closetimer2);
		closetimer2 = null;
	}
}



var timeout2	= 500;
var closetimer2	= 0;
var ddmenuitem2	= 0;
// open hidden layer
function spanopen2(id,parent){	
// cancel close timer
//alert(id);
	mcancelclosetime2();
// close old layer
	if(ddmenuitem2) {
		///ddmenuitem2.style.display = 'none';
	}
// get new layer and show it
	ddmenuitem3 = document.getElementById(parent);
	ddmenuitem3.style.display = 'block';
	ddmenuitem2 = document.getElementById(id);
	ddmenuitem2.style.display = 'block';
}

// close showed layer
function spanclose2(){
//alert('mclose2');
	if(ddmenuitem2) {
		ddmenuitem2.style.display = 'none';
	}
}
// go close timer
function spanclosetime2(){
	closetimer2 = window.setTimeout(mclose2, timeout2);
}
// cancel close timer
function spancancelclosetime2(){
	if(closetimer2){
		window.clearTimeout(closetimer2);
		closetimer2 = null;
	}
}
// close layer when click-out
document.onclick = mclose; 
document.onclick = mclose2; 




//Pop up Function
function popup(id,title){

document.open("php/pop.php?id="+id+"&producttitle="+title+"","myWindow","status=1, width = 750,height=600,resizable=0");
//alert(id);
}
function popup2(id){
//alert("pop");
document.open("php/pop2.php?id=" + id + "", "myWindow", "status = 1, width = 750, height=600, resizable = 0");
}

/* Error messages for possible errors */
var error_address_empty 	= 'Please enter a valid address first.';
var error_invalid_address 	= 'This address is invalid.';
var error_google_error 		= 'There was a problem processing your request, please try again.';
var error_no_map_info		= 'Sorry! Map information is not available for this address.';
/* The default address of your store (your main office or store maybe), we will display this address on the map on startup */
/* Edit this */
var default_address = '1600 Amphitheatre Parkway, Mountain View, CA  94043';
var current_address = null; /* Current address we are displaying, we save it here for directions */
var map				  = null; /* Instance of Google Maps object */
var geocoder		  = null; /* Instance of Google Deocoder object */
var gdir				  = null; /* Instance of Google Directions object */
var map_compatible  = false; /* Whether or not user's browser is compatible to show the map */
/* Check if the browser is compatible */
/* Initialize the map this will be called when the document is loaded from: <body onLoad="initialize_map();"> */
function initialize_map() {
if(GBrowserIsCompatible()) {
var map_compatible = true;
//alert(map_compatible);
}
if( map_compatible ) {
var map = new GMap2(document.getElementById('map'));        
var geocoder = new GClientGeocoder();
var marker = new GMarker(new GLatLng(34.830401262867504, -78.02392601966858));
var html = '<div style="width:210px; padding-right:10px;"><img src="uploads/images/_logos/small_map_logo.jpg" ></div>';
show_address(default_address);
map.setCenter(new GLatLng(34.830401262867504, -78.02392601966858), 9);
map.addOverlay(marker);
//var boundaries = new GLatLngBounds(new GLatLng(34.830401262867504, -78.02392601966858), new GLatLng(35.830401262867504, -79.02392601966858));
//var oldmap = new GGroundOverlay("uploads/images/_logos/small_map_logo.jpg", boundaries);
//map.addOverlay(oldmap);
//marker.openInfoWindowHtml(html);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
}
}
function initialize_map2() {
if(GBrowserIsCompatible()) {
var map_compatible = true;
//alert(map_compatible);
}
if( map_compatible ) {
var map = new GMap2(document.getElementById('map'));        
var geocoder = new GClientGeocoder();
show_address(default_address);
map.setCenter(new GLatLng(34.830401262867504, -78.02392601966858), 6);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
}
}
var map;
var directionsPanel;
var directions;
var startdirections;
function initialize() {
map = new GMap2(document.getElementById("map"));
directionsPanel = document.getElementById("directions_div");
startdirections = document.getElementById("startinput").value;
map.setCenter(new GLatLng(34.830401262867504, -78.02392601966858), 6);
directions = new GDirections(map, directionsPanel);
directions.load("" + startdirections + " to 34.830401262867504, -78.02392601966858");
}
/* This function will move the map and shows the address passed to it */
function show_address(address) {
if( map_compatible && geocoder ) {
/* Save this address in current_address value to use later if user wants directions */
current_address = address;		
geocoder.getLatLng(address,
function( point ) {
if( !point ) {
alert(error_no_map_info);
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
return false;
}
/* Get the directions */
function get_directions() {
if(GBrowserIsCompatible()) {
var map_compatible = true;
//alert(map_compatible);
}
if(map_compatible) {
alert(map_compatible);
if( document.direction_form.from_address.value == '' ) {
alert(error_address_empty);
return false;
}
/**
* Delete the contents of 'directions' DIV first 
* because user might ask for directions more than once.
**/
document.getElementById('directions').innerHTML = '';
gdir = new GDirections(map, document.getElementById('directions'));
/* Setup to event handlers, one: when the directions are loaded, two: if there was any error */
GEvent.addListener(gdir, 'load',  onGDirectionsLoad);
GEvent.addListener(gdir, 'error', handleErrors);
/* Show the directions */
set_directions(document.direction_form.from_address.value, current_address);			
}
return false;
}
/* This will actually set the directions on the map and loads the direction table */
function set_directions(fromAddress, toAddress) {
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": "en" });
}
/* This will handle the errors might happen while retrieving the directions */
function handleErrors(){
if( gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS )
alert(error_invalid_address);
else if( gdir.getStatus().code == G_GEO_SERVER_ERROR )
alert(error_google_error);
else if( gdir.getStatus().code == G_GEO_MISSING_QUERY )
alert(error_address_empty);
else 
alert(error_invalid_address);
}
/* This function will be called when the directions are loaded */
function onGDirectionsLoad(){
/* We will simply scroll down to the directions, but with a little delay so it's loaded */
// setTimeout('eval(\'window.location = "#directions_table"\;\')', 500); /* Uncomment this line if you need to */
}
function initialize_storemap(){
	var map = new GMap2(document.getElementById('StoresMap'));        
	var geocoder = new GClientGeocoder();
	show_address(default_address);
	map.setCenter(new GLatLng(34.830401262867504, -78.02392601966858), 6);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
}
// Auto Tab Phone Number
function autotab(object, destination){
if (object.getAttribute && object.value.length == object.getAttribute("maxlength"))
destination.focus()
}



// Date Calendar Customizable variables
var DefaultDateFormat = 'MM/DD/YYYY'; // If no date format is supplied, this will be used instead
var HideWait = 3; // Number of seconds before the calendar will disappear
var Y2kPivotPoint = 76; // 2-digit years before this point will be created in the 21st century
var UnselectedMonthText = ''; // Text to display in the 1st month list item when the date isn't required
var FontSize = 11; // In pixels
var FontFamily = 'Tahoma';
var CellWidth = 18;
var CellHeight = 16;
var ImageURL = '../images/calendar.jpg';
var NextURL = '../images/next.gif';
var PrevURL = '../images/prev.gif';
var CalBGColor = 'white';
var TopRowBGColor = 'buttonface';
var DayBGColor = 'lightgrey';
// Global variables
var ZCounter = 100;
var Today = new Date();
var WeekDays = new Array('S','M','T','W','T','F','S');
var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var MonthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// Write out the stylesheet definition for the calendar
with (document) {
writeln('<style>');
writeln('td.calendarDateInput {letter-spacing:normal;line-height:normal;font-family:' + FontFamily + ',Sans-Serif;font-size:' + FontSize + 'px;}');
writeln('select.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}');
writeln('input.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}');
writeln('</style>');
}
// Only allows certain keys to be used in the date field
function YearDigitsOnly(e) {
var KeyCode = (e.keyCode) ? e.keyCode : e.which;
return ((KeyCode == 8) // backspace
|| (KeyCode == 9) // tab
|| (KeyCode == 37) // left arrow
|| (KeyCode == 39) // right arrow
|| (KeyCode == 46) // delete
|| ((KeyCode > 47) && (KeyCode < 58)) // 0 - 9
);
}
// Gets the absolute pixel position of the supplied element
function GetTagPixels(StartTag, Direction) {
var PixelAmt = (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop;
while ((StartTag.tagName != 'BODY') && (StartTag.tagName != 'HTML')) {
StartTag = StartTag.offsetParent;
PixelAmt += (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop;
}
return PixelAmt;
}
// Is the specified select-list behind the calendar?
function BehindCal(SelectList, CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY) {
var ListLeftX = GetTagPixels(SelectList, 'LEFT');
var ListRightX = ListLeftX + SelectList.offsetWidth;
var ListBottomY = ListTopY + SelectList.offsetHeight;
return (((ListTopY < CalBottomY) && (ListBottomY > CalTopY)) && ((ListLeftX < CalRightX) && (ListRightX > CalLeftX)));
}
// For IE, hides any select-lists that are behind the calendar
function FixSelectLists(Over) {
if (navigator.appName == 'Microsoft Internet Explorer') {
var CalDiv = this.getCalendar();
var CalLeftX = CalDiv.offsetLeft;
var CalRightX = CalLeftX + CalDiv.offsetWidth;
var CalTopY = CalDiv.offsetTop;
var CalBottomY = CalTopY + (CellHeight * 9);
var FoundCalInput = false;
formLoop :
for (var j=this.formNumber;j<document.forms.length;j++) {
for (var i=0;i<document.forms[j].elements.length;i++) {
if (typeof document.forms[j].elements[i].type == 'string') {
if ((document.forms[j].elements[i].type == 'hidden') && (document.forms[j].elements[i].name == this.hiddenFieldName)) {
FoundCalInput = true;
i += 3; // 3 elements between the 1st hidden field and the last year input field
}
if (FoundCalInput) {
if (document.forms[j].elements[i].type.substr(0,6) == 'select') {
ListTopY = GetTagPixels(document.forms[j].elements[i], 'TOP');
if (ListTopY < CalBottomY) {
if (BehindCal(document.forms[j].elements[i], CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY)) {
document.forms[j].elements[i].style.visibility = (Over) ? 'hidden' : 'visible';
}
}
else break formLoop;
}
}
}
}
}
}
}
// Displays a message in the status bar when hovering over the calendar days
function DayCellHover(Cell, Over, Color, HoveredDay) {
Cell.style.backgroundColor = (Over) ? DayBGColor : Color;
if (Over) {
if ((this.yearValue == Today.getFullYear()) && (this.monthIndex == Today.getMonth()) && (HoveredDay == Today.getDate())) self.status = 'Click to select today';
else {
var Suffix = HoveredDay.toString();
switch (Suffix.substr(Suffix.length - 1, 1)) {
case '1' : Suffix += (HoveredDay == 11) ? 'th' : 'st'; break;
case '2' : Suffix += (HoveredDay == 12) ? 'th' : 'nd'; break;
case '3' : Suffix += (HoveredDay == 13) ? 'th' : 'rd'; break;
default : Suffix += 'th'; break;
}
self.status = 'Click to select ' + this.monthName + ' ' + Suffix;
}
}
else self.status = '';
return true;
}
// Sets the form elements after a day has been picked from the calendar
function PickDisplayDay(ClickedDay) {
this.show();
var MonthList = this.getMonthList();
var DayList = this.getDayList();
var YearField = this.getYearField();
FixDayList(DayList, GetDayCount(this.displayed.yearValue, this.displayed.monthIndex));
// Select the month and day in the lists
for (var i=0;i<MonthList.length;i++) {
if (MonthList.options[i].value == this.displayed.monthIndex) MonthList.options[i].selected = true;
}
for (var j=1;j<=DayList.length;j++) {
if (j == ClickedDay) DayList.options[j-1].selected = true;
}
this.setPicked(this.displayed.yearValue, this.displayed.monthIndex, ClickedDay);
// Change the year, if necessary
YearField.value = this.picked.yearPad;
YearField.defaultValue = YearField.value;
}
// Builds the HTML for the calendar days
function BuildCalendarDays() {
var Rows = 5;
if (((this.displayed.dayCount == 31) && (this.displayed.firstDay > 4)) || ((this.displayed.dayCount == 30) && (this.displayed.firstDay == 6))) Rows = 6;
else if ((this.displayed.dayCount == 28) && (this.displayed.firstDay == 0)) Rows = 4;
var HTML = '<table width="' + (CellWidth * 7) + '" cellspacing="0" cellpadding="1" style="cursor:default">';
for (var j=0;j<Rows;j++) {
HTML += '<tr>';
for (var i=1;i<=7;i++) {
Day = (j * 7) + (i - this.displayed.firstDay);
if ((Day >= 1) && (Day <= this.displayed.dayCount)) {
if ((this.displayed.yearValue == this.picked.yearValue) && (this.displayed.monthIndex == this.picked.monthIndex) && (Day == this.picked.day)) {
TextStyle = 'color:white;font-weight:bold;'
BackColor = DayBGColor;
}
else {
TextStyle = 'color:black;'
BackColor = CalBGColor;
}
if ((this.displayed.yearValue == Today.getFullYear()) && (this.displayed.monthIndex == Today.getMonth()) && (Day == Today.getDate())) TextStyle += 'border:1px solid darkred;padding:0px;';
HTML += '<td align="center" class="calendarDateInput" style="cursor:default;height:' + CellHeight + ';width:' + CellWidth + ';' + TextStyle + ';background-color:' + BackColor + '" onClick="' + this.objName + '.pickDay(' + Day + ')" onMouseOver="return ' + this.objName + '.displayed.dayHover(this,true,\'' + BackColor + '\',' + Day + ')" onMouseOut="return ' + this.objName + '.displayed.dayHover(this,false,\'' + BackColor + '\')">' + Day + '</td>';
}
else HTML += '<td class="calendarDateInput" style="height:' + CellHeight + '">&nbsp;</td>';
}
HTML += '</tr>';
}
return HTML += '</table>';
}
// Determines which century to use (20th or 21st) when dealing with 2-digit years
function GetGoodYear(YearDigits) {
if (YearDigits.length == 4) return YearDigits;
else {
var Millennium = (YearDigits < Y2kPivotPoint) ? 2000 : 1900;
return Millennium + parseInt(YearDigits,10);
}
}
// Returns the number of days in a month (handles leap-years)
function GetDayCount(SomeYear, SomeMonth) {
return ((SomeMonth == 1) && ((SomeYear % 400 == 0) || ((SomeYear % 4 == 0) && (SomeYear % 100 != 0)))) ? 29 : MonthDays[SomeMonth];
}
// Highlights the buttons
function VirtualButton(Cell, ButtonDown) {
if (ButtonDown) {
Cell.style.borderLeft = 'buttonshadow 1px solid';
Cell.style.borderTop = 'buttonshadow 1px solid';
Cell.style.borderBottom = 'buttonhighlight 1px solid';
Cell.style.borderRight = 'buttonhighlight 1px solid';
}
else {
Cell.style.borderLeft = 'buttonhighlight 1px solid';
Cell.style.borderTop = 'buttonhighlight 1px solid';
Cell.style.borderBottom = 'buttonshadow 1px solid';
Cell.style.borderRight = 'buttonshadow 1px solid';
}
}
// Mouse-over for the previous/next month buttons
function NeighborHover(Cell, Over, DateObj) {
if (Over) {
VirtualButton(Cell, false);
self.status = 'Click to view ' + DateObj.fullName;
}
else {
Cell.style.border = 'buttonface 1px solid';
self.status = '';
}
return true;
}
// Adds/removes days from the day list, depending on the month/year
function FixDayList(DayList, NewDays) {
var DayPick = DayList.selectedIndex + 1;
if (NewDays != DayList.length) {
var OldSize = DayList.length;
for (var k=Math.min(NewDays,OldSize);k<Math.max(NewDays,OldSize);k++) {
(k >= NewDays) ? DayList.options[NewDays] = null : DayList.options[k] = new Option(k+1, k+1);
}
DayPick = Math.min(DayPick, NewDays);
DayList.options[DayPick-1].selected = true;
}
return DayPick;
}
// Resets the year to its previous valid value when something invalid is entered
function FixYearInput(YearField) {
var YearRE = new RegExp('\\d{' + YearField.defaultValue.length + '}');
if (!YearRE.test(YearField.value)) YearField.value = YearField.defaultValue;
}
// Displays a message in the status bar when hovering over the calendar icon
function CalIconHover(Over) {
var Message = (this.isShowing()) ? 'hide' : 'show';
self.status = (Over) ? 'Click to ' + Message + ' the calendar' : '';
return true;
}
// Starts the timer over from scratch
function CalTimerReset() {
eval('clearTimeout(' + this.timerID + ')');
eval(this.timerID + '=setTimeout(\'' + this.objName + '.show()\',' + (HideWait * 1000) + ')');
}
// The timer for the calendar
function DoTimer(CancelTimer) {
if (CancelTimer) eval('clearTimeout(' + this.timerID + ')');
else {
eval(this.timerID + '=null');
this.resetTimer();
}
}
// Show or hide the calendar
function ShowCalendar() {
if (this.isShowing()) {
var StopTimer = true;
this.getCalendar().style.zIndex = --ZCounter;
this.getCalendar().style.display = 'none';
this.fixSelects(false);
}
else {
var StopTimer = false;
this.fixSelects(true);
this.getCalendar().style.zIndex = ++ZCounter;
this.getCalendar().style.display = 'block';
}
this.handleTimer(StopTimer);
self.status = '';
}
// Hides the input elements when the "blank" month is selected
function SetElementStatus(Hide) {
this.getDayList().style.visibility = (Hide) ? 'hidden' : 'visible';
this.getYearField().style.visibility = (Hide) ? 'hidden' : 'visible';
this.getCalendarLink().style.visibility = (Hide) ? 'hidden' : 'visible';
}
// Sets the date, based on the month selected
function CheckMonthChange(MonthList) {
var DayList = this.getDayList();
if (MonthList.options[MonthList.selectedIndex].value == '') {
DayList.selectedIndex = 0;
this.hideElements(true);
this.setHidden('');
}
else {
this.hideElements(false);
if (this.isShowing()) {
this.resetTimer(); // Gives the user more time to view the calendar with the newly-selected month
this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars
}
var DayPick = FixDayList(DayList, GetDayCount(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value));
this.setPicked(this.picked.yearValue, MonthList.options[MonthList.selectedIndex].value, DayPick);
}
}
// Sets the date, based on the day selected
function CheckDayChange(DayList) {
if (this.isShowing()) this.show();
this.setPicked(this.picked.yearValue, this.picked.monthIndex, DayList.selectedIndex+1);
}
// Changes the date when a valid year has been entered
function CheckYearInput(YearField) {
if ((YearField.value.length == YearField.defaultValue.length) && (YearField.defaultValue != YearField.value)) {
if (this.isShowing()) {
this.resetTimer(); // Gives the user more time to view the calendar with the newly-entered year
this.getCalendar().style.zIndex = ++ZCounter; // Make sure this calendar is on top of any other calendars
}
var NewYear = GetGoodYear(YearField.value);
var MonthList = this.getMonthList();
var NewDay = FixDayList(this.getDayList(), GetDayCount(NewYear, this.picked.monthIndex));
this.setPicked(NewYear, this.picked.monthIndex, NewDay);
YearField.defaultValue = YearField.value;
}
}
// Holds characteristics about a date
function dateObject() {
if (Function.call) { // Used when 'call' method of the Function object is supported
var ParentObject = this;
var ArgumentStart = 0;
}
else { // Used with 'call' method of the Function object is NOT supported
var ParentObject = arguments[0];
var ArgumentStart = 1;
}
ParentObject.date = (arguments.length == (ArgumentStart+1)) ? new Date(arguments[ArgumentStart+0]) : new Date(arguments[ArgumentStart+0], arguments[ArgumentStart+1], arguments[ArgumentStart+2]);
ParentObject.yearValue = ParentObject.date.getFullYear();
ParentObject.monthIndex = ParentObject.date.getMonth();
ParentObject.monthName = MonthNames[ParentObject.monthIndex];
ParentObject.fullName = ParentObject.monthName + ' ' + ParentObject.yearValue;
ParentObject.day = ParentObject.date.getDate();
ParentObject.dayCount = GetDayCount(ParentObject.yearValue, ParentObject.monthIndex);
var FirstDate = new Date(ParentObject.yearValue, ParentObject.monthIndex, 1);
ParentObject.firstDay = FirstDate.getDay();
}
// Keeps track of the date that goes into the hidden field
function storedMonthObject(DateFormat, DateYear, DateMonth, DateDay) {
(Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay);
this.yearPad = this.yearValue.toString();
this.monthPad = (this.monthIndex < 9) ? '0' + String(this.monthIndex + 1) : this.monthIndex + 1;
this.dayPad = (this.day < 10) ? '0' + this.day.toString() : this.day;
this.monthShort = this.monthName.substr(0,3).toUpperCase();
// Formats the year with 2 digits instead of 4
if (DateFormat.indexOf('YYYY') == -1) this.yearPad = this.yearPad.substr(2);
// Define the date-part delimiter
if (DateFormat.indexOf('/') >= 0) var Delimiter = '/';
else if (DateFormat.indexOf('-') >= 0) var Delimiter = '-';
else var Delimiter = '';
// Determine the order of the months and days
if (/DD?.?((MON)|(MM?M?))/.test(DateFormat)) {
this.formatted = this.dayPad + Delimiter;
this.formatted += (RegExp.$1.length == 3) ? this.monthShort : this.monthPad;
}
else if (/((MON)|(MM?M?))?.?DD?/.test(DateFormat)) {
this.formatted = (RegExp.$1.length == 3) ? this.monthShort : this.monthPad;
this.formatted += Delimiter + this.dayPad;
}
// Either prepend or append the year to the formatted date
this.formatted = (DateFormat.substr(0,2) == 'YY') ? this.yearPad + Delimiter + this.formatted : this.formatted + Delimiter + this.yearPad;
}
// Object for the current displayed month
function displayMonthObject(ParentObject, DateYear, DateMonth, DateDay) {
(Function.call) ? dateObject.call(this, DateYear, DateMonth, DateDay) : dateObject(this, DateYear, DateMonth, DateDay);
this.displayID = ParentObject.hiddenFieldName + '_Current_ID';
this.getDisplay = new Function('return document.getElementById(this.displayID)');
this.dayHover = DayCellHover;
this.goCurrent = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(Today.getFullYear(),Today.getMonth());');
if (ParentObject.formNumber >= 0) this.getDisplay().innerHTML = this.fullName;
}
// Object for the previous/next buttons
function neighborMonthObject(ParentObject, IDText, DateMS) {
(Function.call) ? dateObject.call(this, DateMS) : dateObject(this, DateMS);
this.buttonID = ParentObject.hiddenFieldName + '_' + IDText + '_ID';
this.hover = new Function('C','O','NeighborHover(C,O,this)');
this.getButton = new Function('return document.getElementById(this.buttonID)');
this.go = new Function(ParentObject.objName + '.getCalendar().style.zIndex=++ZCounter;' + ParentObject.objName + '.setDisplayed(this.yearValue,this.monthIndex);');
if (ParentObject.formNumber >= 0) this.getButton().title = this.monthName;
}
// Sets the currently-displayed month object
function SetDisplayedMonth(DispYear, DispMonth) {
this.displayed = new displayMonthObject(this, DispYear, DispMonth, 1);
// Creates the previous and next month objects
this.previous = new neighborMonthObject(this, 'Previous', this.displayed.date.getTime() - 86400000);
this.next = new neighborMonthObject(this, 'Next', this.displayed.date.getTime() + (86400000 * (this.displayed.dayCount + 1)));
// Creates the HTML for the calendar
if (this.formNumber >= 0) this.getDayTable().innerHTML = this.buildCalendar();
}
// Sets the current selected date
function SetPickedMonth(PickedYear, PickedMonth, PickedDay) {
this.picked = new storedMonthObject(this.format, PickedYear, PickedMonth, PickedDay);
this.setHidden(this.picked.formatted);
this.setDisplayed(PickedYear, PickedMonth);
}
// The calendar object
function calendarObject(DateName, DateFormat, DefaultDate) {
/* Properties */
this.hiddenFieldName = DateName;
this.monthListID = DateName + '_Month_ID';
this.dayListID = DateName + '_Day_ID';
this.yearFieldID = DateName + '_Year_ID';
this.monthDisplayID = DateName + '_Current_ID';
this.calendarID = DateName + '_ID';
this.dayTableID = DateName + '_DayTable_ID';
this.calendarLinkID = this.calendarID + '_Link';
this.timerID = this.calendarID + '_Timer';
this.objName = DateName + '_Object';
this.format = DateFormat;
this.formNumber = -1;
this.picked = null;
this.displayed = null;
this.previous = null;
this.next = null;
/* Methods */
this.setPicked = SetPickedMonth;
this.setDisplayed = SetDisplayedMonth;
this.checkYear = CheckYearInput;
this.fixYear = FixYearInput;
this.changeMonth = CheckMonthChange;
this.changeDay = CheckDayChange;
this.resetTimer = CalTimerReset;
this.hideElements = SetElementStatus;
this.show = ShowCalendar;
this.handleTimer = DoTimer;
this.iconHover = CalIconHover;
this.buildCalendar = BuildCalendarDays;
this.pickDay = PickDisplayDay;
this.fixSelects = FixSelectLists;
this.setHidden = new Function('D','if (this.formNumber >= 0) this.getHiddenField().value=D');
// Returns a reference to these elements
this.getHiddenField = new Function('return document.forms[this.formNumber].elements[this.hiddenFieldName]');
this.getMonthList = new Function('return document.getElementById(this.monthListID)');
this.getDayList = new Function('return document.getElementById(this.dayListID)');
this.getYearField = new Function('return document.getElementById(this.yearFieldID)');
this.getCalendar = new Function('return document.getElementById(this.calendarID)');
this.getDayTable = new Function('return document.getElementById(this.dayTableID)');
this.getCalendarLink = new Function('return document.getElementById(this.calendarLinkID)');
this.getMonthDisplay = new Function('return document.getElementById(this.monthDisplayID)');
this.isShowing = new Function('return !(this.getCalendar().style.visibility != \'visible\')');
/* Constructor */
// Functions used only by the constructor
function getMonthIndex(MonthAbbr) { // Returns the index (0-11) of the supplied month abbreviation
for (var MonPos=0;MonPos<MonthNames.length;MonPos++) {
if (MonthNames[MonPos].substr(0,3).toUpperCase() == MonthAbbr.toUpperCase()) break;
}
return MonPos;
}
function SetGoodDate(CalObj, Notify) { // Notifies the user about their bad default date, and sets the current system date
CalObj.setPicked(Today.getFullYear(), Today.getMonth(), Today.getDate());
if (Notify) alert('WARNING: The supplied date is not in valid \'' + DateFormat + '\' format: ' + DefaultDate + '.\nTherefore, the current system date will be used instead: ' + CalObj.picked.formatted);
}
// Main part of the constructor
if (DefaultDate != '') {
if ((this.format == 'YYYYMMDD') && (/^(\d{4})(\d{2})(\d{2})$/.test(DefaultDate))) this.setPicked(RegExp.$1, parseInt(RegExp.$2,10)-1, RegExp.$3);
else {
// Get the year
if ((this.format.substr(0,2) == 'YY') && (/^(\d{2,4})(-|\/)/.test(DefaultDate))) { // Year is at the beginning
var YearPart = GetGoodYear(RegExp.$1);
// Determine the order of the months and days
if (/(-|\/)(\w{1,3})(-|\/)(\w{1,3})$/.test(DefaultDate)) {
var MidPart = RegExp.$2;
var EndPart = RegExp.$4;
if (/D$/.test(this.format)) { // Ends with days
var DayPart = EndPart;
var MonthPart = MidPart;
}
else {
var DayPart = MidPart;
var MonthPart = EndPart;
}
MonthPart = (/\d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart);
this.setPicked(YearPart, MonthPart, DayPart);
}
else SetGoodDate(this, true);
}
else if (/(-|\/)(\d{2,4})$/.test(DefaultDate)) { // Year is at the end
var YearPart = GetGoodYear(RegExp.$2);
// Determine the order of the months and days
if (/^(\w{1,3})(-|\/)(\w{1,3})(-|\/)/.test(DefaultDate)) {
if (this.format.substr(0,1) == 'D') { // Starts with days
var DayPart = RegExp.$1;
var MonthPart = RegExp.$3;
}
else { // Starts with months
var MonthPart = RegExp.$1;
var DayPart = RegExp.$3;
}
MonthPart = (/\d{1,2}/i.test(MonthPart)) ? parseInt(MonthPart,10)-1 : getMonthIndex(MonthPart);
this.setPicked(YearPart, MonthPart, DayPart);
}
else SetGoodDate(this, true);
}
else SetGoodDate(this, true);
}
}
}
// Main function that creates the form elements
function DateInput(DateName, Required, DateFormat, DefaultDate) {
if (arguments.length == 0) document.writeln('<span style="color:red;font-size:' + FontSize + 'px;font-family:' + FontFamily + ';">ERROR: Missing required parameter in call to \'DateInput\': [name of hidden date field].</span>');
else {
// Handle DateFormat
if (arguments.length < 3) { // The format wasn't passed in, so use default
DateFormat = DefaultDateFormat;
if (arguments.length < 2) Required = false;
}
else if (/^(Y{2,4}(-|\/)?)?((MON)|(MM?M?)|(DD?))(-|\/)?((MON)|(MM?M?)|(DD?))((-|\/)Y{2,4})?$/i.test(DateFormat)) DateFormat = DateFormat.toUpperCase();
else { // Passed-in DateFormat was invalid, use default format instead
var AlertMessage = 'WARNING: The supplied date format for the \'' + DateName + '\' field is not valid: ' + DateFormat + '\nTherefore, the default date format will be used instead: ' + DefaultDateFormat;
DateFormat = DefaultDateFormat;
if (arguments.length == 4) { // DefaultDate was passed in with an invalid date format
var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate());
AlertMessage += '\n\nThe supplied date (' + DefaultDate + ') cannot be interpreted with the invalid format.\nTherefore, the current system date will be used instead: ' + CurrentDate.formatted;
DefaultDate = CurrentDate.formatted;
}
alert(AlertMessage);
}
// Define the current date if it wasn't set already
if (!CurrentDate) var CurrentDate = new storedMonthObject(DateFormat, Today.getFullYear(), Today.getMonth(), Today.getDate());
// Handle DefaultDate
if (arguments.length < 4) { // The date wasn't passed in
DefaultDate = (Required) ? CurrentDate.formatted : ''; // If required, use today's date
}
// Creates the calendar object!
eval(DateName + '_Object=new calendarObject(\'' + DateName + '\',\'' + DateFormat + '\',\'' + DefaultDate + '\')');
// Determine initial viewable state of day, year, and calendar icon
if ((Required) || (arguments.length == 4)) {
var InitialStatus = '';
var InitialDate = eval(DateName + '_Object.picked.formatted');
}
else {
var InitialStatus = ' style="visibility:hidden"';
var InitialDate = '';
eval(DateName + '_Object.setPicked(' + Today.getFullYear() + ',' + Today.getMonth() + ',' + Today.getDate() + ')');
}
// Create the form elements
with (document) {
writeln('<input type="hidden" name="' + DateName + '" value="' + InitialDate + '">');
// Find this form number
for (var f=0;f<forms.length;f++) {
for (var e=0;e<forms[f].elements.length;e++) {
if (typeof forms[f].elements[e].type == 'string') {
if ((forms[f].elements[e].type == 'hidden') && (forms[f].elements[e].name == DateName)) {
eval(DateName + '_Object.formNumber='+f);
break;
}
}
}
}
writeln('<table cellpadding="0" cellspacing="2"><tr>' + String.fromCharCode(13) + '<td valign="middle">');
writeln('<select class="calendarDateInput" id="' + DateName + '_Month_ID" onChange="' + DateName + '_Object.changeMonth(this)">');
if (!Required) {
var NoneSelected = (DefaultDate == '') ? ' selected' : '';
writeln('<option value=""' + NoneSelected + '>' + UnselectedMonthText + '</option>');
}
for (var i=0;i<12;i++) {
MonthSelected = ((DefaultDate != '') && (eval(DateName + '_Object.picked.monthIndex') == i)) ? ' selected' : '';
writeln('<option value="' + i + '"' + MonthSelected + '>' + MonthNames[i].substr(0,3) + '</option>');
}
writeln('</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle">');
writeln('<select' + InitialStatus + ' class="calendarDateInput" id="' + DateName + '_Day_ID" onChange="' + DateName + '_Object.changeDay(this)">');
for (var j=1;j<=eval(DateName + '_Object.picked.dayCount');j++) {
DaySelected = ((DefaultDate != '') && (eval(DateName + '_Object.picked.day') == j)) ? ' selected' : '';
writeln('<option' + DaySelected + '>' + j + '</option>');
}
writeln('</select>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '<td valign="middle">');
writeln('<input' + InitialStatus + ' class="calendarDateInput" type="text" id="' + DateName + '_Year_ID" size="' + eval(DateName + '_Object.picked.yearPad.length') + '" maxlength="' + eval(DateName + '_Object.picked.yearPad.length') + '" title="Year" value="' + eval(DateName + '_Object.picked.yearPad') + '" onKeyPress="return YearDigitsOnly(window.event)" onKeyUp="' + DateName + '_Object.checkYear(this)" onBlur="' + DateName + '_Object.fixYear(this)">');
write('<td valign="middle">' + String.fromCharCode(13) + '<a' + InitialStatus + ' id="' + DateName + '_ID_Link" href="javascript:' + DateName + '_Object.show()" onMouseOver="return ' + DateName + '_Object.iconHover(true)" onMouseOut="return ' + DateName + '_Object.iconHover(false)"><img src="' + ImageURL + '" align="baseline" title="Calendar" border="0"></a>&nbsp;');
writeln('<span id="' + DateName + '_ID" style="position:absolute;visibility:hidden;width:' + (CellWidth * 7) + 'px;background-color:' + CalBGColor + ';border:1px solid dimgray;" onMouseOver="' + DateName + '_Object.handleTimer(true)" onMouseOut="' + DateName + '_Object.handleTimer(false)">');
writeln('<table width="' + (CellWidth * 7) + '" cellspacing="0" cellpadding="1">' + String.fromCharCode(13) + '<tr style="background-color:' + TopRowBGColor + ';">');
writeln('<td id="' + DateName + '_Previous_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + '" onClick="' + DateName + '_Object.previous.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.previous.hover(this,true)" onMouseOut="return ' + DateName + '_Object.previous.hover(this,false)" title="' + eval(DateName + '_Object.previous.monthName') + '"><img src="' + PrevURL + '"></td>');
writeln('<td id="' + DateName + '_Current_ID" style="cursor:pointer" align="center" class="calendarDateInput" style="height:' + CellHeight + '" colspan="5" onClick="' + DateName + '_Object.displayed.goCurrent()" onMouseOver="self.status=\'Click to view ' + CurrentDate.fullName + '\';return true;" onMouseOut="self.status=\'\';return true;" title="Show Current Month">' + eval(DateName + '_Object.displayed.fullName') + '</td>');
writeln('<td id="' + DateName + '_Next_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:' + CellHeight + '" onClick="' + DateName + '_Object.next.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return ' + DateName + '_Object.next.hover(this,true)" onMouseOut="return ' + DateName + '_Object.next.hover(this,false)" title="' + eval(DateName + '_Object.next.monthName') + '"><img src="' + NextURL + '"></td></tr>' + String.fromCharCode(13) + '<tr>');
for (var w=0;w<7;w++) writeln('<td width="' + CellWidth + '" align="center" class="calendarDateInput" style="height:' + CellHeight + ';width:' + CellWidth + ';font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">' + WeekDays[w] + '</td>');
writeln('</tr>' + String.fromCharCode(13) + '</table>' + String.fromCharCode(13) + '<span id="' + DateName + '_DayTable_ID">' + eval(DateName + '_Object.buildCalendar()') + '</span>' + String.fromCharCode(13) + '</span>' + String.fromCharCode(13) + '</td>' + String.fromCharCode(13) + '</tr>' + String.fromCharCode(13) + '</table>');
}
}
}
function displaybeachpromoalert(url) {
var r=confirm("Your information has been submitted.\nWould you like to visit Duplinwinery.com?");
if (r==true){
window.location = "http://www.duplinwinery.com"
}
else{
window.location = url;
}
}
function initNodes2(){
var uls = document.getElementById('xmasstore').getElementsByTagName("ul");
var i;
//alert(uls.length);
//for(i = 0; i < uls.length; i++)
//if(uls[i].id != "root")
//uls[i].style.display = "none";
//uls[i].style.display = "";
}
function clickNode(id){
//alert(id);
var node = document.getElementById(id);
if(node.style.display == "none"){
if(navigator.appName == "Netscape"){
//document.write('<div id="windowbuttons" style="position:relative;margin-top:-30px;margin-bottom:25px;"></div>');
//alert(node2.style.display);
node.style.display = "block";
}
if(navigator.appName == "Microsoft Internet Explorer"){
//document.write('<div id="windowbuttons" style="position:relative;"></div>');
//alert(arr2);
node.style.display = "block";
//node2.style.display = "true";
}
}else{
node.style.display = "none";
}
return false;
}
function openNode(){
//alert(document.location);
//alert('here');
var url_string = String(document.location);
var url_array1 = url_string.split('?');
var e_array = url_array1[1].split('&');
pullE(e_array[2]);
}
function pullE(val){
var useVal = val.split('=');
//alert(useVal[1]); //display purposes
//clickNode(useVal[1]);
var id = useVal[1];
var node2 = document.getElementById(useVal[1]);
//alert(val);
if(node2.style.display == "none"){
if(navigator.appName == "Netscape"){
//document.write('<div id="windowbuttons" style="position:relative;margin-top:-30px;margin-bottom:25px;"></div>');
//alert(id);
node2.style.display = "block";
}
if(navigator.appName == "Microsoft Internet Explorer"){
node2.style.display = "block";
//node2.style.display = "true";
}
}else{
node.style.display = "none";
alert(node.style.display);
}
}
function startPopUp(data){
z = setTimeout("eventPopUp("+data+");",50);
}
function eventPopUp(evnt){
var node = document.getElementById("eventpopupTable");
node.style.display = "none";
//clearTimeout(t);
//alert(evnt);
var xx =  window.event.clientX;
var yy =  window.event.clientY;
//var ary = new Array(evnt);
var node = document.getElementById("eventpopupTable");
var nodeh = node.style.height;
nodeh = nodeh.replace("px", "");
var winh = screen.height-300;
var newy = (yy/winh)*nodeh;
//alert(newy);
//writeevnt(evnt);
//evnt = evnt.replace("!||", "<br>");
//var tevnt = evnt.split("||", "<br>");
document.getElementById("eventTitles").innerHTML = evnt;
if(node.style.display == "none"){
//alert(node.style.display);
node.style.position = "fixed";
node.style.left = xx+20;
node.style.top = yy-newy;
node.style.display = "block";
node.style.display = "true";
}else{
node.style.display = "none";
//alert(node.style.display);
}
clearTimeout(z);
}
function eventPopDown(){
clearTimeout(t);
var node = document.getElementById("eventpopupTable");
node.style.display = "none";
}
function startclear(){
t = setTimeout("closeevents();",400);
}
function cleartime(){
clearTimeout(t);
}
function closeevents(){
var node = document.getElementById("eventpopupTable");
node.style.display = "none";
clearTimeout(t);
}
function alrt(varb){
alert(varb);
}
var z = 0;
function checkwindowfolder2(arr,page) {
//alert('here');
var javaarray = new Array();
javaarray = arr.split(",")
var arr2 = new Array();
arr2 = javaarray.sort()
checkbrowser2(arr,page);
}
function checkwindowfolder3(arr,page) {
//alert('here');
var javaarray = new Array();
javaarray = arr.split(",")
var arr2 = new Array();
arr2 = javaarray.sort()
checkbrowser3(arr,page);
}
function checkbrowser2(arr,page){
document.cookie="timer=0";
document.write('<div id="largewindow" style="filter:progid:DXImageTransform.Microsoft.Fade(duration=1); -moz-opacity:1;background-color:black;"></div>');
//document.write('<div id="largewindow"></div><br>');
//document.write('<div><div>here2</div>');
if(navigator.appName == "Netscape"){
document.write('<div id="windowbuttons" style="position:relative;margin-top:-30px;margin-bottom:25px;"></div>');
flipimageNS2(arr,page);
//alert('here');
}
if(navigator.appName == "Microsoft Internet Explorer"){
document.write('<div id="windowbuttons" style="position:relative;"></div>');
flipimageEI2(arr,page);
//alert(arr2);
}
if(navigator.appName == "WebTV"){
//alert("You're using the WebTV browser.")
}
}
function checkbrowser3(arr,page){
document.cookie="timer=0";
document.write('<div id="largewindow" style="filter:progid:DXImageTransform.Microsoft.Fade(duration=1); -moz-opacity:1;background-color:black;"></div>');
//document.write('<div id="largewindow"></div><br>');
//document.write('<div><div>here2</div>');
if(navigator.appName == "Netscape"){
document.write('<div id="windowbuttons" style="position:relative;margin-top:-30px;margin-bottom:25px;"></div>');
flipimageNS3(arr,page);
//alert('here');
}
if(navigator.appName == "Microsoft Internet Explorer"){
document.write('<div id="windowbuttons" style="position:relative;"></div>');
flipimageEI3(arr,page);
//alert(arr2);
}
if(navigator.appName == "WebTV"){
//alert("You're using the WebTV browser.")
}
}
function flipimageEI3(jarray,page){
//var ja = jarray.sort();
	var ja3= new Array();
	ja3 = jarray.split(",");
	ja3.sort()
	var numbr2 = ja3.length;
	//alert(ja3[5]);
	//document.getElementById("largewindow").innerHTML = numbr2;
	//var ja= jarray;
	//ja = jarray.split(",");
	if (document.getElementById("largewindow").filters) {//if browser supports IE filters and it is defined on the object
		document.getElementById("largewindow").filters[0] //access the first filter within object, in this case, the Fade filter
	}
	if(z <= (numbr2-1)){
		a=document.getElementById("largewindow");
		a.filters[0].apply();
		//alert(page+"/" +ja3[z]);
		a.innerHTML = "<?php include(\"uploads/images/?>"+page+"/" +ja3[z] + "<?php echo \");\"; ?>";
		//a.src = "uploads/images/"+page+"/"+ja3[z];
		//alert(z);
		a.filters[0].play();
		z = z+1;
		}else{
		//stoptimer();
		z = 0;
		a=document.getElementById("largewindow");
		a.filters[0].apply();
		a.innerHTML = "<img name=\"content\" width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +ja3[z] + "\">";
		a.filters[0].play();
		//alert(z);
		//flipimageEI2("\""+ja3+"\",'"+page+"'");
		z = 1;
	}
	createwindowbuttons(numbr2,ja3,page,z);
	document.cookie="imagelist="+ja3;
	document.cookie="page="+page;
	//winint4 = setTimeout("flipimageEI2('"+ja3+"','"+page+"');", 9000);
}
function flipimageEI2(jarray,page){
//var ja = jarray.sort();
	var ja3= new Array();
	ja3 = jarray.split(",");
	ja3.sort()
	var numbr2 = ja3.length;
	//alert(ja3[5]);
	//document.getElementById("largewindow").innerHTML = numbr2;
	//var ja= jarray;
	//ja = jarray.split(",");
	if (document.getElementById("largewindow").filters) {//if browser supports IE filters and it is defined on the object
		document.getElementById("largewindow").filters[0] //access the first filter within object, in this case, the Fade filter
	}
	if(z <= (numbr2-1)){
		a=document.getElementById("largewindow");
		a.filters[0].apply();
		a.innerHTML = "<iframe name=\"content\" type=\"text/html\" width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +ja3[z] + "\" frameborder=\"0\" SCROLLING=\"no\"></iframe><br>";
		//a.src = "uploads/images/"+page+"/"+ja3[z];
		//alert(z);
		a.filters[0].play();
		z = z+1;
		}else{
		//stoptimer();
		z = 0;
		a=document.getElementById("largewindow");
		a.filters[0].apply();
		a.innerHTML = "<iframe name=\"content\" width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +ja3[z] + "\" frameborder=\"0\" SCROLLING=\"no\"></iframe>";
		a.filters[0].play();
		//alert(z);
		//flipimageEI2("\""+ja3+"\",'"+page+"'");
		z = 1;
	}
	createwindowbuttons(numbr2,ja3,page,z);
	document.cookie="imagelist="+ja3;
	document.cookie="page="+page;
	//winint4 = setTimeout("flipimageEI2('"+ja3+"','"+page+"');", 9000);
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{ 
c_start=c_start + c_name.length+1; 
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
} 
}
return "";
}
function startflip2(){
var ja3 = document.cookie.match ('(^|;)?imagelist=([^;]*)(;|$)');
var page = document.cookie.match ('(^|;)?page=([^;]*)(;|$)');
//var timer = document.cookie.match ('(^|;)?timer=([^;]*)(;|$)');
var timer = getCookie('timer');
//alert(timer);
page = unescape(page[2]);
ja3 = unescape(ja3[2]);
//alert(timer);
//alert(getCookie('timer'));
//alert(getCookie('page'));
if(navigator.appName == "Netscape"){
//timer = unescape(timer[2]);
//alert(getCookie('page'));
if(timer == null || timer == 0){
//alert('here');
winint4 = setTimeout("flipimageNS2('"+ja3+"','"+page+"');", 9000);
}
}else if(navigator.appName == "Microsoft Internet Explorer"){
//
//timer = unescape(timer[2]);
if(timer == '0'){
winint4 = setTimeout("flipimageEI2('"+ja3+"','"+page+"');", 9000);
}
}
}
function gotopage(url) {
window.location = url;
}
var count2 = 0;
function flipimageNS2(jarray2,page){
var javaarray3 = new Array();
javaarray3 = jarray2.split(",");
var numbr3 = javaarray3.length;
javaarray3.sort();
//var count = 0;
var inc = true;
if(z <= numbr3-1){
a=document.getElementById("largewindow");
a.innerHTML = "<iframe name=\"content\" width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +javaarray3[z] + "\" frameborder=\"0\" SCROLLING=\"no\"></iframe>";
//a.innerHTML = "<script src=\"uploads/images/"+page+"/" +javaarray3[z] + "\">
z = z+1;
//alert("here");
//alert(a.src);
//doFade();
}else{
//alert("here");
//stoptimer();
z = 0;
a=document.getElementById("largewindow");
a.innerHTML = "<iframe name=\"content\" width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +javaarray3[z] + "\" frameborder=\"0\" SCROLLING=\"no\"></iframe>";
z = 1;
//clearTimeout(winint);
//alert(a.src);
}
createwindowbuttonsNS(numbr3,javaarray3,page,z);
//winint5=setTimeout("flipimageNS2('"+javaarray3+"','"+page+"');", 9000);
document.cookie="imagelist="+javaarray3;
document.cookie="page="+page;
}
function doFade2() {
count = (inc) ? count+0.1 : count-0.1;
//alert(a);
a.style.MozOpacity = count;
if(count >= 0.9){
inc = false;
//clearTimeout(winint2);
}
if(count <= 0.1){
inc = true;
//clearTimeout(winint2);
}
winint6=setTimeout("doFade2('"+a+"');", 2000);
}
function stoptimer(){
clearTimeout(t);
}
function createwindowbuttons2(numb,arrays,page,z){
//alert(arrays);
var j = "";
c=document.getElementById("windowbuttons");
//b.filters[0].apply()
for(h = 1;h<=numb;h++){
if(h == z){
j = j+"<a style=\"z-index:"+500+h+"; position:relative; top:-30px; bottom:-30px; padding: 3px 5px 3px 5px; margin-left:4px;border:1px solid #ffffff;\" onMouseUp=\"gotowindow("+(h-1)+",'"+arrays+"','"+page+"'), createwindowbuttons("+numb+",'"+arrays+"','"+page+"',"+h+")\">"+h+"</a>";
}else if(h != z){
j = j+"<a style=\"z-index:"+500+h+"; position:relative; top:-30px; bottom:-30px; padding: 3px 5px 3px 5px; margin-left:4px;\" onMouseUp=\"gotowindow("+(h-1)+",'"+arrays+"','"+page+"'), createwindowbuttons("+numb+",'"+arrays+"','"+page+"',"+h+")\">"+h+"</a>";
}
}
c.innerHTML = j;
}
function createwindowbuttonsNS2(numb,arrays,page,z){
//alert(arrays);
var j = "";
c=document.getElementById("windowbuttons");
//b.filters[0].apply()
for(h = 1;h<=numb;h++){
if(h == z){
j = j+"<a style=\"z-index:700; margin-left:4px;  padding:3px 5px 3px 5px;border:1px solid #ffffff;\" onMouseUp=\"gotowindow("+(h-1)+",'"+arrays+"','"+page+"'), createwindowbuttonsNS("+numb+",'"+arrays+"','"+page+"',"+h+")\">"+h+"</a>";
}else if(h != z){
j = j+"<a style=\"z-index:700; margin-left:4px; padding:3px 5px 3px 5px;\" onMouseUp=\"gotowindow("+(h-1)+",'"+arrays+"','"+page+"'), createwindowbuttonsNS("+numb+",'"+arrays+"','"+page+"',"+h+")\">"+h+"</a>";
}
}
c.innerHTML = j;
}
function gotowindow(d,b,page){
//alert(b.length);
//document.cookie="timer=stopped";
clearTimeout(winint4)
document.cookie="timer=1";
var arr = new Array();
arr = b.split(",");
a=document.getElementById("largewindow");
//a.filters[0].apply()
a.innerHTML = "<iframe width=\"955\" height=\"421\" src=\"uploads/images/"+page+"/" +arr[d] + "\" frameborder=\"0\" SCROLLING=\"no\"></iframe>";
//a.innerHTML = "<?php echo \"here\";?>";
//alert(arr[d]);
}
function checkUrl(){
var browUrl = document.location.href;
//document.write (browUrl); 
if(browUrl == 'http://duplinwinery.com/'){
window.location = "http://www.duplinwinery.com"
} 
}
function OpenDistributor(){
//alert('here');
document.open("http://www.duplinwinery.com/phpincludes/distributor.php","","width=600,height=800"); 

}
function DisplayCruiseDiv(DivID){
	//alert(DivID);
	for(z=0;z<7;z++){
		//alert(z);
		document.getElementById(z).style.display = "none";
	}
	//alert(DivID);
	document.getElementById(DivID).style.display = "block";
}
function setCookie(c_name,value)
{

document.cookie=c_name+ "=" +escape(value);
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function checkCookie()
{
//alert(getCookie('username'));
username=getCookie('username');

if (username!=null && username!="")
  {
  //alert("Cookies Work");
  }
else
  {
  //username=prompt('Please enter your name:',"");
  //alert("cookie");
  
	alert("If your login failed, and you are sure you entered the correct password. Please check to make sure you have cookies enabled on your web browser.");
    
	//alert(getCookie('username'));
    
  }
}
//document.onload = setCookie('username','CookiesWork');
//document.onload = checkCookie();