function change_form_action(val)
{
	if($("quantity").value == "")
	{
		alert("Please enter product quantity.");
		$("quantity").focus();
		return false;
	}
	else
	{
/*		if(val == "offer")
		{
			$("add_cart_form").action = host+'common2/offer';
			$("add_cart_form").submit();
		}*/
		/*
		if(val == "add_cart")
		{
			$("add_cart_form").action = host+'cart/addtocart';
		}*/
		return true;
	}
}

function giveRating(product_id,rate)
{
	var url = host+'productdisplay/rating/pid/'+product_id+'/rate/'+rate;
	new Ajax.Updater('rating_div',url,{asynchronous:true, evalscripts:true, onComplete: function(request){ 
			return request.responseText;
		}
	});
}

function changeRating(id,event)
{
 	var css;
 	if(event=='over')
	{
    	css='star_box_over';
	    switch(parseInt(id))
		{
	     case 1:
			 $('rate_div').innerHTML='1 out of 5';
             break;
         case 2:
			 $('rate_div').innerHTML='2 out of 5';
             break;
         case 3:
			 $('rate_div').innerHTML='3 out of 5';
             break;
	     case 4:
			 $('rate_div').innerHTML='4 out of 5';
             break;
	     case 5:
			 $('rate_div').innerHTML='5 out of 5';
             break;	 
	    }
	
	}
 else
	{
	css='star_box';
// 	$('rate_div').innerHTML='Rate this Store';
	}
  
	for(var count=1;count<=id;count++)
	{ 
	  $('star_'+count).className=css;	  
	}

}

function ask_a_question(user_id,product_id)
{
	var message_url = site_url+"productdisplay/askquestion/user_id/"+user_id+"/pid/"+product_id;
		
		Modalbox.show(message_url,{title:'Ask a question:',height:285,width:400});
}

function check_question_blank()
{
	var message = document.getElementById("message");
	if(message.value == "")
	{
		alert("Please enter your message here.");
		message.focus();
		return false;
	}
	return true;
}


function tab(display_type)
{
	if(display_type=="video"){
		document.getElementById("display_video").style.display="";
// 		document.getElementById("display_video").style.visibility="visible";
		document.getElementById("video").className="tab_active";
		document.getElementById("display_video").className="product_video";
		document.getElementById("display_photos").style.display="none";
// 		document.getElementById("display_photos").style.visibility="hidden";
		document.getElementById("photos").className="tab_inactive";
		document.getElementById("display_photos").className="product_image  displayNone";
		
		
	}
	if(display_type=="photos"){
		document.getElementById("display_video").style.display="none";
// 		document.getElementById("display_video").style.visibility="hidden";
		document.getElementById("video").className="tab_inactive";
		document.getElementById("display_video").className="product_video displayNone";

		document.getElementById("display_photos").style.display="";
// 		document.getElementById("display_photos").style.visibility="visible";
		document.getElementById("photos").className="tab_active";
		document.getElementById("display_photos").className="product_image";
	
	}
}
