function BW_PicNumber(numPic) {
	if(numPic<10)
		return '0'+numPic;
	else
		return numPic;
}

function BW_SetCategory() {
	document.codeform.select_category.selectedIndex=BW_CategoryNumber;
}

function BW_ChangeCategory(strCat) {
	if(strCat!=0&&confirm('Do you want to jump to another category?'))
		document.location.href='photographic_'+strCat+'.html';
	else
		BW_SetCategory();
}

function BW_ChangePhoto(numPic) {
	if(numPic!=0) {
		numPic=arrImages[BW_CategoryNumber][3]+numPic-1;
		document.photo.src='gallery/'+arrImages[BW_CategoryNumber][1]+'/'+arrImages[BW_CategoryNumber][2]+'_'+BW_PicNumber(numPic)+'.jpg';
	}
	else
		document.photo.src='gallery/blank.gif';
}

function BW_ChangeICode(numPic) {
	document.codeform.select_image_code.selectedIndex=numPic;
}

function BW_OnThumbClick(numPic) {
	BW_ChangePhoto(numPic);
	BW_ChangeICode(numPic);
}

function BW_CalculatePrice() {
	if(document.codeform.select_frame_option.selectedIndex!=0&&document.codeform.select_art_size.selectedIndex!=0&&document.codeform.select_quantity.selectedIndex!=0) {
		result=arrPrices[document.codeform.select_frame_option.selectedIndex-1][document.codeform.select_art_size.selectedIndex-1]*document.codeform.select_quantity.selectedIndex;
		if(result==0)
			result='Not available';
		else
			result='Price: £'+result+' + VAT';
	}
	else
		result='Price:';
	document.codeform.price.value=result;
}

function BW_ValidateForm() {
	if(!BW_ValidateSelect('select_category'))
		return false;
	else if(!BW_ValidateSelect('select_image_code'))
		return false;
	else if(!BW_ValidateSelect('select_frame_option'))
		return false;
	else if(!BW_ValidateSelect('select_art_size'))
		return false;
	else if(!BW_ValidateSelect('select_orientation'))
		return false;
	else if(!BW_ValidateSelect('select_quantity'))
		return false;
	else if(document.codeform.price.value=='Not available') {
		alert('Not available');
		return false;
	}
	else {
		width=280;
		height=280;
		screenleft=(window.screen.width-width)/2;
		screentop=(window.screen.height-height)/2;
		window.open('','_form','height='+height+',width='+width+',fullscreen=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no,status=no,directories=no,channelmode=no,top='+screentop+',left='+screenleft+'');
		return true;
	}
}

function BW_ValidateSelect(strSel) {
	objSel=eval('document.codeform.'+strSel);
	if(objSel.selectedIndex==0) {
		alert(objSel.options[objSel.selectedIndex].text);
		return false;
	}
	else
		return true;
}