﻿function txtFocus(x)
	{
		if ((x.value == "Name") || (x.value == "Email") || (x.value == "Enter Keyword"))
		{
			x.value = "";
			x.style.color = "#542a18"
		}
	}
	
function txtFocusLost(x)
{
	if (x.value == "")
	{
		if (x.name == "name")
		{
			x.value = "Name";
			x.style.color = "gray";
		}
		else if (x.name == "search")
		{
			x.value = "Enter Keyword";
			x.style.color = "gray";
		} 			
		else
		{
			x.value = "Email";
			x.style.color = "gray";
		}
	}
}

/*SWITCH*/

function displayReviews()
{
	var x = document.getElementById('review_container');
	
	
	if (x.style.display == 'block')
	{
		x.style.display = 'none';
	}
	else
	{
		x.style.display = 'block';
	}
}

function displayWriteReview()
{
	var x = document.getElementById('write_a_review_container');
	
	
	if (x.style.display == 'block')
	{
		x.style.display = 'none';
	}
	else
	{
		x.style.display = 'block';
	}
}
/*SWITCH*/

/*RATING*/
function setRating(x)
{
	document.getElementById('therating').value = x;
	
	for(var i = 1; i <= x; i++)
	{
		document.getElementById('star_' + i).src = '/_template/images/product/star_color_rate.png';
	}
	for(var i = x+1; i <= 10; i++)
	{
		document.getElementById('star_' + i).src = '/_template/images/product/star_bw_rate.png';
	}
}

function changeStar(x)
{
	for(var i = 1; i <= x; i++)
	{
		document.getElementById('star_' + i).src = '/_template/images/product/star_color_rate.png';
	}
	for(var i = x + 1; i <= 10; i++)
	{
		document.getElementById('star_' + i).src = '/_template/images/product/star_bw_rate.png';
	}
}

function removeStar()
{
	x = document.getElementById('therating').value;
	
	for(var i = 1; i <= 10; i++)
	{
		document.getElementById('star_' + i).src = '/_template/images/product/star_bw_rate.png';
	}
	
	if (x != "")
	{
		for(var i = 1; i <= x; i++)
		{
			document.getElementById('star_' + i).src = '/_template/images/product/star_color_rate.png';
		}
	}
}

/*RATING*/


/*IMAGE FADING CODE
*/

var opacity = 100;
var thesrc;
var theImage;

function changeImage(x) 
{ 
	thesrc = "/_images/_images/l/" + x + ".jpg";
	document.getElementById('large_image').src = "/_images/_images/xl/" + x + ".jpg";
	
 	theImage = document.getElementById("main_image"); 
	
	
	
	fadeOut();
} 

//change the opacity for different browsers 
function fadeOut()
{ 
	if (opacity > 0)
	{
		opacity = opacity - 10;
		
	    theImage.style.opacity = (opacity / 100); 
	    theImage.style.MozOpacity = (opacity / 100); 
	    theImage.style.KhtmlOpacity = (opacity / 100); 
	    theImage.style.filter = "alpha(opacity=" + opacity + ")";
	    
	    setTimeout('fadeOut()', 10);
    }
    else
    {
    	fadeIn();
    }
}

function fadeIn()
{
	theImage.src = thesrc;

	if (opacity <= 100)
	{
		opacity = opacity + 10;
		
	    theImage.style.opacity = (opacity / 100); 
	    theImage.style.MozOpacity = (opacity / 100); 
	    theImage.style.KhtmlOpacity = (opacity / 100); 
	    theImage.style.filter = "alpha(opacity=" + opacity + ")";
	    
	    setTimeout('fadeIn()', 10);
    }
}
/*IMAGE FADING CODE*/
