var nvp_array = new Array;
function nvp_struct(){
		var args = nvp_struct.arguments;
		this.nvp_qvpair = args[0];
		this.nvp_var = args[1];
		this.nvp_value = args[2];
}

function nvp_parse(){
	var querystring = location.search; nvp = querystring.indexOf('&'); searchstring = "true"; prev_nvp = 1; x = 0;
	do {
	if (nvp == -1){nvp = querystring.length; searchstring = "false";}
	var nvp_qvpair = querystring.substring(prev_nvp, nvp); nvp_var = nvp_qvpair.substring(0, nvp_qvpair.indexOf('=')); nvp_value = nvp_qvpair.substring(nvp_qvpair.indexOf('=')+1);
	nvp_array[x] = new nvp_struct(nvp_qvpair,nvp_var,nvp_value); querystring = querystring.substring(nvp + 1,querystring.length);
	if(querystring == null){searchstring = "false"} else {var prev_nvp = 0;		nvp = querystring.indexOf('&');		x++;}
	} while (searchstring == "true")
}

function nvp_get(){
	var args = nvp_get.arguments; nvpsearch = args[0]; nvpvalue = "noval"; nvp_length = nvp_array.length;
	for (var x = 0; x != nvp_length; x++){
		if(nvp_array[x].nvp_var == nvpsearch){nvpvalue = nvp_array[x].nvp_value};
	}
return nvpvalue;
}

function createProductPage(id,image,hasSTD,seq,name,purchaseURL,stdURL, copy){
	arg = createProductPage.arguments;
	this.id = id;
	this.image = image;
	this.hasSTD= hasSTD;
	this.seq = seq;
	this.name = name;
	this.purchaseURL = purchaseURL;
	this.stdURL = stdURL;
	this.copy = copy;
}

product_array = new Array;
product_array[0] = new createProductPage(26,'img/wine_detail.jpg',false,1,'Winery Wedding','http://www.etsy.com/listing/76927011/winery-wedding','','Raise your glass to this winery wedding invitation set! An elegant pattern covers each piece. Look closer, and you\'ll see wine bottles! This invitation is neatly held together with a belly band.');

product_array[1] = new createProductPage(25,'img/product/teafortwo_invite_detail.jpg',false,1,'Tea for Two','http://www.etsy.com/listing/63444257/tea-for-two-sample','','This invite might just be your cup of tea! A modern spin on lace and a matching monogram containing the happy couple\'s initials serve up quite the stationery set.');

product_array[2] = new createProductPage(24,'img/product/peacock_invite_detail.jpg',true,2,'Peacock','http://www.etsy.com/listing/58835188/peacock-invitation','save-date-detail.html?product=13','Birds of a feather come together in this sophisticated design. All pieces are held together with a belly band enscribed with your names and wedding date. Stay with the traditional hues of a peacock feather, or mix it up to match your palette! ');

product_array[3] = new createProductPage(20,'img/product/helovesme_detail.jpg',false,3,'He Loves Me...','http://www.etsy.com/view_listing.php?listing_id=43294271','','A spring shower of petals adorn this custom-color invitation set. Each pocketfold contains an invitation and four tiered inserts. Keep the scheme pretty in pink, or coordinate with your wedding palette.');
product_array[4] = new createProductPage(21,'img/product/tres_chic_detail.jpg',false,4,'Tres Chic','http://www.etsy.com/view_listing.php?listing_id=43295212','','Whether you\'re planning your big day in the City of Light, or simply want to add a little "je ne sais quoi," this French-inspired design features bold damask, elegant flowers and subtle stripes. All pieces are held together with a striped paper band adorned with your wedding monogram.');
product_array[5] = new createProductPage(22,'img/product/boarding_pass_invite-detail.jpg',true,5,'Boarding Pass','http://www.etsy.com/view_listing.php?listing_id=43295553','save-date-detail.html?product=2','If you\'re planning a destination wedding (or just love to travel), these unique boarding pass invitations are a must. A colorful folder holds all the information guests will need. Choose a palm tree, modern flower, tropical flower or starfish motif--or, we can work together to create a custom design.');
product_array[6] = new createProductPage(23,'img/product/marryandbright_detail.jpg',false,6,'Marry & Bright','http://www.etsy.com/view_listing.php?listing_id=43295986','','No winter wedding is complete without a little snow. Custom-color snowflakes decorate this invitation set, backed by a shimmering card and all wrapped with a decorative paper band.');

