function FashioncraftGlassware(line1,line2,date,font,glass_image,design,quantity,color) {
	var transferTo = "cart";
	var formToSubmit = "cart";
	design = design.split( "." )[0];
	var designMap = new Array();
	designMap["25th-anniversary"] = "A_001";
	designMap["50th-anniversary"] = "A_002";
	designMap["amor"] = "A_003";
	designMap["amor-classic"] = "A_004";
	designMap["angel"] = "A_005";
	designMap["angel-2"] = "A_006";
	designMap["a-toast"] = "A_007";
	designMap["antique-key"] = "A_008";
	designMap["autumn"] = "A_009";
	designMap["autumn-breeze-leaves"] = "A_010";
	designMap["autumn-pair-leaves"] = "A_011";
	designMap["autumn-single-leaf"] = "A_012";
	designMap["baby-bib"] = "B_001";
	designMap["baby-bottle"] = "B_002";
	designMap["baby-carriage"] = "B_003";
	designMap["baby-crawling"] = "B_004";
	designMap["baby-crib"] = "B_005";
	designMap["baby-on-board"] = "B_006";
	designMap["baby-on-board-2"] = "B_007";
	designMap["baby-on-board-3"] = "B_008";
	designMap["baby-feet"] = "B_009";
	designMap["baby-pacifier"] = "B_010";
	designMap["baby-rocking-horse"] = "B_011";
	designMap["baby-rubber-duck"] = "B_012";
	designMap["baby-shoe"] = "B_013";
	designMap["baby-stork"] = "B_014";
	designMap["baby-teddy-bear-1"] = "B_015";
	designMap["baby-teddy-bear-2"] = "B_016";
	designMap["ballet"] = "B_017";
	designMap["balloons"] = "B_018";
	designMap["baseball"] = "B_019";
	designMap["basketball"] = "B_020";
	designMap["bet-on-love"] = "B_021";
	designMap["bride-and-groom-signature"] = "B_022";
	designMap["bride-and-groom-love"] = "B_023";
	designMap["bride-and-groom-modern"] = "B_024";
	designMap["bride-&-groom-silhouette"] = "B_025";
	designMap["bun-in-oven"] = "B_026";
	designMap["butterfly"] = "B_027";
	designMap["calla-lilly"] = "C_001";
	designMap["castle"] = "C_002";
	designMap["castle-2"] = "C_003";
	designMap["celebrate"] = "C_004";
	designMap["25-champange"] = "C_005";
	designMap["40-champange"] = "C_006";
	designMap["50-champange"] = "C_007";
	designMap["cherry-blossom"] = "C_008";
	designMap["claddah"] = "C_009";
	designMap["communion"] = "C_010";
	designMap["corset"] = "C_011";
	designMap["chandelier"] = "C_012";
	designMap["cross"] = "C_013";
	designMap["crown"] = "C_014";
	designMap["cupid"] = "C_015";
	designMap["damask"] = "D_001";
	designMap["double-happiness"] = "D_002";
	designMap["double-signature-hearts"] = "D_003";
	designMap["dove"] = "D_004";
	designMap["dragonfly"] = "D_005";
	designMap["engagement-ring"] = "E_001";
	designMap["engagement-ring-2"] = "E_002";
	designMap["fall-for-love"] = "F_001";
	designMap["fan-white"] = "F_002";
	designMap["film"] = "F_003";
	designMap["fleur-di-lis"] = "F_004";
	designMap["flourish-15"] = "F_005";
	designMap["flourish-16"] = "F_006";
	designMap["flourish-21"] = "F_007";
	designMap["flourish-25"] = "F_008";
	designMap["flourish-40"] = "F_009";
	designMap["flourish-50"] = "F_010";
	designMap["football"] = "F_011";
	designMap["forever-in-love"] = "F_012";
	designMap["four-leaf-clover"] = "F_013";
	designMap["glam-girl"] = "G_001";
	designMap["glass-slipper"] = "G_002";
	designMap["golf"] = "G_003";
	designMap["good-fortune"] = "G_004";
	designMap["graduation"] = "G_005";
	designMap["graduation-books-with-year"] = "G_006";
	designMap["graduation-with-year"] = "G_007";
	designMap["graduate-boy"] = "G_008";
	designMap["graduate-girl"] = "G_009";
	designMap["handbag"] = "H_001";
	designMap["happy-anniversary"] = "H_002";
	designMap["happy-bar-mitzvah"] = "H_003";
	designMap["happy-birthday"] = "H_004";
	designMap["happy-couple"] = "H_005";
	designMap["heart-bow"] = "H_006";
	designMap["heart-car"] = "H_007";
	designMap["heart-burst"] = "H_008";
	designMap["hearts-two"] = "H_009";
	designMap["horseshoe"] = "H_010";
	designMap["its-a-boy"] = "I_001";
	designMap["its-a-girl"] = "I_002";
	designMap["kissing-fish"] = "K_001";
	designMap["koi-fish"] = "K_002";
	designMap["las-vegas"] = "L_001";
	designMap["las-vegas-2"] = "L_002";
	designMap["last-fling-before-the-ring"] = "L_003";
	designMap["license-plate"] = "L_004";
	designMap["like-milk-and-cookies"] = "L_005";
	designMap["lol-computer"] = "L_006";
	designMap["love"] = "L_007";
	designMap["love-banner"] = "L_008";
	designMap["love-beyond-measure"] = "L_009";
	designMap["love-birds"] = "L_010";
	designMap["love-blooms"] = "L_011";
	designMap["love-dice"] = "L_012";
	designMap["love-heart"] = "L_013";
	designMap["love-rocks"] = "L_014";
	designMap["love-travels"] = "L_015";
	designMap["martini"] = "M_001";
	designMap["moon-and-the-stars"] = "M_002";
	designMap["music"] = "M_003";
	designMap["night-on-the-town"] = "N_001";
	designMap["nuestra-boda"] = "N_002";
	designMap["ornate-cross"] = "O_001";
	designMap["ornament"] = "O_002";
	designMap["pagoda"] = "P_001";
	designMap["paris"] = "P_002";
	designMap["peace"] = "P_003";
	designMap["peace-sign"] = "P_004";
	designMap["piano"] = "P_005";
	designMap["piece-of-cake"] = "P_006";
	designMap["penguins"] = "P_007";
	designMap["perfect-pair"] = "P_008";
	designMap["present"] = "P_009";
	designMap["prom"] = "P_010";
	designMap["religious-boy"] = "R_001";
	designMap["religious-girl"] = "R_002";
	designMap["retired-at-last"] = "R_003";
	designMap["rose"] = "R_004";
	designMap["sassy-high-heel"] = "S_001";
	designMap["scribble-wine"] = "S_002";
	designMap["sea-shell"] = "S_003";
	designMap["seasons-autumn-ornament"] = "S_004";
	designMap["seasons-winter-ornament"] = "S_005";
	designMap["sheep"] = "S_006";
	designMap["showers-of-happiness"] = "S_007";
	designMap["showers-of-happiness-2"] = "S_008";
	designMap["single-signature-heart"] = "S_009";
	designMap["s'more"] = "S_010";
	designMap["snowflake"] = "S_011";
	designMap["snowflake-stamp"] = "S_012";
	designMap["snowman"] = "S_013";
	designMap["soccer"] = "S_014";
	designMap["star-of-david"] = "S_015";
	designMap["sugar-and-spice"] = "S_016";
	designMap["swak"] = "S_017";
	designMap["swans"] = "S_018";
	designMap["sweet-15-crown"] = "S_019";
	designMap["sweet-16-crown"] = "S_020";
	designMap["sweet-quinceañera-heart"] = "S_021";
	designMap["sweet-16-heart"] = "S_022";
	designMap["sweet-15-shoe"] = "S_023";
	designMap["sweet-16-shoe"] = "S_024";
	designMap["sweet-things"] = "S_025";
	designMap["tea-time"] = "T_001";
	designMap["torah"] = "T_002";
	designMap["torah-2"] = "T_003";
	designMap["tropical-paradise"] = "T_004";
	designMap["tropical-paradise-drink"] = "T_005";
	designMap["two-peas-in-a-pod"] = "T_006";
	designMap["wedding-bells"] = "W_001";
	designMap["wedding-cake"] = "W_002";
	designMap["wedding-cake-stamp"] = "W_003";
	designMap["were-engaged"] = "W_004";
	designMap["windy-silhouette"] = "W_005";
	designMap["wine-country"] = "W_006";
	designMap["wine-glasses"] = "W_007";
	designMap["xxxooo"] = "X_001";
	designMap["xoxo-xoxo"] = "X_002";
	designMap["ying-yang"] = "Y_001";
	// new designs
	designMap["a-lovely-toast"] = "A_013";
	designMap["baby-blocks"] = "B_028";
	designMap["baby-shoes"] = "B_029";
	designMap["baby-shower"] = "B_030";
	designMap["baby-shower-2"] = "B_031";
	designMap["baby-shower-bear"] = "B_032";
	designMap["baby-shower-carriage"] = "B_033";
	designMap["bride-groom-bear"] = "B_034";
	designMap["chai"] = "C_016";
	designMap["cheers"] = "C_017";
	designMap["congratulations"] = "C_018";
	designMap["cruise"] = "C_019";
	designMap["directors-chair"] = "D_006";
	designMap["doves"] = "D_007";
	designMap["drama"] = "D_008";
	designMap["eat-drink-and-be-married"] = "E_003";
	designMap["fireworks"] = "F_014";
	designMap["first-communion"] = "F_015";
	designMap["ganesha"] = "G_010";
	designMap["i-love-you"] = "I_003";
	designMap["just-married"] = "J_001";
	designMap["mardi-gras"] = "M_004";
	designMap["prayer"] = "P_011";
	designMap["seasons-greetings"] = "S_026";
	designMap["skull-and-crossbones"] = "S_027";
	designMap["baseball-silhouette"] = "S_028";
	designMap["baseball-woman-silhouette"] = "S_029";
	designMap["football-silhouette"] = "S_030";
	designMap["man-guitar"] = "S_031";
	designMap["woman-guitar"] = "S_032";
	designMap["ice-hockey-silhouette"] = "S_033";
	designMap["roller-hockey-silhouette"] = "S_034";
	designMap["running-man-silhouette"] = "S_035";
	designMap["running-woman-silhouette"] = "S_036";
	designMap["skateboard-silhouette"] = "S_037";
	designMap["skiier-silhouette"] = "S_038";
	designMap["thank-you"] = "T_007";
	designMap["wine-glasses-2"] = "W_008";
	designMap["young-love"] = "Y_002";
	// monograms etc
	designMap["noDesign"] = "noDesign";
	designMap["monogram3"] = "mono_3L";
	designMap["monogram1-d"] = "mono_1LD";
	designMap["monogram1-nd"] = "mono_1LND";
	// replaced designs
	designMap["o_003"] = "O_003";
	designMap["k_003"] = "K_003";
	designMap["f_016"] = "F_016";

	var transferOptions = new Array();
	transferOptions["className"] = "ui-effects-transfer";
	if ( transferTo != "" && $("#" + transferTo).length ) {
		transferOptions["to"] = "#" + transferTo;
	}
	if ( color == "Fusicha" ) {
		color = "Fuischa";
	} else if ( color == "" || color == "null" ) {
		color = "Black";
	}
	
	//transferOptions = { to: "#" + transferTo, className: 'ui-effects-transfer' };

	var design = designMap[design];
	$('#designnum option').each(function(){
		if (strstr($(this).text(), design)) {
			design = $(this).val();
		}
	});

	var color = color.replace("-", " ").toLowerCase();
	$('#screened option').each(function(){
		if (strstr($(this).text().toLowerCase(), color)) {
			color = $(this).val();
		}
	});

	var font = font.replace("-", " ").toLowerCase();
	$('#Font option').each(function(){
		if (strstr($(this).text().toLowerCase(), font)) {
			font = $(this).val();
		}
	});

	$("#Font").val( font );
	$("#designnum").val( design );
	$("#screened").val( color );
	$("#Text-Line-1").val( line1 );

	if ( date != "null" && $("#Text-Line-2").length ) { $("#Text-Line-2").val( date ); }
	if ( date != "null" && $("#FashioncraftGlasswareDate").length ) { $("#FashioncraftGlasswareDate").val( date ); }
	if ( line2 != "null" && $("#Text-Line-2").length ) { $("#Text-Line-2").val( line2 ); }



	$("#cart_quantity").val( quantity );
	if ( $(transferOptions["to"]).length ) {
		$("#fashioncraftGlasswarePopup").effect( "transfer", transferOptions, 500, function(){
			if ( formToSubmit != "" ) {
				//alert("ok");//$("#" + formToSubmit).submit();
			}
		});
		$("#fashioncraftGlasswarePopup").dialog( "close" );
	} else {
		$("#fashioncraftGlasswarePopup").dialog( "close" );
		if ( formToSubmit != "" && $("#" + formToSubmit).length ) {
			//alert("ok");//$("#" + formToSubmit).submit();
		}
	}
} // function FashioncraftGlassware(line1,line2,date,font,glass_image,design,quantity,color) {

