/*<![CDATA[*/
		   
/*****************************************************************************
//-> START sIFR configuration
*****************************************************************************/

var rockwell = {src: '/include/fonts/rockwell.swf' ,ratios: [6,1.41,9,1.35,15,1.29,21,1.25,22,1.22,27,1.24,29,1.21,34,1.22,41,1.21,45,1.2,46,1.21,59,1.2,68,1.19,69,1.2,96,1.19,97,1.18,102,1.19,103,1.18,107,1.19,108,1.18,112,1.19,114,1.18,116,1.19,120,1.18,121,1.19,1.18]};

// --> sIFR.domains = ['novemberborn.net'] // Don't check for domains in this demo
sIFR.useStyleCheck = true;
sIFR.activate(rockwell);
/*
// --> Top Header Sentence
sIFR.replace(rockwell, {
  selector: 'h1.header, h2.header'
    ,wmode: 'transparent'
    ,fixFocus: true
	,css: [
		'.sIFR-root { color: #FFFFFF; background-color:transparent; text-transform:capitalize; font-weight:bold; letter-spacing:-2; leading: -8.5;}',
		'h1.header strong { color: #be4a27; }',
		'h1.header a { text-decoration: none; color: #be4a27; }',
		'h1.header a:link { color: #be4a27; }',
		'h1.header a:hover { color: #be4a27; }',
		'h1.header a:active {color:#be4a27;}'
	]	  
  ,filters: {
	DropShadow: {
	  knockout: false
	  ,distance: 1.0
	  ,color: '#000000'
	  ,angle:90
	  ,strength: 0.8
	}
  }
});
*/
// --> Cross site headings
sIFR.replace(rockwell, {
  selector: 'h1.heading, h2.heading, h3.heading, h4.heading, h5.heading'
    ,wmode: 'transparent'
    ,fixFocus: true
	,css: [
		'.sIFR-root { color:#FFFFFF; background-color:#BADCE6; text-transform:capitalize; font-weight:bold; letter-spacing:-1; }',
		'h1.header strong { color:#be4a27; }',
		'h1.header a { text-decoration: underline; color:#FFFFFF;}',
		'h1.header a:link { color:#FFFFFF; }',
		'h1.header a:hover { color:#FFFFFF; text-decoration:none; }',
		'h1.header a:active {color:#FFFFFF; }'
	]	  
  ,filters: {
	DropShadow: {
	  knockout: false
	  ,distance: 1
	  ,color: '#000000'
	  ,blurY:0
	  ,blurX:0
	  ,angle:40
	  ,strength: 1
	}
  }
});
/*****************************************************************************
//-> END sIFR configuration
*****************************************************************************/
    
/*****************************************************************************
//-> START General Functions
*****************************************************************************/

// --> START Date Picker
var d = new Date();
var day = d.getDay();
var interval = 3;
	if(day > 2 && day < 7) interval+= 2;


// --> START Cookie Function
function saveCalcData() {
	
 	//console.log('saveCalcData')
 	$.cookie('pageQty', $("input.amount").val(), { expires:7, path:'/'})
 	$.cookie('totalPrice', $("span.price").html(), { expires:7, path:'/'})
 	$.cookie('totalPrice', $("input.price").val(), { expires:7, path:'/'})
	
	if($.browser.name == "opera" || $.browser.name == "msie"){	// Check if OPERA or MSIE browsers
		
		if($.cookie('pageQty') == "null"){
			$.cookie('pageQty',1, { expires:7, path:'/'});
			//console.log("in null");
		}
		if($.cookie('totalPrice') == "null"){
			$.cookie('totalPrice','$249', { expires:7, path:'/'});
			//console.log("in null");
		}
		
	}else{	// case of other browsers do this...
	
		if(!$.cookie('pageQty')){
			$.cookie('pageQty',1, { expires:7, path:'/'});
			//console.log("in null");
		}
		if(!$.cookie('totalPrice')){
			$.cookie('totalPrice','$249', { expires:7, path:'/'});
			//console.log("in null");
		}
	}	
}

/*****************************************************************************
//-> END General Functions
*****************************************************************************/

/*****************************************************************************
//-> START Window Load
*****************************************************************************/

