var currentTweet = 0;
var currentBG = 0;
var twitSliderTO;

function replaceURLWithHTMLLinks(inputText) {
  //URLs starting with http://, https://, or ftp://
    var replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/gim;
    var replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1&</a>');
 
    //URLs starting with www. (without // before it, or it'd re-link the ones done above)
    var replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
    var replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
 
    //Change email addresses to mailto:: links
    var replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
    var replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
 
    return replacedText
}



function switchBG() {
	$('#backgrounds li:eq(' + currentBG + ')').fadeOut(400);
	currentBG++;
	if (currentBG == $('#backgrounds ul:first').children().length) { currentBG = 0; }
	$('#backgrounds li:eq(' + currentBG + ')').fadeIn(400);
	setTimeout('switchBG()', 10000);
}
var currentProdIndex = 0;
var currentAlbumIndex = 0;
var canClick = true;
var signal = '-=';

function loadPageBGs(thePage) {
	res = '1024';
	if (screen.width >= 1920) {
		res = '1920';
	}
	if (screen.width < 1920 && screen.width > 1024) {
		res = 'full';
	}
	if (screen.width <= 1024 || window.orientation == 0 || Math.abs(window.orientation) == 90) {
		res = '1024';
	}
	$.ajax({
		type: "GET",
		url: basePath + 'getPageBGs.php',
		data: {page: thePage, screenRez: res},
		dataType: 'text',
		success: function(data) {
			if (data != '') {
				$('#backgrounds').html(data);
				if ($('#backgrounds ul:first').children().length > 1) { setTimeout('switchBG()', 10000); }
			}
		}
	});
}

$(document).ready(function() {
// start custom scroll

	//$("#gridFull").hide();
	$("#gridFull").fadeIn(1400);
	
	
	$('#article').scrollbar();
	
	$('.prodGalleryThumbs ul').each(function(index) {
		$(this).width(($(this).children('li').length+1) * 165);
	})
	

	if ($('#backgrounds ul:first').children().length > 1) { setTimeout('switchBG()', 10000); }
	
});
