
$(document).ready(function(){

/*
var timeDelay = 5000;
var currentNumSlides ;
var timer;
var slideCounter=0;

function changeSlide() {
  
	  if (slideCounter >= currentNumSlides)
	    {
		    $('#slides img').eq(slideCounter).fadeOut(500);
		    slideCounter=0;
		    $('#slides img').eq(slideCounter).fadeIn(500);
	  	 
	  	 //alert('reset');
	    }
	  else
	    {
		   // alert(slideCounter);
		    $('#slides img').eq(slideCounter).fadeOut(500);
		    slideCounter++;
		    $('#slides img').eq(slideCounter).fadeIn(500);
		    //moveTo = "-=" + imgWidth + "px";
		    
		  	 
	  	}; 
	  
};
*/
if ($('body').hasClass('home'))
{
	$('#slides').delay(700).fadeIn(700, function () { 
		$('#slides').removeClass('hide');
		$('#header').delay(700).fadeIn(500, function () { 
			$('#header').removeClass('hide');
		
		
		});
	});
	
	//$('#slides').removeClass('hide');
	//$('#header').removeClass('hide');
}

/*
if ($('body').hasClass('home'))
{
	//timer = window.setInterval( changeSlide, timeDelay);
	
	//currentNumSlides = $('#slides img').length -1 ;
	
	//var myRandom = Math.floor(Math.random()*currentNumSlides);
	
	//alert(myRandom);
	
	
	var randImg = new Array();
	randImg[0] = '<img id="slides-otari" src="images/slides/slide1.png" class="show this" alt="" />';
	randImg[1] = '<img id="slides-pies" src="images/slides/slide3.png" alt="" />';
	randImg[2] = '<img id="slides-bars" src="images/slides/slide2.png" alt="" />';
	
	//Then on document ready, get a new random number between 0 and the length of that array.
	var myRandom = Math.floor(Math.random()*randImg.length);
	//alert(myRandom);
	//Then update the blockquote (put an id="myQuote" or whatever)
	$('#slides').html(randImg[myRandom]);
	
	
	
	
}

*/


/*

	$(".example-img-wrap").hover(
		function () {		
			
			//$(this).find('.first').fadeOut(100);
			$(this).find('.first').fadeTo(50, 0);
			$(this).find('.second').fadeTo(50, 1);
			
		}, 
		function () {
			
			$(this).find('.second').fadeTo(50, 0);
			$(this).find('.first').fadeTo(50, 1);
			//$(this).find('.second').fadeOut(100);
			//$(this).find('.first').fadeIn(100);
				
		}
	);

*/ //alert($(window).width());
	var offsetWidth;
	
	if ($(window).width()<=964) {
	
	 offsetWidth = -190;
	
	} else {
	
		offsetWidth = 0;
	}
	
	$(window).resize(function() {
	
		$('#subnav, .scroll-link').unbind();
		  if ($(window).width()<=964) {
		  
		   offsetWidth = -190;
		  
		  } else {
		  
		  	offsetWidth = 0;
		  }
		  
		  $('#subnav, .scroll-link').localScroll({
		  offset: {top:offsetWidth, left:0},
		  lazy: true,
		  duration:200
		  });
		  
		  
	});
	
	$('#subnav, .scroll-link').localScroll({
	offset: {top:offsetWidth, left:0},
	lazy: true,
	duration:200
	});
	
	
	
	
	$(".buy-form img").hover(
		function () {		
			//alert('hi');
			$(this).fadeTo(50, 0.8);
			
			
		}, 
		function () {
			
			$(this).fadeTo(50, 1);
			
			
			
				
		}
	);
	
	$(".popup-start").click(function () { return false; } );
	
	$(".popup-start").hover(
		function () {		
			//alert('hi');
			$('.popup').fadeIn(50);
			
			
		}, 
		function () {
			
			$('.popup').fadeOut(50);
			
			
			
				
		}
	);
	
	/*
	$(".buy-form a").toggle(
		function () {		
			
			var findClass = '#' + $(this).attr("class");
			
			findClass = findClass.replace( "first", "" );
			findClass = findClass.replace( "-add", "" );
			findClass = findClass.replace( " complete", "" );
			findClass = findClass.replace( "img-preview", "" );
			//alert(findClass);
			
			$(findClass).addClass('selected');
			
			
		}, 
		function () {
			var findClass = '#' + $(this).attr("class");
			
			findClass = findClass.replace( "first", "" );
			findClass = findClass.replace( "-add", "" );
			findClass = findClass.replace( " complete", "" );
			findClass = findClass.replace( "img-preview", "" );
			//alert(findClass);
			
			$(findClass).removeClass('selected');
			
			
				
		}
	);
	


*/



// Cart Arrays ---------------------------------------------

	var allProducts = [];
	/*
	allProducts[0] = ['otaricomplete', sessvars.otaricompleteglobal, 'Otari Complete', '150' ];
	allProducts[1] = ['otaripacka', sessvars.otaripackaglobal, 'Otari Pack A', '100' ];
	allProducts[2] = ['otaripackb', sessvars.otaripackbglobal, 'Otari Pack B', '70' ];
	allProducts[3] = ['otarilight', sessvars.otarilightglobal, 'Otari Light', '25' ];
	allProducts[4] = ['otarilightitalic', sessvars.otarilightitalicglobal, 'Otari Light Italic', '25' ];
	allProducts[5] = ['otariregular', sessvars.otariregularglobal, 'Otari Regular', '25' ];
	allProducts[6] = ['otariregularitalic', sessvars.otariregularitalicglobal, 'Otari Regular Italic', '25' ];
	allProducts[7] = ['otarimedium', sessvars.otarimediumglobal, 'Otari Medium', '25' ];
	allProducts[8] = ['otarimediumitalic', sessvars.otarimediumitalicglobal, 'Otari Medium Italic', '25' ];
	allProducts[9] = ['otaribold', sessvars.otariboldglobal, 'Otari Bold', '25' ];
	allProducts[10] = ['otaribolditalic', sessvars.otaribolditalicglobal, 'Otari Bold Italic', '25' ];
	allProducts[11] = ['otariheavy', sessvars.otariheavyglobal, 'Otari Heavy', '25' ];
	allProducts[12] = ['otariheavyitalic', sessvars.otariheavyitalicglobal, 'Otari Heavy Italic', '25' ];
	allProducts[13] = ['chartwellcomplete', sessvars.chartwellcompleteglobal, 'Chartwell Complete', '40' ];
	allProducts[14] = ['chartwellpies', sessvars.chartwellpiesglobal, 'Chartwell Pies', '15' ];
	allProducts[15] = ['chartwellbars', sessvars.chartwellbarsglobal, 'Chartwell Bars', '15' ];
	allProducts[16] = ['chartwelllines', sessvars.chartwelllinesglobal, 'Chartwell Lines', '15' ];
	*/
	allProducts[0] = 'otaricomplete';
	allProducts[1] = 'otaripacka';
	allProducts[2] = 'otaripackb';
	allProducts[3] = 'otarilight';
	allProducts[4] = 'otarilightitalic';
	allProducts[5] = 'otariregular';
	allProducts[6] = 'otariregularitalic';
	allProducts[7] = 'otarimedium';
	allProducts[8] = 'otarimediumitalic';
	allProducts[9] = 'otaribold';
	allProducts[10] = 'otaribolditalic';
	allProducts[11] = 'otariheavy';
	allProducts[12] = 'otariheavyitalic';
	allProducts[13] = 'chartwellcomplete';
	allProducts[14] = 'chartwellpies';
	allProducts[15] = 'chartwellbars';
	allProducts[16] = 'chartwelllines';
	

	
	var totalProducts = allProducts.length - 1;
	var updateCount = 0 ;
	var updatedText = '';
	
	var numDiff=0;
	var totalCost=0;
	var productCompressed='';
	var removeItem;
	
	
	
	
	var otaricomplete = [];
	otaricomplete[0] = sessvars.otaricompleteglobal ; // session variable name
	otaricomplete[1] = 'Otari Complete' ; // Name of item
	otaricomplete[2] = '150' ; // price
	//otaricomplete[3] = 'complete' ; // is complete ? 
	
	
	
	
	var otaripacka = [];
	otaripacka[0] = sessvars.otaripackaglobal ;
	otaripacka[1] = 'Otari Pack A' ;
	otaripacka[2] = '100' ;
	
	
	
	
	
	var otaripackb = [];
	otaripackb[0] = sessvars.otaripackbglobal ;
	otaripackb[1] = 'Otari Pack B' ;
	otaripackb[2] = '70' ;
	
	var otarilight = [];
	otarilight[0] = sessvars.otarilightglobal  ;
	otarilight[1] = 'Otari Light' ;
	otarilight[2] = '25' ;
	
	var otarilightitalic = [];
	otarilightitalic[0] = sessvars.otarilightitalicglobal  ;
	otarilightitalic[1] = 'Otari Light Italic' ;
	otarilightitalic[2] = '25' ;
	
	var otariregular = [];
	otariregular[0] = sessvars.otariregularglobal  ;
	otariregular[1] = 'Otari Regular' ;
	otariregular[2] = '25' ;
	
	var otariregularitalic = [];
	otariregularitalic[0] = sessvars.otariregularitalicglobal  ;
	otariregularitalic[1] = 'Otari Regular Italic' ;
	otariregularitalic[2] = '25' ;
	
	var otarimedium = [];
	otarimedium[0] = sessvars.otarimediumglobal  ;
	otarimedium[1] = 'Otari Medium' ;
	otarimedium[2] = '25' ;
	
	var otarimediumitalic = [];
	otarimediumitalic[0] = sessvars.otarimediumitalicglobal  ;
	otarimediumitalic[1] = 'Otari Medium Italic' ;
	otarimediumitalic[2] = '25' ;
	
	var otaribold = [];
	otaribold[0] = sessvars.otariboldglobal  ;
	otaribold[1] = 'Otari Bold' ;
	otaribold[2] = '25' ;
	
	var otaribolditalic = [];
	otaribolditalic[0] = sessvars.otaribolditalicglobal  ;
	otaribolditalic[1] = 'Otari Bold Italic' ;
	otaribolditalic[2] = '25' ;
	
	var otariheavy = [];
	otariheavy[0] = sessvars.otariheavyglobal  ;
	otariheavy[1] = 'Otari Heavy' ;
	otariheavy[2] = '25' ;
	
	var otariheavyitalic = [];
	otariheavyitalic[0] = sessvars.otariheavyitalicglobal  ;
	otariheavyitalic[1] = 'Otari Heavy Italic' ;
	otariheavyitalic[2] = '25' ;

	var chartwellcomplete = [];
	chartwellcomplete[0] = sessvars.chartwellcompleteglobal  ;
	chartwellcomplete[1] = 'Chartwell Complete' ;
	chartwellcomplete[2] = '50' ;
	//chartwellcomplete[3] = 'complete' ; // is complete ? 
	
	
	var chartwellpies = [];
	chartwellpies[0] = sessvars.chartwellpiesglobal ;
	chartwellpies[1] = 'Chartwell Pies' ;
	chartwellpies[2] = '20' ;
	
	var chartwellbars = [];
	chartwellbars[0] = sessvars.chartwellbarsglobal  ;
	chartwellbars[1] = 'Chartwell Bars' ;
	chartwellbars[2] = '20' ;
	
	var chartwelllines = [];
	chartwelllines[0] = sessvars.chartwelllinesglobal  ;
	chartwelllines[1] = 'Chartwell Lines' ;
	chartwelllines[2] = '20' ;
	
	var familyValue = '';
	var clickedValue = ''; 
	var currentProduct = '';
	var cartPoofText ='';
	
	if ( sessvars.numLicenses == undefined)
	{
	 sessvars.numLicenses = 1;
	}

	/* Add items to cart */
	
	
	var isComplete;
	var notItems;
	var alreadyAdded;
	
	

	
	$(".img-preview").hover(
		function () {		
			
			$(this).parent().find('.add-links a').eq(0).addClass('hovering');
			
		}, 
		function () {
			
			$(this).parent().find('.add-links a').eq(0).removeClass('hovering');
				
		}
	);
	
	
	$('.buy-form a').click(function() {
		 var $this = $(this);
		
		
		
		if ($this.hasClass('added'))
		{
			alreadyAdded = 'true';
		} else {
			alreadyAdded = 'false';
		}
		
		if ($this.hasClass('complete')){
		
		    isComplete = 'true';//clicked on complete
		    currentProduct = $(this).closest('ul').attr("id");// find id of parent package/ul
		   
		    if ($this.hasClass('added')){ //add class identifying state of complete
		    
				   $(this).closest('ul').removeClass('complete-on');
		    } else {
		    
			     $(this).closest('ul').addClass('complete-on');
		     }
		    
		    notItems = ''; //include complete when targeting strike-through
		    
		    removeAllPackages();
		    
		    
	    } else {
		    
		    if ($this.closest('ul').hasClass('complete-on')){
			    
			    currentProduct = $(this).closest('ul').attr("id");
			    sessvars[currentProduct + 'global'] = 'false' ; 
			    
			    var targeted = '#' + currentProduct + ' a';
			    $(targeted).not(notItems).removeClass('added');
			    notItems = notItems.replace( ".", ", ." );
			     
			     $(targeted).not('.img-preview' + notItems).each(function(index) {
			         
			         
			         prevText = $(this).text();
			         newText  = prevText.replace( "Remove", "Add" );
			         newText  = newText.replace( "from", "to" );
			         $(this).text(newText);
			       });
			    //removeAllPackages();
			    
		    }
		    
		   $(this).closest('ul').removeClass('complete-on'); 
		    isComplete = 'false';
		    currentProduct = $(this).closest('li').attr("id");
		    
		    
		   
		    notItems = '.complete';
	    }
			
			
		 if (alreadyAdded ==='true'){
			      
			     toggleOff();
			     
		    } else {
		        toggleOn();
		        
		        
		 }
	
		 updateCart();
	  
		 return false;
		 
	  
	});
    
    function removeAllPackages() {
   
		var numPackagesCount = 0;
		var numPackages = $('#' + currentProduct + ' li').size() -1; //find total number of styles in current font
		
		while (numPackagesCount <= numPackages ) // loop through remove all single items 
		{
		    var thisId = $('#' + currentProduct + ' li').eq(numPackagesCount).attr("id");
		   
			if (sessvars[thisId + 'global']==='true') // identify items that are on
			{
				numDiff = numDiff - 1; //counter for side cart count
			}
			
			sessvars[thisId + 'global'] = 'false' ; // remove item
			numPackagesCount++;
		}
	}
	
	 $('#cart-poof').fadeOut(1);
	function toggleOn() {
			
			
				 var targeted = '#' + currentProduct + ' a';
				 $(targeted).not(notItems).addClass('added');
				 notItems = notItems.replace( ".", ", ." );
				  
				  $(targeted).not('.img-preview' + notItems).each(function(index) {
				      
				      
				      prevText = $(this).text();
				      newText  = prevText.replace( "Add", "Remove" );
				      newText  = newText.replace( "to", "from" );
				      $(this).text(newText);
				    });
				  
				 
				 numDiff = numDiff + 1;
				 				 
				 sessvars[currentProduct + 'global'] = 'true' ;
				 
				 //updateProduct = eval(allProducts[updateCountB]);
				 cartPoofText = eval(currentProduct);
				 //alert(cartPoofText[1]);
				 
				
				 
				
				// $('#cart-poof').stop(true, true).fadeOut(1).html(cartPoofText[1] + ' has been added to your cart').addClass('in-progress').fadeIn(100).delay(1000).fadeOut(200).removeClass('in-progress'); 
				 
			
	}
	
	function toggleOff() {
	
			
			var targeted = '#' + currentProduct + ' a';
			$(targeted).not(notItems).removeClass('added');
			notItems = notItems.replace( ".", ", ." );
			 
			 $(targeted).not('.img-preview' + notItems).each(function(index) {
			     
			     
			     prevText = $(this).text();
			     newText  = prevText.replace( "Remove", "Add" );
			     newText  = newText.replace( "from", "to" );
			     $(this).text(newText);
			   });
			
			
			
			numDiff = numDiff - 1;
			
			sessvars[currentProduct + 'global'] = 'false' ;
			
	
	}
	
	
	
	

	var updateProduct;
		
		
		function updateLicense() {
		
			
			var counter = 0;
			var numOnPage = $(".cost").length - 1;
			
			while (counter<=numOnPage)
			  {
				    currentProduct = $('.cost').eq(counter).parent().attr("id");
				    currentProduct = eval(currentProduct);
				    var targetProductCost = currentProduct[2];
				    
				    
				  	 $('.cost').eq(counter).text(targetProductCost * currentMultiplier);
				
				
				 
				  counter++;
			 }
			
		
		}
		
		
		function updateCart() {
				
				updateCountB = 0;
				updatedText = '';
				
				numProducts = 0;
				
				while (updateCountB <= totalProducts)
				  {
					   
					  updateProduct = eval(allProducts[updateCountB]);
					
					
					
						
					  if (updateProduct[0]=='true')
					    {
					    
					   
					    updatedText = updatedText + updateProduct[1] + '<br />';
					    
					    //sessvars.testSession[numProducts] = allProducts[updateCount] ;
					    numProducts++;
					    //alert(updatedText);
					    //alert(updateCountB );
					    }
					  
					  //$('#test-cart').html(updatedText);
					  
					  updateCountB++;
					  
					  
					 
				 }
				
				 updatedText = updatedText + sessvars.numLicenses;
				 $('.nav-cart-count').text(numProducts + numDiff);
				 
				 if (numProducts + numDiff === 0)
				 {
					 $('.nav-cart-count').parent().removeClass('items-in-cart');
				 } else {
				 
				 $('.nav-cart-count').parent().addClass('items-in-cart');
				 
				 }
				 
				 
				 //$('#test-cart').html(updatedText);
		}
		
		
		
		function togglePreDetermine() {
		
			updateCountC = 0;
			numProducts = 0;
			
			//alert(currentProduct + 'pies, ' + sessvars.chartwellpiesglobal);
			//alert(currentProduct + 'bars, ' + sessvars.chartwellbarsglobal);
			//alert(currentProduct + 'lines, ' + sessvars.chartwelllinesglobal);
			
			
			while (updateCountC<=totalProducts)
			  {
				 
				  updateProduct = eval(allProducts[updateCountC]);
				  
				   //alert(updateProduct[0]);
				  
				  if (updateProduct[0]==='true')
				    {
				    
						//alert('in');
						notItems = '.complete'; 
						 
						    
					    if (allProducts[updateCountC]==='otaricomplete' || allProducts[updateCountC]==='chartwellcomplete') 
					    {
						    notItems = '';
						    //alert(allProducts[updateCountC]);
						   $('#' + allProducts[updateCountC]).addClass('complete-on');
						    
					    }
					    
					   
					    var targeted = '#' + allProducts[updateCountC] + ' a';
					    
					    
					    $(targeted).not(notItems).addClass('added');
					    notItems = notItems.replace( ".", ", ." );
					    
					    $(targeted).not('.img-preview' + notItems).each(function(index) {
					        
					        
					        prevText = $(this).text();
					        newText  = prevText.replace( "Add", "Remove" );
					        newText  = newText.replace( "to", "from" );
					        $(this).text(newText);
					      });
					    
					   
					    numProducts++;
					    
					    
					    
				    }
				  
				 
				 
				  updateCountC++;
			 }
		
		}
	
	
	
	var currentMultiplier;
	
	
	
	/*
	
	$('.remove-cell a').live('change', function() {
		currentMultiplier = $(this).val();
		
		sessvars.numLicenses = currentMultiplier;
		updateCartPage();
	});
	*/
	/*
	$('#cartNumLic').change(function() {
	  
	  
	  currentMultiplier = $(this).val();
	  
	  sessvars.numLicenses = currentMultiplier;
	  updateCartPage();
	  
	  
	});
	*/
		
	
	updateCart();
	
	togglePreDetermine();
	
	
	
	if (sessvars.numLicenses >= 2)
	  {
	  
		   $('#numLic, #cartNumLic').val(sessvars.numLicenses);
		   
		   
		   currentMultiplier = sessvars.numLicenses;
		   
		   updateLicense();
		  
	  }
	
	
	

	
	function updateCartPage() {
	
		updateCount = 0;
		updatedText = '<form method="post" action="http://sites.fastspring.com/traviskochel/api/order" name="purchaseform" id="purchase-form"><input type="hidden" name="action" value="create"/><input type="hidden" name="destination" value="checkout"/><table class="grid8 first floatnone">';
		
		numProducts = 0;
		totalCost = 0;
		
		if (sessvars.numLicenses===undefined)
		{
		
		 sessvars.numLicenses=1;
		 
		}
		
		
		//$('#test-cart').text('');
		
		
		
		while (updateCount<=totalProducts)
		  {
			  productCompressed = allProducts[updateCount];
			  updateProduct = eval(allProducts[updateCount]);
			  var fastspringPath = productCompressed; // in case fix is needed to comply with fastspring
			  
			  if (productCompressed=='otaricomplete')
			  {
				  fastspringPath='otaricompleteset';
				  
			  }
			  
			  if (updateProduct[0] === 'true')
			    {
			    //alert(updateProduct);
			    
			    updatedText = updatedText + '<tr class="row' + numProducts + '"><td class="product-cell">' + updateProduct[1] + '</td><td class="cost-cell">$' + updateProduct[2] * sessvars.numLicenses  + '</td><td class="remove-cell">' +  '<a href="#" id="' + productCompressed + '">Remove</a> <input type="hidden" name="product_'+ (numProducts+1) +'_path" value="/' + fastspringPath +'"/><input class="quant-products" type="hidden" name="product_'+ (numProducts+1) +'_quantity" value="'+sessvars.numLicenses+'"/> </tr>';
			    
			    totalCost = totalCost + (updateProduct[2] * sessvars.numLicenses); 
			    
			    //sessvars.testSession[numProducts] = allProducts[updateCount] ;
			    numProducts++;
			    }
			  
			  //$('#test-cart').html(updatedText);
			 
			  updateCount++;
		 }
		 
		 //totalCost = totalCost *  sessvars.numLicenses;
		 updatedText = updatedText + '<tr id="license-row"><td colspan="3"><span class="textbox"><input type="text" name="coupon" value="Coupon" class="textclear" /></span> <select id="cartNumLic"><option selected="selected" value="1">1-5 Users</option><option value="2">6-10 Users</option><option value="3">11-25 Users</option><option value="4">26-50 Users</option><option value="5">51-100 Users</option><option value="10">101-500 Users</option> <option value="20">501-2,000 Users</option> <option value="30">2,001-5,000 Users</option> <option value="40">5,001-10,000 Users</option> <option value="50">10,000+ Users</option></select></td></tr><tr id="total-row" ><td colspan="2">Total Cost: $' + totalCost + ' <td><a href="#" class="submit button">Checkout</a></td></tr></table></form>';
		
		$('#purchase-form .submit').live('click', function() {
	  			if (document.purchaseform.coupon.value === 'Coupon'){ document.purchaseform.coupon.value =''; } document.purchaseform.submit();
			  return false;
		});
				
	
		
		$('#cart-page-list').html(updatedText);
		$('.nav-cart-count').text(numProducts + numDiff);
		
		if (numProducts + numDiff === 0)
		{
			 $('.nav-cart-count').parent().removeClass('items-in-cart');
		} else {
		
		$('.nav-cart-count').parent().addClass('items-in-cart');
		
		}
		
		$('#cartNumLic').bind('change', function() {
			  currentMultiplier = $(this).val();
			  
			  sessvars.numLicenses = currentMultiplier;
			  updateCartPage();
			  
			  
		});
		$("#cartNumLic").val(sessvars.numLicenses);
	
	}
	
	
	updateCartPage();
	
	$('.remove-cell a').live('click', function() {
	 
		
			removeItem = $(this).attr('id');
			 
			 sessvars[removeItem + 'global'] = 'false' ;
			 
			
			 removeItem = eval(removeItem);
			 
			 removeItem[0] = 'false';
			 
			
			 updateCartPage();
					 
			 return false;
		
		}
	
	);
		

	// browser-shot change
	$("#browsers-selector").change(function() {
			var browser_val = '#' + $(this).val();
			//alert(browser_val);
			$('#browsers-target .shot').fadeOut(100)
			
			if (browser_val == '#mac' || browser_val == '#win7' || browser_val == '#vista' || browser_val == '#xp' )
			{
				$(browser_val + ' .shot').fadeIn(200);
				
			} else {
			
				
				$(browser_val).fadeIn(200);
		    }
		}
	);  
	
	
	var cw_ug ={"TK110610-5621-42117":"cwc", "TK110613-5621-61119":"cwc", "TK110307-4422-13121":"cwc", "TK110307-4422-53126":"cwc", "TK110307-4422-62132":"cwc", "TK110308-5071-76119":"cwc", "TK110308-4422-71113":"cwc", "TK110308-4422-85122":"cwc", "TK110308-4422-98141":"cwc", "TK110308-5918-18111":"cwc", "TK110308-4422-91154":"cwc", "TK110308-5918-96128":"cwc", "TK110308-5071-38122":"cwc", "TK110308-4422-52170":"cwc", "TK110308-5918-21135":"cwc", "TK110308-4422-71172":"cwc", "TK110308-4422-71178":"cwc", "TK110308-4422-39191":"cwc", "TK110308-5918-24146":"cwc", "TK110309-4422-70103":"cwc", "TK110309-5918-61125":"cwc", "TK110309-4422-93111":"cwc", "TK110309-5071-46105":"cwc", "TK110309-5071-14113":"cwc", "TK110309-5918-18142":"cwc", "TK110309-4422-44115":"cwc", "TK110309-5918-25146":"cwc", "TK110309-4422-14126":"cwc", "TK110309-5918-35153":"cwc", "TK110310-4422-15115":"cwc", "TK110310-5918-86105":"cwc", "TK110310-5071-25116":"cwc", "TK110310-5071-83123":"cwc", "TK110310-5918-69111":"cwc", "TK110310-5071-23124":"cwc", "TK110310-5071-62135":"cwc", "TK110310-4422-50124":"cwc", "TK110310-4422-20131":"cwc", "TK110310-2260-42119":"cwc", "TK110311-1117-53115":"cwc", "TK110311-9562-26105":"cwc", "TK110311-9562-21118":"cwc", "TK110311-9700-92102":"cwc", "TK110311-7722-64104":"cwc", "TK110311-9562-66132":"cwc", "TK110311-9700-20120":"cwc", "TK110311-7722-76122":"cwc", "TK110311-1117-44122":"cwc", "TK110312-9562-21106":"cwc", "TK110312-7722-73113":"cwc", "TK110313-7711-33109":"cwc", "TK110313-7711-91128":"cwc", "TK110314-7711-39111":"cwc", "TK110314-9700-34102":"cwc", "TK110314-7722-63109":"cwc", "TK110315-1094-55104":"cwc", "TK110315-4082-20110":"cwc", "TK110316-8788-44110":"cwc", "TK110316-8527-37108":"cwc", "TK110317-8788-97111":"cwc", "TK110317-8788-61117":"cwc", "TK110317-1094-91111":"cwc", "TK110317-1094-59130":"cwc", "TK110317-8788-79135":"cwc", "TK110317-8788-41149":"cwc", "TK110318-8788-97114":"cwc", "TK110318-8788-55126":"cwc", "TK110318-8558-57101":"cwc", "TK110319-1373-23118":"cwc", "TK110319-3721-15112":"cwc", "TK110321-1373-22102":"cwc", "TK110321-8558-20116":"cwc", "TK110321-1373-69113":"cwc", "TK110321-8558-76128":"cwc", "TK110321-1373-31126":"cwc", "TK110321-1373-40128":"cwc", "TK110322-3721-56104":"cwc", "TK110322-8558-42106":"cwc", "TK110322-1373-64106":"cwc", "TK110322-7697-26136":"cwc", "TK110322-1373-32113":"cwc", "TK110323-3721-78117":"cwc", "TK110323-3721-97134":"cwc", "TK110324-3721-67115":"cwc", "TK110325-3721-29108":"cwc", "TK110325-3721-19122":"cwc", "TK110325-3721-88134":"cwc", "TK110325-5696-85104":"cwc", "TK110325-5696-46114":"cwc", "TK110325-5696-92129":"cwc", "TK110325-3721-65143":"cwc", "TK110325-7697-19127":"cwc", "TK110325-7697-72148":"cwc", "TK110325-3721-55145":"cwc", "TK110325-5696-70133":"cwc", "TK110325-3721-32158":"cwc", "TK110325-5696-24146":"cwc", "TK110325-1373-23106":"cwc", "TK110325-5696-26152":"cwc", "TK110325-5696-60164":"cwc", "TK110325-1373-16107":"cwc", "TK110325-3721-38190":"cwc", "TK110325-3721-72198":"cwc", "TK110325-5696-15167":"cwc", "TK110325-5696-40172":"cwc", "TK110325-3721-42204":"cwc", "TK110325-5696-15182":"cwc", "TK110325-5696-17198":"cwc", "TK110325-5696-57199":"cwc", "TK110325-3721-38208":"cwc", "TK110325-7697-11162":"cwc", "TK110325-5696-96214":"cwc", "TK110325-5696-56240":"cwc", "TK110325-3721-35212":"cwc", "TK110325-5696-38242":"cwc", "TK110325-7697-73168":"cwc", "TK110325-1373-71126":"cwc", "TK110325-1373-44145":"cwc", "TK110325-1373-27153":"cwc", "TK110326-6745-60107":"cwc", "TK110326-6745-21125":"cwc", "TK110326-9094-87116":"cwc", "TK110326-2826-91109":"cwc", "TK110326-9094-34117":"cwc", "TK110326-6745-31143":"cwc", "TK110328-9094-10108":"cwc", "TK110328-6745-88111":"cwc", "TK110328-2014-96111":"cwc", "TK110328-2014-20114":"cwc", "TK110328-6745-97117":"cwc", "TK110328-9094-61133":"cwc", "TK110328-2014-42121":"cwc", "TK110328-9094-73136":"cwc", "TK110329-7033-61113":"cwc", "TK110329-7975-47119":"cwc", "TK110329-2503-55116":"cwc", "TK110329-2503-81129":"cwc", "TK110329-7033-41120":"cwc", "TK110330-5247-23102":"cwc", "TK110330-7975-60103":"cwc", "TK110330-7033-78117":"cwc", "TK110330-7033-32118":"cwc", "TK110331-7033-20108":"cwc", "TK110331-2503-31114":"cwc", "TK110331-7975-47113":"cwc", "TK110331-7975-97125":"cwc", "TK110331-7975-21142":"cwc", "TK110331-7033-19120":"cwc", "TK110401-7975-22127":"cwc", "TK110401-5247-41106":"cwc", "TK110401-2503-64107":"cwc", "TK110401-2503-27123":"cwc", "TK110402-2503-11101":"cwc", "TK110402-7033-93115":"cwc", "TK110402-2503-72112":"cwc", "TK110403-7975-49102":"cwc", "TK110404-2503-33102":"cwc", "TK110404-7033-77107":"cwc", "TK110404-7033-11118":"cwc", "TK110405-7975-22116":"cwc", "TK110406-7033-33114":"cwc", "TK110406-2503-25102":"cwc", "TK110407-1959-30104":"cwc", "TK110407-3832-13112":"cwc", "TK110408-6657-45109":"cwc", "TK110408-7780-71113":"cwc", "TK110408-6657-51114":"cwc", "TK110409-3880-91117":"cwc", "TK110409-3582-15112":"cwc", "TK110410-4844-48109":"cwc", "TK110410-3880-75116":"cwc", "TK110410-3582-20117":"cwc", "TK110412-3582-13114":"cwc", "TK110412-4844-21113":"cwc", "TK110414-1708-37104":"cwc", "TK110414-1708-68116":"cwc", "TK110414-1708-60132":"cwc", "TK110414-3582-16113":"cwc", "TK110417-3582-75110":"cwc", "TK110417-1708-20115":"cwc", "TK110418-1708-92118":"cwc", "TK110418-4844-11115":"cwc", "TK110419-1708-71110":"cwc", "TK110419-4844-44101":"cwc", "TK110419-1708-56111":"cwc", "TK110420-3880-47119":"cwc", "TK110421-3880-81102":"cwc", "TK110422-1708-58114":"cwc", "TK110426-4844-70117":"cwc", "TK110427-3582-35117":"cwc", "TK110427-4844-20106":"cwc", "TK110428-3582-45115":"cwc", "TK110503-7694-62102":"cwc", "TK110503-7694-29112":"cwc", "TK110505-4375-98107":"cwc", "TK110511-4375-60118":"cwc", "TK110512-4375-12111":"cwc", "TK110516-4375-24103":"cwc", "TK110518-6188-97115":"cwc", "TK110520-3873-75110":"cwc", "TK110524-7363-55108":"cwc", "TK110524-7363-20118":"cwc", "TK110524-3873-45114":"cwc", "TK110525-3873-14101":"cwc", "TK110525-7363-88115":"cwc", "TK110525-3873-73105":"cwc", "TK110525-4224-49113":"cwc", "TK110525-7363-17129":"cwc", "TK110525-1759-48118":"cwc", "TK110525-1759-65119":"cwc", "TK110525-3873-80115":"cwc", "TK110525-3873-80120":"cwc", "TK110525-1759-56137":"cwc", "TK110525-7363-91135":"cwc", "TK110526-3873-24119":"cwc", "TK110526-3222-84113":"cwc", "TK110526-3222-60132":"cwc", "TK110527-9077-35118":"cwc", "TK110530-1599-18105":"cwc", "TK110531-1599-92112":"cwc", "TK110601-1599-80107":"cwc", "TK110601-1599-67119":"cwc", "TK110603-1599-49117":"cwc", "TK110606-9170-16114":"cwc", "TK110609-7242-34110":"cwc", "TK110307-5071-54101":"cwp", "TK110309-5918-53116":"cwp", "TK110310-4422-14121":"cwp", "TK110310-5918-53114":"cwp", "TK110315-7711-96113":"cwp", "TK110316-8788-47108":"cwp", "TK110322-7697-75119":"cwp", "TK110325-3721-93176":"cwp", "TK110325-5696-77150":"cwp", "TK110325-7697-28150":"cwp", "TK110327-2826-50105":"cwp", "TK110327-6745-72103":"cwp", "TK110328-2826-30108":"cwp", "TK110328-2014-89137":"cwp", "TK110329-2503-43141":"cwp", "TK110330-5247-15103":"cwp", "TK110331-5247-52117":"cwp", "TK110331-2503-44127":"cwp", "TK110401-7975-22140":"cwp", "TK110404-7975-38101":"cwp", "TK110404-7033-40103":"cwp", "TK110405-5247-22111":"cwp", "TK110406-7975-65114":"cwp", "TK110407-6657-22119":"cwp", "TK110407-3832-66107":"cwp", "TK110413-1708-30112":"cwp", "TK110414-3582-73103":"cwp", "TK110428-5530-67115":"cwp", "TK110513-8374-87118":"cwp", "TK110518-4375-48113":"cwp", "TK110518-8374-59116":"cwp", "TK110528-1599-18113":"cwp", "TK110531-9077-76118":"cwp", "TK110605-1599-67113":"cwp", "TK110608-7242-37108":"cwp", "TK110407-3832-78102":"cwb", "TK110311-9700-42139":"cwl", "TK110406-7033-47118":"cwl", "TK110417-1708-53111":"cwl", "TK110606-1599-37106":"cwc5", "TK110309-5918-53149":"cwc3", "TK110331-7975-76133":"cwc2", "TK110520-7363-91106":"cwpb" };
	
	//alert(cw_ug["TK110307-4422-13121"]);
	
	
	var order_num_found = false;
	
	// upgrade browser
	$("#upgrade-form a").click(function() {
	
			var order_num = $('#upgrade-form #upgrade').val();
			
			
			
			var xoasjflaasfjcwc = 'CWU-1216531';
			var aiiaslasafcwp = 'CWU-321679'; 
			var asfsatwasercwl = 'CWU-7816874'; 
			var xcklsjoercwb = 'CWU-574981'; 
			var ffgabasfcwpb = 'CWU-6871684';
			var fjtulahjftyycw5 = 'cwu-1216531';
			var asfasfhhycw3 = 'cwu-1216531'; 
			var gkoawngfancw2 = 'cwu-1216531'; 
			
			
			
			//alert(cw_ug[order_num]);
			
			$('#target-num').fadeOut(50);
			
			if (cw_ug[order_num] == 'cwc' )
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ xoasjflaasfjcwc +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Complete Upgrade</td><td class="cost-cell">$10</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwellcomplete" name="product_1_path"><input class="quant-products" type="hidden" value="1" name="product_1_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $10 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwp' ) // pies
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ aiiaslasafcwp +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Pies Upgrade</td><td class="cost-cell">$5</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwellpies" name="product_1_path"><input class="quant-products" type="hidden" value="1" name="product_1_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $5 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwl' ) //lines
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ asfsatwasercwl +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Lines Upgrade</td><td class="cost-cell">$5</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwelllines" name="product_3_path"><input class="quant-products" type="hidden" value="1" name="product_3_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $5 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwb' ) //bars
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ xcklsjoercwb +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Bars Upgrade</td><td class="cost-cell">$5</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwellbars" name="product_2_path"><input class="quant-products" type="hidden" value="1" name="product_2_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $5 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwpb' ) //bars and pies
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ ffgabasfcwpb +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Pies Upgrade</td><td class="cost-cell">$5</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwellpies" name="product_1_path"><input class="quant-products" type="hidden" value="1" name="product_1_quantity"></td></tr><tr class="row0"><td class="product-cell">Chartwell Bars Upgrade</td><td class="cost-cell">$5</td><td class="remove-cell">1-5 Users<input type="hidden" value="/chartwellbars" name="product_2_path"><input class="quant-products" type="hidden" value="1" name="product_2_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $10 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwc5' ) //complete 5
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ xoasjflaasfjcwc +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Complete Upgrade</td><td class="cost-cell">$50</td><td class="remove-cell">51+ Users<input type="hidden" value="/chartwellcomplete" name="product_1_path"><input class="quant-products" type="hidden" value="5" name="product_1_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $50 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwc3' ) //complete 3
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ xoasjflaasfjcwc +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Complete Upgrade</td><td class="cost-cell">$30</td><td class="remove-cell">11-25 Users<input type="hidden" value="/chartwellcomplete" name="product_1_path"><input class="quant-products" type="hidden" value="3" name="product_1_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $30 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else if (cw_ug[order_num] == 'cwc2' ) //complete 2
			{
				$('#check-info').fadeOut(50);
				$('#target-num').html('<input class="textclear" type="hidden" value="'+ xoasjflaasfjcwc +'" name="coupon"><table class="grid8 first floatnone"><tbody><tr class="row0"><td class="product-cell">Chartwell Complete Upgrade</td><td class="cost-cell">$20</td><td class="remove-cell">6-10 Users<input type="hidden" value="/chartwellcomplete" name="product_1_path"><input class="quant-products" type="hidden" value="2" name="product_1_quantity"></td></tr><tr id="total-row"><td colspan="2">Total Cost: $20 </td><td><a class="submit button" href="#">Checkout</a></td></tr></tbody></table>');
				//alert(order_num);
				$('#target-num').fadeIn(200);
				order_num_found = true;
				//document.upgradeform.submit();
			} else {
				$('#target-num').html('<p>Sorry, we can&rsquo;t find your order number. Try entering it again, or email <a href="mailto:info@tktype.com">info@tktype.com</a> for help.</p>');
				$('#target-num').fadeIn(200);
				//alert('nope');
			}
			
			
			return false;
			
			
		}
	);    
	
	$('#upgrade-form .submit').live('click', function() {
		
		document.upgradeform.submit();
	    return false;
	});


});



