function initPage()
{
	var rates = document.getElementsByTagName("ul");
	for (i = 0; i < rates.length; i ++)
	{
		if (rates[i].className.indexOf("star-rating") != -1)
		{
			rates[i]._lis = rates[i].getElementsByTagName("li");
			
			/*
			rates[i].onmouseover = function() {
				for (k = 0; k < this._lis.length; k++)
				{
					if (this._lis[k].className.indexOf("active") != -1)
					{
						this._active = this._lis[k];
						this._lis[k].className = this._lis[k].className.replace("active", "");
					}
				}
			}
			rates[i].onmouseout = function() {
				if (this._active && this._active.className.indexOf("active") == -1)
				{
					this._active.className += "active";
				}
			}
			*/
			for (k = 0; k < rates[i]._lis.length; k++)
			{
				rates[i]._lis[k].onclick= function(){
					//Deactivate others
					$("li[id^=Star]").each(function (i) {$(this).removeClass('active');});
					//Activate selected
					//alert(this.id);
					this.className = 'active';
					//$(this).addClass('active');
				}
			}
		}
	}
}

function initTabs(){
	var sets = document.getElementsByTagName("ul");
	for (var i = 0; i < sets.length; i++){
		if (sets[i].className.indexOf("tabs") != -1){
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++){
				if (links[j].className.indexOf("tab") != -1){
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

	//reset all tabs on start
					if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";

					links[j].onclick = function (){
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c){
	//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++){
								document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
							return false;
						}
					}
				}
			}
		}
	}
}

function initPopups() {
	if (typeof $().simpleLightbox == 'function') {
		$('a.btn-leave-comment').simpleLightbox();
		$('a.btn-table').simpleLightbox();
	}
}
$(document).ready(function(){
	initPopups();
	initPage();
	initTabs();
});


function replaceImage (imagePath, imageRes) {
	document.images.productImage.src = imagePath;
	bigImageRes = imageRes;
}

// Adios explorer 6.0 
function warningExplore (){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{ //test for MSIE x.x;
		 var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number
		 if (eval(ieversion)<=6){
			 if(document.getElementById('opcion_ie6') != null){
				 document.getElementById('opcion_ie6').style.display = "block";
				 document.getElementById('version').innerHTML = 'Si ve mal esta página es posible que sea porque su navegador es Internet Explorer ' + ieversion + '.';
			 }
		} 
	} else {
			 document.getElementById('opcion_ie6').style.display = "none";
			
	}
}




