/*****************************************************************************
It is adviced to place the sIFR JavaScript calls in this file, keeping it
separate from the `sifr.js` file. That way, you can easily swap the `sifr.js`
file for a new version, while keeping the configuration.

You must load this file *after* loading `sifr.js`.

That said, you're of course free to merge the JavaScript files. Just make sure
the copyright statement in `sifr.js` is kept intact.
*****************************************************************************/

// Make an object pointing to the location of the Flash movie on your web server.
// Try using the font name as the variable name, makes it easy to remember which
// object you're using. As an example in this file, we'll use Futura.
//var gotham = { src: 'http://ll.ciscoeos.com/extras/wmg/gotham-med-sifr.swf' };
//var prater = { src: '../templates/extras/praterserifbold.swf'};
var prater = { src: 'http://origin-static.ciscoeos.com/zipupload/625/084/2a44ec3d1c3f9b946301144d73/js/praterserifbold.swf'};

// Now you can set some configuration settings.
// See also <http://wiki.novemberborn.net/sifr3/JavaScript+Configuration>.
// One setting you probably want to use is `sIFR.useStyleCheck`. Before you do that,
// read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad>.

// sIFR.useStyleCheck = true;

// Next, activate sIFR:
sIFR.activate(prater);

// If you want, you can use multiple movies, like so:
//
//    var futura = { src: '/path/to/futura.swf' };
//    var garamond = { src '/path/to/garamond.swf' };
//    var rockwell = { src: '/path/to/rockwell.swf' };
//    
//    sIFR.activate(futura, garamond, rockwell);
//
// Remember, there must be *only one* `sIFR.activate()`!

// Now we can do the replacements. You can do as many as you like, but just
// as an example, we'll replace all `<h1>` elements with the Futura movie.
// 
// The first argument to `sIFR.replace` is the `futura` object we created earlier.
// The second argument is another object, on which you can specify a number of
// parameters or "keyword arguemnts". For the full list, see "Keyword arguments"
// under `replace(kwargs, mergeKwargs)` at 
// <http://wiki.novemberborn.net/sifr3/JavaScript+Methods>.
// 
// The first argument you see here is `selector`, which is a normal CSS selector.
// That means you can also do things like '#content h1' or 'h1.title'.
//
// The second argument determines what the Flash text looks like. The main text
// is styled via the `.sIFR-root` class. Here we've specified `background-color`
// of the entire Flash movie to be a light grey, and the `color` of the text to
// be red. Read more about styling at <http://wiki.novemberborn.net/sifr3/Styling>.

//for module headers in signup, join, login and password reset forms
sIFR.replace(prater, {
  selector: '.title h2',
  css: [
  	'.sIFR-root { text-transform: uppercase; color: #FFFFFF; padding: 0; }',
  	'a { color: #FFFFFF; text-decoration: none; }',
  	'a:hover { color: #FFFFFF; text-decoration: none; }'
  	],
  tuneHeight: '-5',
  wmode: 'transparent'
});

var itemsInStore = [
	{'SKU':'INS63746','productName':'Digital Pack Preorder','category':'preorder','unitPrice':'9.99'},
	{'SKU':'INS63747','productName':'Standard Pack Preorder','category':'preorder','unitPrice':'29.99'},
	{'SKU':'INS64183','productName':'Limited Edition Pack Preorder (Small)','category':'preorder','unitPrice':'79.99'},
	{'SKU':'INS64184','productName':'Limited Edition Pack Preorder (Medium)','category':'preorder','unitPrice':'79.99'},
	{'SKU':'INS64185','productName':'Limited Edition Pack Preorder (Large)','category':'preorder','unitPrice':'79.99'},
	{'SKU':'INS64186','productName':'Limited Edition Pack Preorder (X-Large)','category':'preorder','unitPrice':'79.99'},
	{'SKU':'INS64187','productName':'Deluxe Pack Preorder (Small)','category':'preorder','unitPrice':'399.99'},
	{'SKU':'INS64188','productName':'Deluxe Pack Preorder (Medium)','category':'preorder','unitPrice':'399.99'},
	{'SKU':'INS64189','productName':'Deluxe Pack Preorder (Large)','category':'preorder','unitPrice':'399.99'},
	{'SKU':'INS64190','productName':'Deluxe Pack Preorder (X-Large)','category':'preorder','unitPrice':'399.99'}
];
function getStoreItem(skuID) {
	for (var i=0; i<itemsInStore.length; i++) {
		console.log('compare '+skuID+' against store item list: '+itemsInStore[i].SKU);
		if (itemsInStore[i].SKU.indexOf(skuID)>=0) { console.log('found match, returning '+itemsInStore[i].productName); return itemsInStore[i]; }
	}
	return null;
}
function addItemCookie(value) {
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	if (value.indexOf('/add/')>=0) { value = value.substring(5); }
	var oldvalue = readCookie('CART-ITEMS');
	if (oldvalue!=null && oldvalue!='') {
		value = oldvalue+','+value;
	}
	document.cookie = "CART-ITEMS="+value+expires+"; path=/";
}
function updateCartCookies() {
	var skus = $('div.checkout_item .item_count input');
	var skuList = new Array();
	for (i=0; i<skus.length; i++) {
		for (j=0; j<$(skus[i]).attr('value'); j++) {
			skuList.push($(skus[i]).attr('id'));
		}
	}
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "CART-ITEMS="+skuList.join(',')+expires+"; path=/";
}
function saveShippingDetails(shipping,tax,total,city,state,country) {
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "CARTSHIPPING="+shipping+expires+"; path=/";
	document.cookie = "CARTTAX="+tax+expires+"; path=/";
	document.cookie = "CARTTOTAL="+total+expires+"; path=/";
	document.cookie = "CARTCITY="+city+expires+"; path=/";
	document.cookie = "CARTSTATE="+state+expires+"; path=/";
	document.cookie = "CARTCOUNTRY="+country+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function clearCart() {
	document.cookie='CART-ITEMS=;expires=-1';
	document.cookie='CARTSHIPPING=;expires=-1';
	document.cookie='CARTTAX=;expires=-1';
	document.cookie='CARTTOTAL=;expires=-1';
	document.cookie='CARTCITY=;expires=-1';
	document.cookie='CARTSTATE=;expires=-1';
	document.cookie='CARTCOUNTRY=;expires=-1';
}
$(document).ready(function(){
	$('.titleName img').attr('src','http://flash.atlrec.com/jasoncastro/store/logo_jasoncastro.gif');
	if (window.location.href.indexOf('deluxepack') >= 0 || window.location.href.indexOf('limitededitionpack') >=0) {
		$('#col_498 div.section_title').hide();
		$('#col_260 div.image').hide();
	}
	$('a.cart_total').attr('href','/cart');
	$('a.item_number').attr('href','/cart');
	$("a.type[href*='/add/INS']").each(function(i){ $(this).attr('onclick','addItemCookie("'+$(this).attr('href')+'")'); });
	$("a.price[href*='/add/INS']").each(function(i){ $(this).attr('onclick','addItemCookie("'+$(this).attr('href')+'")'); });
	$("a[href*='/add/']").each(function(i){ $(this).attr('onclick','addItemCookie("'+$(this).attr('href')+'")'); });
	$("a.product_name[href='/cart/clear']").click(clearCart);
	$("a:contains('Update Cart')").attr('href','javascript:updateCartCookies();document.ItemForm.submit();');
//$("#BillCountry").html("<option	value='US'>United States</option>");
//$("#ShipCountry").html("<option value='US'>United States</option>");

});
