﻿var tasterStatus;

function switchTaster(obj) {

	switch(obj){

	    case '1':
	        $('#tasterEnabled').fadeIn(function() { $('#tasterEnabled').oneTime(1500, function() { $('#tasterEnabled').fadeOut(); }) });
	        $('#freeReadingButton').hide();
	        $('#tasterReadingButton').show();
	        $('#profileImage').removeClass('taster1');
	        $('#profileImage').addClass('taster2');
	        $('#phoneNumTaster').show();
	        $('#phoneNum').hide();
	        $('#creditNumTaster').show();
	        $('#creditNum').hide();
			$('#ccNormalCost').hide();
			$('#ccTasterCost').show();
	        tasterStatus = true;
	        break;

	    case '2':
	        $('#tasterDisabled').fadeIn(function() { $('#tasterDisabled').oneTime(1500, function() { $('#tasterDisabled').fadeOut(); }) });
	        $('#freeReadingButton').show();
	        $('#tasterReadingButton').hide();
	        $('#profileImage').removeClass('taster2');
	        $('#profileImage').addClass('taster1');
	        $('#creditNumTaster').hide();
	        $('#creditNum').show();
	        $('#phoneNumTaster').hide();
	        $('#phoneNum').show();
			$('#ccNormalCost').show();
			$('#ccTasterCost').hide();
	        tasterStatus = false;
	        break;
	
	}

}

var phoneTaste;

function loadTaster(obj) {

    switch (obj) {

        case '1':
            $('#freeReadingButton').hide();
            $('#tasterPhone').show();
            $('#profileImage').removeClass('taster1');
            $('#profileImage').addClass('taster2');
            $('#phoneNumTaster').show();
            $('#phoneNum').hide();
            $('#creditNumTaster').show();
            $('#creditNum').hide();
			$('#ccNormalCost').hide();
			$('#ccTasterCost').show();
            phoneTaste = true;
            break;

        case '2':
            $('#freeReadingButton').show();
            $('#tasterPhone').hide();
            $('#profileImage').removeClass('taster2');
            $('#profileImage').addClass('taster1');
            $('#creditNumTaster').hide();
            $('#creditNum').show();
            $('#phoneNumTaster').hide();
            $('#phoneNum').show();
			$('#ccNormalCost').show();
			$('#ccTasterCost').hide();
            phoneTaste = false;
            break;

    }

}

function showTaster() {
	$('#tasterBox').show();
}	

function hideTaster() {
	$('#tasterBox').hide();
}

function paypalComplete() {
	$('#paypalStep1').hide();
	$('#paypalStep2').show();
}

function showContact() {
    $.scrollTo('0px', 500, { onAfter: function() { $('#contactInfo').show(); } });
}


function contactBox() {
    $('#contactInfo').show();
}


function closeContactBox() {
    $('#contactInfo').hide();
}	

var currentPanel = 2;

function showPanel(panel) {
    if (panel == "pnlPhonePayment") {
        switch (currentPanel) 
        {
            case 1:
                break;
            case 2:
                $('#pnlCCPayment').hide();
                $('#pnlPhonePayment').show();
                $('#phonePaymentButton').css("background-position", "left bottom");
                $('#currentOne').css("visibility", "visible");
                $('#creditCardPaymentButton').css("background-position", "left top");
                $('#currentTwo').css("visibility", "hidden");
                $('#paypalPaymentButton').css("background-position", "left top");
                $('#currentThree').css("visibility", "hidden");
                currentPanel = 1;
                if (tasterStatus) {
                    $('#tasterReadingButton').hide();
                    loadTaster('1');
                } else {
                    loadTaster('1');
                }
                break;
            case 3:
                $('#pnlPaypalPayment').hide();
                $('#pnlPhonePayment').show();
                $('#phonePaymentButton').css("background-position", "left bottom");
                $('#currentOne').css("visibility", "visible");
                $('#creditCardPaymentButton').css("background-position", "left top");
                $('#currentTwo').css("visibility", "hidden");
                $('#paypalPaymentButton').css("background-position", "left top");
                $('#currentThree').css("visibility", "hidden");
                currentPanel = 1;
                if (tasterStatus) {
                    $('#tasterReadingButton').hide();
                    loadTaster('1');
                } else {
                    loadTaster('1');
                }
                break;               
        }
    }
    if (panel == "pnlCCPayment") {
        switch (currentPanel) {
            case 1:
                $('#pnlPhonePayment').hide();
                $('#pnlCCPayment').show();
                $('#phonePaymentButton').css("background-position", "left top");
                $('#currentOne').css("visibility", "hidden");
                $('#creditCardPaymentButton').css("background-position", "left bottom");
                $('#currentTwo').css("visibility", "visible");
                $('#paypalPaymentButton').css("background-position", "left top");
                $('#currentThree').css("visibility", "hidden");
                currentPanel = 2;
                if (!tasterStatus || phoneTaste) {
                    loadTaster('2');
                }
                break;
            case 2:
                break;
            case 3:
                $('#pnlPaypalPayment').hide();
                $('#pnlCCPayment').show();
                $('#phonePaymentButton').css("background-position", "left top");
                $('#currentOne').css("visibility", "hidden");
                $('#creditCardPaymentButton').css("background-position", "left bottom");
                $('#currentTwo').css("visibility", "visible");
                $('#paypalPaymentButton').css("background-position", "left top");
                $('#currentThree').css("visibility", "hidden");
                currentPanel = 2;
                if (!tasterStatus || phoneTaste) {
                    loadTaster('2');
                }
                break;
        }
    }
    if (panel == "pnlPaypalPayment") {
        switch (currentPanel) {
            case 1:
                $('#pnlPhonePayment').hide();
                $('#pnlPaypalPayment').show();
                $('#phonePaymentButton').css("background-position", "left top");
                $('#currentOne').css("visibility", "hidden");
                $('#creditCardPaymentButton').css("background-position", "left top");
                $('#currentTwo').css("visibility", "hidden");
                $('#paypalPaymentButton').css("background-position", "left bottom");
                $('#currentThree').css("visibility", "visible");
                currentPanel = 3;
                if (!tasterStatus || phoneTaste) {
                    loadTaster('2');
                }
                break;
            case 2:
                $('#pnlCCPayment').hide();
                $('#pnlPaypalPayment').show();
                $('#phonePaymentButton').css("background-position", "left top");
                $('#currentOne').css("visibility", "hidden");
                $('#creditCardPaymentButton').css("background-position", "left top");
                $('#currentTwo').css("visibility", "hidden");
                $('#paypalPaymentButton').css("background-position", "left bottom");
                $('#currentThree').css("visibility", "visible");
                currentPanel = 3;
                if (!tasterStatus || phoneTaste) {
                    loadTaster('2');
                }
                break;
            case 3:
                break;
        }
    }
}



//Rating System---------------------------------------------

/*
Author: Addam M. Driver
Date: 10/31/2006
*/

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;

// Rollover for image Stars //
function rating(num){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	if(!rated){
		s = num.id.replace("_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById("_"+i).className = "on";
				document.getElementById("rateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById("_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){
	if(!rated){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById("_"+i).className = "";
				document.getElementById("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(preSet);
			document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML;
		}
	}
}

// When you actually rate something //
function rateIt(me){
	if(!rated){
		document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML + " :: "+me.title;
		preSet = me;
		rated=1;
		sendRate(me);
		rating(me);
	}
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
	alert("Your rating was: "+sel.title);
}

