/* eyFadeMenus.js */

function mouseLeaves (element, evt) {
if (typeof evt.toElement != 'undefined' && evt.toElement && typeof element.contains != 'undefined') {
return !element.contains(evt.toElement);
}
else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
return !contains(element, evt.relatedTarget);
}
}

function contains (container, containee) {
while (containee) {
if (container == containee) {
return true;
}
containee = containee.parentNode;
}
return false;
}

function hideElement (element) {
if (element.style) {
$(element).fadeOut("500");
}
}

function showElement (element) {
if (element.style)
{
if (element.style.display == "block")
{
$(element).fadeOut("500");
}
else
{
//$(".topDDMenus").css("display", "none");
$(".topDDMenus").fadeOut("500");
$(element).fadeIn("500");
}
}
}

function hideAll()
{
$(".topDDMenus").fadeOut("500");
}


/* cleopatraschoice-b.js */

function check()
{
  if(document.thecontactform.name.value.length==0)
  {
   alert('Please enter your name');
   document.thecontactform.name.focus();
   return;
  }
  if(document.thecontactform.email.value.length==0)
  {
   alert('Please enter your email address');
   document.thecontactform.email.focus();
   return;
  }
  if(document.thecontactform.message.value.length==0)
  {
   alert('Please enter your inquiry');
   document.thecontactform.message.focus();
   return;
  }
document.thecontactform.submit();
}

function changeFAQ(b){
if(document.getElementById('FAQA'+b).style.display == 'block')
{
$(".FAQQ").css("background", "url(http://lib.store.yahoo.net/lib/yhst-128337017012708/ey-faqArrUp.jpg) no-repeat scroll left 3px");
$(".FAQA").css("display", "none");
}
else
{
$(".FAQQ").css("background", "url(http://lib.store.yahoo.net/lib/yhst-128337017012708/ey-faqArrUp.jpg) no-repeat scroll left 3px");
$("#FAQQ" + b).css("background", "url(http://lib.store.yahoo.net/lib/yhst-128337017012708/ey-faqArrDown.jpg) no-repeat scroll left 3px");
$(".FAQA").css("display", "none");
$("#FAQA" + b).css("display", "block");
}
}

function changeTab(b){
$(".tabLinks").css("display","none");
$("#TabLinks"+b).css("display","block");
$(".tabs").css("display","none");
$("#Tab"+b).css("display","block");
}

$(document).ready(function(){
$(".qtyTable tr:even").addClass("even"); 
$(".qtyTable tr:odd").addClass("odd"); 
}); 

function checkQty()
{
var availableText=$(".available").text();
var splitMe=availableText.split(" ");
var result=parseInt(splitMe[0]);

if (document.theOrderForm.vwquantity.value > result)
{
alert("We're sorry.  There are only "+result+" of this item available.  Please re-enter a valid quantity.");
$("input.theqty").val(result);
return;
}
else
{
document.theOrderForm.submit();
}
}

function checkURL(){
var urlTemp=self.location.href.split("?");
if(urlTemp.length>1)
{
if(urlTemp[1] == "reviews")
{
changeTab(3);
}
}
}


function checkQty()
{
var availableText=$(".available").text();
//var splitMe=availableText.split(" ");
//var result=parseInt(splitMe[0]);

var result = parseInt(availableText);
var myqty = parseInt(document.theOrderForm.vwquantity.options[document.theOrderForm.vwquantity.selectedIndex].value);

if (myqty > result)
{
alert("We're sorry.  There are only "+result+" of this item available.  Please select a valid quantity.");
//$("input.theqty").val(result);
return;
}
else
{
document.theOrderForm.submit();
}
}

function changeContTab(b)
{
$(".tabContName").removeClass("activeContTab");
$("#TabContName"+b).addClass("activeContTab");

$(".tabContents").css("display", "none");
$("#TabContents"+b).css("display", "block");
}

function changeContTabSect(b)
{
$(".tabContName").removeClass("activeContTab");
$("#TabContName"+b).addClass("activeContTab");

$(".tabContentsSect").css("display", "none");
$("#TabContents"+b).css("display", "block");
}

$(document).ready(function(){
	
	$('#toggle-review-form').unbind();
	
	$('#toggle-review-form').bind('click', function(event){
		
		event.preventDefault();
		
		if($('#review-form').is(':visible')) {
			$('#review-form').hide();
		} else {
			$('#review-form').show();
			$(document).height(320);
		}
		
	});

        $('#review-submit').unbind();
	$('#review-submit').bind('click', function(event){
              $('#review-form').hide();
              alert('Your review has been submitted and is waiting on approval');
        });
		
	$('#gift-submit2').bind('click', function(event){
         $("#weekly-specials").append("<img src=\"http://app.bronto.com/public/?q=direct_add&fn=Public_DirectAddForm&id=bplyxqgqwzlcpvcddogaklxcuaiaben&email=" + $('#gift-email').val() + "&sendWelcome=yes&messageId=ce18d64fa4a880f48c26955a19b372aa&fromName=CleopatrasChoice.com&fromAddress=support%40cleopatraschoice.com\" width=\"0\" height=\"0\" border=\"0\" alt=\"\"/>");
     });
});

function goToSignup()
{
window.location.href="signup.html?" + $('#gift-email').val();
}

function submitBundle()
{
document.theBundleForm.submit();
}