$(window).load(function () {
						 
// --> Replace Logo
	$("#Header_a").html('<h2 class="logo-replaced"><a href="http://www.cssreaper.com/"><img src="/images/blank.gif" alt="Home Page" /></a></h2>');

// --> Start insert menu seperators
	$("#Header_c ul li:not(:last)").each(function(){
		$(this).after('<li class="sep">&nbsp;</li>');
	});
	
// --> Cookies
 	//console.log('Start me up!')
 	var pageQty = $.cookie('pageQty');
 	var totalPrice = $.cookie('totalPrice');
	
 	//console.log('pageQty='+pageQty);
 	//console.log('totalPrice='+totalPrice);
	$("input.amount").val(pageQty);
	//console.log("var pageQty is true");
	$("input.price").val(totalPrice); 
	$("span.price").html(totalPrice);
	//console.log("var totalPrice is true");
 	//update the cookies every 10 seconds....
 	//window.setInterval('saveCalcData()', 5*500)
	saveCalcData() 


// --> Start Disable '#' links from being clicked
	$("a[href^='#']").click(function() {
		return false;
	});

// --> Init External Links
	$("a[rel*='external']").attr("target","_blank");
	
// --> Stripping a tags with: class="remove"
	$("a[class*='strip']").each(function(){
		$(this).replaceWith($(this).html()); 
	});
	
// --> Init SPAM Email links
	$("a[href^='mailto:']").each(function(){
		var mail = $(this).attr("href").replace("mailto:","");
		var replaced = mail.replace("/at/","@");
		$(this).attr("href","mailto:"+replaced);
		if($(this).text() == mail){ 
			$(this).text(replaced);
		}
	});

// --> Init Text Shadow
	if($.browser.className != "msie6") $("#links-content span").textDropShadow();
	
// --> Slider
	$(".slider").slider({
		animate: true,
		range: "min",
		value: parseInt($.cookie('pageQty')),
		min: 1,
		max: 20,
		slide: function(event, ui) {
			var first_page = 249;
			var other_page = 149;
			if(ui.value == 1){
				$(".price").val('$' + (first_page));
				$("span.price").html('$' + (first_page));
				// --> write to hidden input
				$("#inputPrice:input").val('$' + (first_page));
			}else{
				$(".price").val('$' + (first_page + ((ui.value -1) * other_page)));
				$("span.price").html('$' + (first_page + ((ui.value -1) * other_page)));
				// --> write to hidden input
				$("#inputPrice:input").val('$' + (first_page + ((ui.value -1) * other_page)));
			}
			$(".amount").val(ui.value);
			// --> write to hidden input
			$("#inputAmount:input").val(ui.value);
			// --> update cookie
			saveCalcData()
		}
	});
	
	$(".price").val($.cookie('totalPrice'));
	$("span.price").html($.cookie('totalPrice'));
	$(".amount").val($(".slider").slider("value"));
	// write to hidden input
	//$("#inputPrice:input").val('$' + ($(".slider").slider("value") + 248));
	//$("#inputAmount:input").val($(".slider").slider("value"));
	$("#inputPrice:input").val($.cookie('totalPrice'));
	$("#inputAmount:input").val($.cookie('pageQty'));

// --> Buttons Less & More
	$("a.more").click(function(){
	
		var first_page = 249;
		var other_page = 149;
		var s = $(".slider"), val = parseInt($.cookie('pageQty')), step = s.slider("option","step");
		s.slider("value", val + step);
		//console.log(val);
		if(val >= 20){
			return false;
		}else{
			$(".price").val('$' + (first_page + (val) * other_page));
			$("span.price").html('$' + (first_page + (val) * other_page));
			$(".amount").val($(".slider").slider("value"));
			// --> write to hidden input
			$("#inputPrice:input").val('$' + (first_page + (val) * other_page));
			$("#inputAmount:input").val($(".slider").slider("value"));
			// --> update cookie
			saveCalcData()
			return false;
		}
	});

	$("a.less").click(function(){
		var first_page = 249;
		var other_page = 149;
		var s = $(".slider"), val = s.slider("value"), step = s.slider("option","step");
		s.slider("value", val - step);
		//console.log(val);
		if(val <= 1){
			return false;
		}else{
			$(".price").val('$' + (first_page + ((val -2) * other_page)));
			$("span.price").html('$' + (first_page + ((val -2) * other_page)));
			$(".amount").val($(".slider").slider("value"));
			// --> write to hidden input
			$("#inputPrice:input").val('$' + (first_page + ((val -2) * other_page)));
			$("#inputAmount:input").val($(".slider").slider("value"));
			// --> update cookie
			saveCalcData()
			return false;
		}
	});
	
// --> START FAQ's
	$("dl.faq")
		.find('dd').hide().end()
		.find('dt').append('<span class="expand">+ show<span class="shadow">+ show</span></span>')
		.toggle(function(){
		$(this)
			.find('span').attr('class','collapse').html('- hide<span class="shadow">- hide</span>').end()
			.next('dd').slideDown()
		},function(){
			$(this)
			.find('span').attr('class','expand').html('+ show<span class="shadow">+ show</span>').end()
			.next('dd').slideUp();
	});

// --> START DatePicker
	$('#deadline').focus(function(){
		$(this).val('');
			}).datepicker({
			minDate: interval, 
			beforeShowDay: $.datepicker.noWeekends, 
			showOn: "both", 
			showAnim: "fadeIn", 
			speed: "fast", 
			buttonImage: "/images/date.png", 
			buttonImageOnly: true, 
			hideIfNoPrevNext: true
	});
	
// --> START Order Form Input Files
	$('.add_file').show();

// --> add click handler to add icon
	$('.add_file').click(function(){
		// --> get input html
		var html = $(this).parents('.input').html();
		// --> add to form
		$('.file:last').after( '<div class="seperation"></div><div class="input file hide">'+html+'</div>' );
		// show the delete icon
		if($.browser.className == "msie6"){
			$('.file:last').append('<a href="#" class="del_file clear" title="Remove file field"><img class="png_bg clear optIcon" src="/images/delete.png" alt="Remove file field" /></a>');	
		}else{
			$('.file:last a.del_file').show();
		}
		// --> hide the add icon
		$('.file:last a.add_file').hide();
		// --> fade in the input
		$('.file:last').slideDown().removeClass('hide');
		// --> Remove the file field
		$('.del_file').click(function(){
			//console.log($(this).parent());
			$(this).parent().slideUp().addClass('hide');
			$(this).parent().prev().slideUp().addClass('hide');
			// --> Emptying the content of the input box
			$(this).parent().empty();
		return false;
		});
	return false;
	});
	
// --> Generate Tag Cloud
		var aLi = $("#cloud>li");
		var iLi = aLi.length;
		$.each(aLi,function(i,o){
			//$(o).val(iLi-i);
			//$(o).val(Math.round(iLi*Math.sqrt(1-i/iLi)));
			$(o).val(Math.round(iLi*Math.pow(1-i/iLi,2))).attr("title",$(o).text());
		});
		
		$("#cloud>li").tsort({order:"rand"});

		$("#cloud").tagcloud({type:"list",sizemin:10,colormin:"22454F",colormax:"000000"});
		
// --> ADD Styling - Avoiding css validation errors..

	// STYLE.CSS - CONTACT FORM
	$("#contact label, #contact input, textarea, select, .error_message, pre, .msg").css({"-webkit-border-radius" : "5px", "-moz-border-radius" : "5px"});

	// UI.DATEPICKER.CSS - IE6 IFRAME FIX
	$(".ui-datepicker-cover").css({"filter" : "mask()"});

	/* UI.THEME.CSS - Interaction Cues
	$(".ui-state-disabled, .ui-widget-content .ui-state-disabled").css({"opacity" : "0.35", "filter" : "Alpha(Opacity=35)"});
	$(".ui-priority-secondary, .ui-widget-content .ui-priority-secondary").css({"opacity" : "0.7", "filter" : "Alpha(Opacity=70)"});
	*/
	
	// UI.THEME.CSS - Corner radius
	$(".ui-corner-tl, .ui-corner-tr, .ui-corner-bl, .ui-corner-br").css({"-moz-border-radius-topleft": "5px", "-webkit-border-top-left-radius" : "5px"});
	$(".ui-corner-top").css({"-moz-border-radius-topleft" : "5px", "-webkit-border-top-left-radius" : "5px", "-moz-border-radius-topright" : "5px", "-webkit-border-top-right-radius" : "5px"});
	$(".ui-corner-bottom").css({"-moz-border-radius-bottomleft" : "5px", "-webkit-border-bottom-left-radius" : "5px", "-moz-border-radius-bottomright" : "5px", "-webkit-border-bottom-right-radius" : "5px"});
	$(".ui-corner-right").css({"-moz-border-radius-topright" : "5px", "-webkit-border-top-right-radius" : "5px", "-moz-border-radius-bottomright" : "5px", "-webkit-border-bottom-right-radius" : "5px"});
	$(".ui-corner-left").css({"-moz-border-radius-topleft" : "5px", "-webkit-border-top-left-radius" : "5px", "-moz-border-radius-bottomleft" : "5px", "-webkit-border-bottom-left-radius" : "5px"});
	$(".ui-corner-all").css({"-moz-border-radius" : "5px", "-webkit-border-radius" : "5px"});
	
	// UI.THEME.CSS - Overlays
	$(".ui-widget-overlay").css({"opacity" : ".30", "filter" : "Alpha(Opacity=30)"});
	$(".ui-widget-shadow").css({"opacity" : ".45", "filter" : "Alpha(Opacity=45)", "-moz-border-radius" : "5px", "-webkit-border-radius" : "5px"});

	// UI.CORE.CSS - Layout helpers
	$(".ui-helper-zfix").css({"opacity" : "0", "filter" : "Alpha(Opacity=0)"});
	
	// Headings with background
	$("h3.article, h3.sum, p.order-number").css({"-moz-border-radius" : "5px", "-webkit-border-radius" : "5px"});
	
	// Articles Comments
	$("ol.comments li").css({"-moz-border-radius" : "5px", "-webkit-border-radius" : "5px"});
	$("ol.comments li:even").css("background-color", "#2F6C7F");
	
	// Breadcrumbs background
	$("ol.comments li").css({"-moz-border-radius" : "5px", "-webkit-border-radius" : "5px"});
	$("ol.comments li:even").css("background-color", "#2F6C7F");
});

/*****************************************************************************
//-> END Window Load
*****************************************************************************/

/*]]>*/