// JavaScript Document

function $_GET(q,s) { 
	s = s ? s : window.location.search; 
	var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i'); 
	return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined; 
}

$(document).ready(function(){

	$("a.package").click(function(){
		$("a.package").removeClass("active");
		$(this).addClass("active");
		
		var pkgid = $(this).attr("rel");
		$("#pkg"+pkgid+"").click();
		
		return false;
	});
	
	$("#pkgchoice5055").addClass("active");
	$("#pkg5055").attr("checked","checked");

});


function goSignup(method){

	//var getcreditsurl = "http://fireball.bsdtelecom.net/signup/";
	var email = $("#signup-email").val();
	var promo = $("#signup-promocode").val();
	var pkg = $('input:radio[name=package]:checked').val();
	var pay = method;
	
	var qv = "?";
	if(email != "") {qv += "email="+email+"&";}
	if(promo != "") {qv+= "promo="+promo+"&";}
	if(pkg != "") {qv+= "pkg="+pkg;}
	qv += "&pay="+pay;

	window.getcreditsurl += qv;
	
	window.location = window.getcreditsurl;
}


/***** Div panes for displaying mobile app instructions ****/
var paneAlreadyExtended = 0;
function clearPaneHeight() { if(paneAlreadyExtended) paneAlreadyExtended = 0; }
function showPanes(type, pane)
{	
	var mobile_type = "";
	if(type == 3) mobile_type = "blackberry";

	var fancyOuterHeight = $("#fancy_outer").height();
	var fancyDivHeight = $("#fancy_div div").height();
	var jqueryElem = '';

	if(!paneAlreadyExtended)
	{
		fancyDivHeight+=250;
		fancyOuterHeight+=250;
		paneAlreadyExtended = 1;
	}
	$("#fancy_outer").height(fancyOuterHeight);
	$("#fancy_div > div").height(fancyDivHeight);

	for(i=1; i<5; i++)
	{
			jqueryElem = '#fancy_div div.pane'+i;
			$(jqueryElem).hide();
	}
	jqueryElem = '#fancy_div div.pane'+pane;
	$(jqueryElem).show();
}

/***** End of div panes *****/

/***** Select Voice and Record Options *****/

var voiceval = "normal";
var recordval = "no-record";

$(document).ready(function(){
	
	$("a.voicebuttons").click(function(){
		$("a.voicebuttons").removeClass("active");
		if($(this).hasClass("no-voice")) voiceval = "normal";
		if($(this).hasClass("male-voice")) voiceval = "man";
		if($(this).hasClass("female-voice")) voiceval = "woman";
		
		$(this).addClass("active");
		
		$("#id_voice").val(voiceval);

		return false;
	});
	
	$("a.recordbuttons").click(function(){
		$("a.recordbuttons").removeClass("active");
		
		if($(this).hasClass("record-off")){
			$("a.notifybuttons").removeClass("active");
			$("a.notify-off").addClass("active");
			
			$("div.notify-options").hide();
			$("#notify-text").hide();
			
			recordval = "no-record";
		}
		
		if($(this).hasClass("record-on")){
			recordval = "no-announce";
			$("div.notify-options").show();
			$("#notify-text").show();
		}
		
		$(this).addClass("active");
		
		$("#id_record").val(recordval);
		return false;
	});
	
	$("a.notifybuttons").click(function(){
		
		if(recordval != "no-record"){
			$("a.notifybuttons").removeClass("active");
			if($(this).hasClass("notify-off")) recordval = "no-announce";
			if($(this).hasClass("notify-on")) recordval = "announce";
			$(this).addClass("active");	
			$("#id_record").val(recordval);
		}
		
		return false;
	});
	
	$(".call-field.phonenumber").click(function(){
		var val = $(this).val();
		if(val == 'Email' || val == 'My Number' || val == 'Number to Call' || val == 'Fake Caller ID')
			$(this).val('');	
	});
	
	$(".call-field.phonenumber").blur(function(){
		var val = $(this).val();		
		var alt = $(this).attr('alt');
		$(this).val(!val?alt:val);
	});

});

/***** End of Voice and Record Options ****/


/**** Twitter Popup *****/
var txt = "Dial-in Number";
function popup()
{
	$.prompt(txt);
}

function sendTweet()
{
	window.open('http://twitter.com/home?status=Fake your friends out for fun using a http://CallerIDFaker.com! Follow and RT @calleridfaker for a free premium account!');
	
}

/***** End of Twitter Popup *****/
