$(document).ready(function() { 
	$("a.group").fancybox(); 
	$("a.map").fancybox({'frameWidth':600,'frameHeight':450}); 
	$("a.checkavail").fancybox({'frameWidth':600,'frameHeight':530, 'padding':20}); 
	$("a#rss-help").fancybox({'frameWidth':600,'frameHeight':510, 'padding':10 }); 
	
}); 

function DoDel(iserial)
{
	if (confirm("Are you sure?"))
	{
		window.location.href=iserial;
	}
}

function DoQuit()
{
	if (confirm("Exit without save changes?"))
	{
		window.location.href='my_refarm.php';
	}
}

function show_window(sid,h,w)
{

  var popup = window.open("aa", "News",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + h + ',height=' + w);
  popup.location = sid;

}

function show_bar_window(sid,h,w)
{

  var popup = window.open("", "News",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + h + ',height=' + w);
  popup.location = sid;

}

function subscribe_newsletter() {
	
	var email=$("#subscribe_email").attr('value');
	
	var fail=0; error="";
	
	if ((email=="") || (email=="Enter your email address")) { error+='Please enter your Email Address'; fail=1; }
	if ((!isValidEmail(email)) && (email!="Enter your email address")) { error+='Please enter a correct Email Address'; fail=1; }

	if (fail==0) {
		var dataString="pg=subscribe&name=" + name + "&email=" + email;
		
		$.ajax({  
		   type: "GET",  
		   url: "index.php",  
		   data: dataString,  
		   success: function(msg) {  
				document.getElementById('newsletter').innerHTML='<span class="message-text">' + msg + '</span>';
		   }  
		});  
	} else {
		alert(error);
	}
     
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function checkUncheckAll(theElement) {
	 //documentation for this script at http://www.shawnolson.net/a/693/
    var theForm = theElement.form, z = 0;
    while (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
     theForm[z].checked = theElement.checked;
     z++;
    }
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}