function strstr (haystack, needle, bool) {
    // Finds first occurrence of a string within another  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/strstr    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strstr('Kevin van Zonneveld', 'van');
    // *     returns 1: 'van Zonneveld'    // *     example 2: strstr('Kevin van Zonneveld', 'van', true);
    // *     returns 2: 'Kevin '
    // *     example 3: strstr('name@example.com', '@');
    // *     returns 3: '@example.com'
    // *     example 4: strstr('name@example.com', '@', true);    // *     returns 4: 'name'
    var pos = 0;
    
    haystack += '';
    pos = haystack.indexOf( needle );    if (pos == -1) {
        return false;
    } else{
        if (bool){
            return haystack.substr( 0, pos );        } else{
            return haystack.slice( pos );
        }
    }
}

function str_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/str_replace    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }
     for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}        }
    }
    return sa ? s : s[0];
}


jQuery(document).ready(function(){
	jQuery("head").append("<link rel=\"stylesheet\" href=\"/fashioncraftGlassware/advanced/style.css\" type=\"text/css\">");
	if ( jQuery(".fashioncraftGlasswareLink").length ) {
		jQuery(".fashioncraftGlasswareLink").click(function(event){
			event.preventDefault();
			if ( jQuery("#fashioncraftGlasswarePopup").length ) {
				jQuery("#fashioncraftGlasswarePopup").load( jQuery(this).attr( "href" ) ).dialog( "open" );
			} else {
				jQuery("body").append( "<div id=\"fashioncraftGlasswarePopup\" title=\"Design Your Glassware\" style=\"display: none;\"></div>");
				jQuery("#fashioncraftGlasswarePopup").load( jQuery(this).attr( "href" ), function(){
					jQuery(this).dialog({
						height: 640,
						width: 840
					});
				});
			}			
			return false;
		});
	}
});
