binatone = binatone || {};
binatone.productView = {};
binatone.productView.slideShow = false;
binatone.productView.tabsId = ['features', 'gallery', 'video'];
binatone.productView.tabs = function(tab, contentId) {
	/*var tab =  document.getElementById(tabElement);*/
	tab.className = 'active';
	for(var i = 0; i < binatone.productView.tabsId.length; i++) {
		if(binatone.productView.tabsId[i] == contentId) {
			document.getElementById(binatone.productView.tabsId[i]).style.display = 'block';
		}else if (binatone.productView.tabsId[i] != contentId) {
			var tabElement = document.getElementById(binatone.productView.tabsId[i]+'_tab');
			tabElement.className = '';
			document.getElementById(binatone.productView.tabsId[i]).style.display = 'none';
		}
	}
	
}

binatone.productView.gallerySlide = function() {
	if(binatone.productView.slideShow == false) {
		$(document).ready(function(){
		
			$('#productGallery').galleryView({
				panel_width: 720,
				panel_height: 540,
				panel_scale: 'nocrop',
				frame_scale: 'nocrop',
				filmstrip_position: 'top',
				transition_interval: 0
			});
		});
		binatone.productView.slideShow = true;
	}
}

binatone.productView.productHistory = function(imageUrl, productName, productCategory) {
	var productStatusDiv = document.getElementById(productName);
	var index = binatone.productCompare.product.indexOfProductName(productName);
	if(index != -1) {
		var remove = document.createElement("a");
		remove.setAttribute("href", "javascript:void(0)");
		remove.onclick = function() {binatone.productCompare.removeFromCompare(imageUrl, productName, productCategory)};
		remove.innerHTML = "Remove";
		productStatusDiv.appendChild(remove);
	}else if(index == -1) {
		var input = document.createElement("input");
		input.setAttribute("id", productName+"_checkbox");
		input.setAttribute("type", "checkbox");
		input.className = "checkStd";
		input.onclick = function() {binatone.productCompare.addToCompare(imageUrl, productName, productCategory)};
		var span = document.createElement("span");
		span.innerHTML = "Add to Compare";
		productStatusDiv.appendChild(input);
		productStatusDiv.appendChild(span);
	}
}

binatone.productView.imageGallery = function(element, productName, currentImage, imageCount) {
	var count = parseInt(imageCount, 10);
	for(var i = 1; i < count; i++) {
		document.getElementById(productName+"_g_"+i).style.display = 'none';
	}
	document.getElementById(currentImage).style.display = 'block';
}

binatone.productView.videoGallery = function( element, productName, currentVideo, videoCount) {
	var count = parseInt(videoCount, 10);
	for(var i = 1; i < count; i++) {
		document.getElementById(productName+"_v_"+i).style.display = 'none';
		document.getElementById(productName+"_v_"+i+"_row").className = 'vidRow';
	}
	document.getElementById(currentVideo).style.display = 'block';
	document.getElementById(currentVideo+"_row").className = 'vidRow activeRow';
	
}



