/**
 * @author dan
 */

var $j = jQuery.noConflict();
 
function changeStyle( setTo, changeWhat ) {
				
	//$('link[@rel*=style][title]').each(function(i) {
	
	$j('.'+changeWhat).each(function(i) {
		this.disabled = true;
		if (this.getAttribute('title') == setTo) {
			this.disabled = false;
		}
	});
	$j.cookie('selected-'+changeWhat, setTo, { path: '/', expires: 365 } );

}



$j(document).ready( function() {
	

	var toLoad = new Array('cssSize','cssColour');
	for (var i = 0; i < toLoad.length; i++) {
		
		var c = $j.cookie('selected-'+toLoad[i]);
		if (c) 
			changeStyle( c, toLoad[i]);
	
	}

	for (var i = 0; i < toLoad.length; i++) {
	
		$j('.'+toLoad[i]).each( function() {
			
			if (this.disabled == false) {
				var newRow = $j('<option selected="selected" value="' + this.getAttribute('title') + '">' + this.getAttribute('title') + '</option>');
			}
			else {
				var newRow = $j('<option value="' + this.getAttribute('title') + '">' + this.getAttribute('title') + '</option>');
			}
			$j('#'+toLoad[i]).append( newRow );
			
		});
		
		
	}
	
});