product_array[7] = new createProductPage(1,'img/product/bloomsandstripes.jpg',false,7,'Blooms and Stripes','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=20152159','','Show off your wedding information with a bit of drama. Bold flowers and elegant stripes come together in this sophisticated design. All pieces are held together with a striped paper band.');
product_array[8] = new createProductPage(2,'img/product/tiered-damask.jpg',false,8,'Tiered Damask','http://www.etsy.com/view_listing.php?listing_id=29030694','','A layered effect is created by attaching a bold backer card to this design with matching brads. Pair it with a contrasting envelope for a stunning set.');
product_array[9] = new createProductPage(3,'img/product/black-tie-pocket.jpg',false,9,'Black Tie Pocketfold','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=21484400','','Bold color and white contrasts for a striking presentation. Each pocketfold contains and invitation and four tiered inserts. Choose white, or a color from your wedding palette.');
product_array[10] = new createProductPage(4,'img/product/inv_gardenparty.jpg',true,10,'Garden Party','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=23171790','save-date-detail.html?product=8','Spring blooms with hydrangeas and peonies on this invitation set. Bold flowers and stripes come together in this elegant design. All pieces are held together with a striped paper band.');
product_array[11] = new createProductPage(5,'img/product/inv_oohlala.jpg',false,11,'Ooh La La','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=17715811','','Whimsical yet elegant, this bold design practically leaps off the paper. Perfect for summer weddings, or a particularly boisterous guest list.');
product_array[12] = new createProductPage(6,'img/product/inv_formalfronds.jpg',false,12,'Formal Fronds','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=23881105','','Layers adhere together to reveal a beautiful fern frond. Perfect for nature lovers or an outdoor wedding.');
product_array[13] = new createProductPage(7,'img/product/inv_surfsup.jpg',false,13,'Surf’s Up','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=15416505','','An ocean-side wedding calls for a dramatic splash of color. Staying local? This bold seaside feel will stand out in your guests’ mailbox. Choose one of our custom stamps to complete the look.');
product_array[14] = new createProductPage(8,'img/product/inv_moderndots.jpg',true,14,'Modern Dots','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=21484506','save-date-detail.html?product=7','A clean, graphic look for a modern touch. This invitation brings in your wedding colors and showcases them in style. Optional wrap-around address label is a Marit Hanson specialty.');
product_array[15] = new createProductPage(9,'img/product/inv_weheartny.jpg',false,15,'We Heart NY','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=29030450','','Whether your big day is in the city or it played a role in your courtship, let these famous icons set the scene. “Heart” another major city? We can talk about customization.');
product_array[16] = new createProductPage(10,'img/product/inv_artdeco.jpg',true,16,'Art Deco','http://www.etsy.com/view_listing.php?listing_id=29394128','save-date-detail.html?product=12','Step back in time with this striking Art Deco design. A layered effect is created by attaching a bold backer card to this invitation with matching brads.');
product_array[17] = new createProductPage(11,'img/product/inv_serendipity.jpg',false,17,'Serendipity','http://www.etsy.com/view_listing.php?listing_id=29428475','','Warm, natural tones and rich textures set this design apart. All pieces are held together with a belly band enscribed with your names and wedding date.');
product_array[18] = new createProductPage(12,'img/product/inv_justberried.jpg',false,18,'Just Berried','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=28067541','','Classic line art of autumn branches and berries adorn these cheery invitations. Stay with our seasonal hues, or personalize them with custom colors.');
product_array[19] = new createProductPage(13,'img/product/inv_cherryblossom.jpg',false,19,'Cherry Blossom','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=14375465','','Sweet and delicate, cherry blossoms are one of the first signs of spring. Let them frame your wedding details, and serve as a keepsake for guests.');
product_array[20] = new createProductPage(14,'img/product/inv_tealengthdamask.jpg',false,20,'Tea-Length Damask','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=21484784','','Black and white stand out against a colorful card stock. Longer length is elegant, and will stand out in your guests\' mailbox.');
product_array[21] = new createProductPage(15,'img/product/inv_vintagerose.jpg',false,21,'Vintage Rose','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=15152154','','Tradition takes a modern turn with this rose pattern in a bright, unexpected color. Sophisticated and elegant.');
product_array[22] = new createProductPage(16,'img/product/go-green.jpg',false,22,'Go Green!','http://www.etsy.com/listing/53262420/go-green-invitation-sample','','The grass is greener with these invitations! RSVP is a postcard. Not only will you save on the cost of envelopes, you\'ll also pay less postage. And you know what that means? <br/>You’re saving trees as well!');
product_array[23] = new createProductPage(17,'img/product/inv_kabloom.jpg',false,23,'Ka-BLOOM!','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=29030644','','Open this envelope and be wowed by a burst of colorful blooms. The perfect look for spring weddings, small gatherings or simply making a statement.');
product_array[24] = new createProductPage(18,'img/product/inv_monogramdamask.jpg',false,24,'Monogrammed Damask','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=21484343','','Show off your future last name with a classic monogram against a traditional damask pattern. Accent color and envelope can be tailored to match your wedding colors.');
product_array[25] = new createProductPage(19,'img/product/inv_callalily.jpg',false,25,'Calla Lilies','http://www.etsy.com/view_listing.php?ref=vl_other_2&listing_id=22061323','','One of the most beautiful wedding flowers comes to life on these classic invitations. I\'ve chosen a fall palette, but this design looks equally graceful in spring greens or summer hues.');









$(document).ready(function() {
	nvp_parse();
	setProductPage();
	function setProductPage(){
		var prodId = nvp_get('product');
		for(var i = 0; i < product_array.length; i++){
			if(product_array[i].id == prodId){
				//set seq num
				$("#currSeq").html(product_array[i].seq);
				$("#totalSeq").html(product_array.length);
				if(product_array[i].seq != 1){
					$("#prevnext-01").html('<a href="invitations-detail.html?product='+(product_array[i-1].id)+'"><span>next</span></a>');
				}
				if(product_array[i].seq != product_array.length){
					$("#prevnext-02").html('<a href="invitations-detail.html?product='+(product_array[i+1].id)+'"><span>next</span></a>');
				}
				//set img
				$("#productImg").attr("src", product_array[i].image);
				//Set name
				$("#prodName").html(product_array[i].name);
				//Set copy
				$("#prodCopy").html(product_array[i].copy);
				//shoe matching std
				if(!(product_array[i].hasSTD)){
					$("#matchSTD").hide();
				} else {
					$("#matchSTD").html('<a href="'+product_array[i].stdURL+'">Matching Save the Date available!</a>');
				}
				$("#quote-02").html('<a href="'+product_array[i].purchaseURL+'" target="win2"><span>Order a Sample</span></a>');
			
			} 
		}
	}
 });
