// JavaScript Document
if(typeof(jqss) === 'undefined') {
	jqss = jQuery;
} 

var bgStyles = new Array();
var $a =1;
bgStyles[$a] = new Array();
bgStyles[$a]['repeat'] = 'repeat-x';
bgStyles[$a]['attachment'] = 'scroll';
bgStyles[$a]['position'] = '0 45px';
$a ++;

bgStyles[$a] = new Array();
bgStyles[$a]['repeat'] = 'no-repeat';
bgStyles[$a]['attachment'] = 'fixed';
bgStyles[$a]['position'] = '50% 125px';
$a ++;

bgStyles[$a] = new Array();
bgStyles[$a]['repeat'] = 'no-repeat';
bgStyles[$a]['attachment'] = 'fixed';
bgStyles[$a]['position'] = '50% 125px';
$a ++;

bgStyles[$a] = new Array();
bgStyles[$a]['repeat'] = 'no-repeat';
bgStyles[$a]['attachment'] = 'fixed';
bgStyles[$a]['position'] = '50% 125px';

function setBgStyle(i){ //Main style switcher function.

	var cssObj = {
		'background-image' : 'url(/hacks/style_switcher/background_images/image' + i + '.jpg)',
		'background-repeat' : bgStyles[i]['repeat'],
		'background-attachment' : bgStyles[i]['attachment'],
		'background-position' : bgStyles[i]['position']
	}

	jqss('#page-bg2').css(cssObj);
}

function chooseStyle(i){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
	if (document.getElementById){
		setBgStyle(i);
		jqss.cookie("mybackground", i, { expires: 60 });
	}
}

jqss(document).ready(function() {

	i = jqss.cookie("mybackground");
	if(i){
		setBgStyle(i);
	}
});
