function setUpSlides() {
	jQuery('div.slides').each(function(i) {
		jQuery(this).css('display', 'none');
		if (typeof slideWait !='undefined') {
			sWait=slideWait;
		}
		else {
			sWait=8000;
		}
		if (typeof slideDur !='undefined') {
			sDur=slideDur;
		}
		else {
			sDur=800;
		}
		if (typeof slideFX !='undefined') {
			sFX=slideFX;
		}
		else {
			sFX='fade';
		}
		
		jQuery(this).fadeIn();
		jQuery(this).cycle({fx: sFX, speed: sDur, timeout: sWait, pause: 1});
		
	});
	return;


}

function resizeImg() {
	var bgImg=jQuery('#bgImage img').each(function() {
		jQuery(this).removeAttr('width').removeAttr('height');
		var imgwidth = jQuery(this).width();
		var imgheight = jQuery(this).height();
		var winwidth = jQuery(window).width()+100;
		var winheight = jQuery(window).height()+100;
		
		var widthratio = winwidth / imgwidth;
		var heightratio = winheight / imgheight;
		var widthdiff = heightratio * imgwidth;
		var heightdiff = widthratio * imgheight;
		var topPos = -(heightdiff-winheight) /2;
		var leftPos = -(widthdiff-winwidth) /2;
		if(heightdiff>winheight) {
			jQuery(this).css({
				width: winwidth+'px',
				height: heightdiff+'px',
				left:"0",
				top:topPos+"px"
			});//.attr('width',winwidth).attr('height', heightdiff);
			//alert('Resizing Images: \nImageWidth: '+winwidth+' - Image Height: '+heightdiff+'\nWindow Width: '+winwidth+' - Window Height: '+winheight);
		}
		else {
			jQuery(this).css({
				width: widthdiff+'px',
				height: winheight+'px',
				left:leftPos+"px",
				top:"0"
			});//.attr('width',widthdiff).attr('height', winheight);
			//alert('Resizing Images: \nImageWidth: '+widthdiff+' - Image Height: '+winheight+'\nWindow Width: '+winwidth+' - Window Height: '+winheight);
		}
	});
	
}

function setBackground () {
	if (jQuery('#content #background').length==0) {
		return;
	}
	//jQuery('#bgImage').hide();
	jQuery('#bgImage').empty().append(jQuery('#content #background'));
	
	if (jQuery('#bgImage img').length>1) {
		//jQuery('#bgImage img').removeAttr('width').removeAttr('height');
		resizeImg();
		jQuery('#bgImage #background').cycle({fx:'fade', speed:2000, timeout: 20000, containerResize: 0});
		}
	
	if (jQuery('#background').hasClass('noresize')) {
		var imgWidth=jQuery('#background img').attr('width');
		jQuery('#background').css({position: 'absolute', width: imgWidth, left: '50%', marginLeft: -imgWidth/2, height: 'auto'});
		jQuery('#background img').css({width: imgWidth, height: 'auto'});
		jQuery('#bgImage').css({width: imgWidth, marginLeft: -imgWidth/2, left: '50%', position: 'fixed'});
	}
	else {
		resizeImg();
	}
	jQuery('#bgImage img').load(function() {
		jQuery('#bgImage').fadeIn(1000);
	});
	return;
}
function addToHeader() {
	jQuery('#mainContent').before('<div id="importedHeader"></div>');
	if (jQuery('#content #addToHeader').length==0) {return;}
	jQuery('#importedHeader').append(jQuery('#addToHeader').html());
	jQuery('#content #addToHeader').empty();
	return;
}

function addToFooter() {
	if (jQuery('#content #addToFooter').length==0) {return;}
	jQuery('#footer').prepend('<div id="importedFooter">'+jQuery('#addToFooter').html()+'</div>');
	jQuery('#content #addToFooter').empty();
	return;
}

function initSB() {
	Shadowbox.init({
		players: ["html","img","swf","flv","qt","iframe"]
	});
	return;
}

function setUpPhotoAlbumSB() {
	var theLink=jQuery('div.thumbnail-frame a').each(function() {
		theURL=jQuery(this).attr('href').replace(/html/, 'jpg');
		var theTitle=jQuery(this).next('p.thumbnail-caption').text();
		jQuery(this).attr({
			'href': theURL,
			'rel': 'shadowbox[photoSet]',
			'title': theTitle
		});
	});
	return;
}

function addPageNameHeader () {
	var pageName=jQuery('#navcontainer li.current').find('a').first().text();
	jQuery('#pageHeader').append('<div id="pageName">['+pageName+']</div>');
	return;
}

function moveSidebar() {
	if (iPhone) {
		if (!(jQuery('#sidebar').css('display')=='none')) {
			jQuery('#footer').prepend(jQuery('#sidebar'));
		}
	}
	return;
}

function fixiDevSB() {
	if (iPhone || iPad) {
	jQuery('#content a').click(function(e) {
		var relTag=jQuery(this).attr('rel');
		if ((/shadowbox/gi.test(relTag)) || (/lightbox/gi.test(relTag))) {
			var wScroll=jQuery(window).scrollTop();
			wScroll-=30;
			var wScrollCSS=wScroll+'px';
			jQuery('#sb-container').css('top', wScrollCSS);
		}
	});
	}
	return;
}

function fixOpera() {
	if(jQuery.browser.opera) {
		jQuery('#logo').css({'top': '0', 'marginTop': '0'});
		jQuery('#navcontainer').css({'top': '0', 'marginTop': '0'});
	}
	return;
}

function fixRC() {
	if(jQuery('#rcCart').length>0) {
		jQuery('#topBarBG').css('top', '38px');
		jQuery('#topBar').css('margin-top', '50px');
		jQuery('.remooz-box').css('zIndex', '1000');
		jQuery('a.remooz-btn-close').css('display', 'block');
	}
	return;
}
