var loader = new Image();
loader.src = 'images/loader_gray_dkbg.gif';
var smloader = new Image();
smloader.src = 'images/loader_gray_sm.gif';
function doNav(theUrl) {
	document.location.href = theUrl;
}
function pleaseWait(id) {
	$('pleaseWait'+id).show();
}
function showMyAccountWindow() {
	$('myAccountWindow').show();
	$('myAccountLink').className = 'myAccountSelected';
	$('myAccountLink').stopObserving('click',showMyAccountWindow);
	$('myAccountLink').observe('click',hideMyAccountWindow);
	return false;
}
function hideMyAccountWindow() {
	$('myAccountWindow').hide();
	$('myAccountLink').className = '';
	$('myAccountLink').stopObserving('click',hideMyAccountWindow);
	$('myAccountLink').observe('click',showMyAccountWindow);
	return false;
}
function equalizeHeight(id1,id2) {
	new Event.observe(window,'load',function() {
		var h1 = $(id1).getHeight();
		var h2 = $(id2).getHeight();
		if(h1 > h2) {
			$(id1).setStyle({'height':h1+'px'});
			$(id2).setStyle({'height':h1+'px'});
		} else if(h1 < h2) {
			$(id1).setStyle({'height':h2+'px'});
			$(id2).setStyle({'height':h2+'px'});
		}
	})
}
function showService(div) {
	$('loadingDiv').show();
	$('designDiv').hide();
	$('developmentDiv').hide();
	$('hostingDiv').hide();
	$('domainsDiv').hide();
	$('diyDiv').hide();
	$('ecommerceDiv').hide();
	$('consultingDiv').hide();
	$('loadingDiv').hide();
	$(div+'Div').show();
}
function deleteThis(id,type) {
	if(confirm('Are you sure you want to completely remove this '+type+'?')) {
		var url = $(id).href;
		doNav(url);
	}
	return false;
}

function addImage(iteration) {
	$('imageContainer').insert('<div id="img'+iteration+'"><input type="file" name="images[]" id="image'+iteration+'" />&nbsp;&nbsp;(<a href="javascript:removePortfolioImage(\''+iteration+'\');">remove</a>)</div>');
	iteration++;
	$('addImageLink').href= 'javascript:addImage(\''+iteration+'\');';
	equalizeHeight('leftBox','rightBox');
}
function removePortfolioImage(id) {
	$('img'+id).remove();
	equalizeHeight('leftBox','rightBox');
}
function loadPortfolioThumbs() {
	new Ajax.Updater('portfolioThumbs','ajax_portfolio.php?action=thumbs');
}
function loadPortfolio(id) {
	//new Effect.Appear('loadingView');
	//new Effect.SlideUp('portfolioView');
	new Ajax.Request('ajax_portfolio.php?id='+id,{
		method:'get',
		onSuccess:function(transport) {
			var response = transport.responseText;
			$('loadingView').hide();
			$('portfolioView').update(response);
			//new Effect.SlideDown('portfolioView');
			//new Effect.Fade('loadingView');
		},
		onFailure:function() { alert('We had trouble communicating with the server. Please try again.'); }
	});
	return false;
}