
function addToCart(element){
	stockid=$j("#"+element).val();
	if(stockid==''){
		alert("Please select an in stock size to add to your cart.")
	}else{
		document.location='/cart/add/'+stockid;
	}
}



function catalog(){
	fd = $j("#finddesigns");
	document.location='/catalog'+fd.val();
	return true;
}

function getSourceScroll(type){
	$j("#source").slideIntoView();
	getSource(type);
}

function getSource(type){
	$j("#sourcebox").html("<div class=\"p_10\"><img src=\"/imgs/loading.gif\" width=\"18\" height=\"18\"align=\"absmiddle\"/> Loading...</div>");
	var types = new Array('all','news','events');
	for ( var i=0, len=types.length; i<len; ++i ){
		if (types[i] == type) {
			$j('#source_' + type).addClass('active');
		} else {
			$j('#source_' + types[i]).removeClass('active');
		}
	}	
	$j.ajax({
		type: "post", url: "/scripts/sourcebox.php", data: "type="+type,
		success: function(html){
			$j("#sourcebox").html(html);
		}
	});	
}

function sourcePost(action){
	var pars = $j('#sourcePostForm').serialize();
	$j("#sourcebox").html("<div class=\"p_10\"><img src=\"/imgs/loading.gif\" width=\"18\" height=\"18\"align=\"absmiddle\"/> Saving...</div>");
	$j.ajax({
		type: "post", url: "/scripts/sourcebox.php", data: "&type="+action+"&"+pars,
		success: function(html){
			$j("#sourcebox").html(html);
		}
	});		
}
function sourcePage(page,vars){
	$j("#sourcebox").html("<div class=\"p_10\"><img src=\"/imgs/loading.gif\" width=\"18\" height=\"18\"align=\"absmiddle\"/> Loading...</div>");
	$j.ajax({
		type: "post", url: "/scripts/sourcebox.php", data: "&page="+page+"&"+vars,
		success: function(html){
			$j("#sourcebox").html(html).scrollTop(0);
		}
	});		
}
function nextPhoto(){
	if(photoIndex >= photoArray.length-1){
		photoIndex=0;
	}else{
		photoIndex++;
	}
	$j("#photo").attr("src",photoArray[photoIndex]);
}

function toggleZoom(){
	$j("#productzoom").toggle();
	$j("#productphotos").toggle();
	if(isVisible("productzoom")){
		$j('#productzoom').slideIntoView();	
	}else{
		$j('#productphotos').slideIntoView();
	}
}

function showOther(filename,width,height){
	if(filename!=''){
		$j('#otherwork').html('<div class="blackoverlay i"><a href="javascript:showOther()" class="nou">Back to listing</a></div><a href="javascript:showOther()"><img src="'+filename+'" width="'+width+'" height="'+height+'"/></a>');
	}	
	$j("#otherwork").toggle();
	$j("#otherlisting").toggle();
	if(isVisible("otherwork")){
		$j('#otherwork').slideIntoView();	
	}else{
		$j('#otherlisting').slideIntoView();
	}
}

function isVisible(elementName){
	if($j("#"+elementName).css("display")=='none'){
		return false;
	}else{
		return true;
	}
}

function checkusername(nm){
	$j.ajax({
		type: "post", url: "/join/check", data: "&username="+nm,
		success: function(html){
			$j("#usercheck").html(html);
		}
	});	
}
function addNewsletter(){
	var pars = $j('#newsletterForm').serialize();
	$j("#addNewsletter").html("<img src=\"/imgs/loading.gif\" width=\"18\" height=\"18\"align=\"absmiddle\"/> Adding you to our newsletter...");	
	$j.ajax({
		type: "post", url: "/scripts/addnewsletter.php", data: "&"+pars,
		success: function(html){
			$j("#addNewsletter").html(html);
		}
	});	
	return false;	
}