$(document).ready(function() { /* This is basic - uses default settings */ 
	$("a#single_image").fancybox(); /* Using custom settings */ 
	$("a#inline").fancybox({ 'hideOnContentClick': true }); 
	$("a.iframe").fancybox({ 'zoomSpeedIn': 300, 'overlayShow': true, 'frameWidth':600, 'frameHeight':430 });
	$("a.group").fancybox({ 'zoomSpeedIn': 500, 'zoomSpeedOut': 500, 'overlayShow': false }); }); 


/* end JQuery */

function toggle_menu(id) {
	tmp=document.getElementById('menu' + id);
	tmp1=document.getElementById('top' + id);
	if (tmp.style.display=='none') { 
		tmp.style.display=''; 
		tmp1.className="selected1";
	} else {
		tmp.style.display='none'; 
		tmp1.className="";
	}
}

function toggle_box(id) {
	total=document.getElementById('totalgroup').value;
	tmp=document.getElementById('box' + id);
	
	for (i=1;i<=total;i++) {
		document.getElementById('box' + i).style.display='none';	
	}

	tmp.style.display=''; 

}

function default_text(obj,text,mode) {
	
	if (mode=='focus') {
		if (obj.value==text) { obj.value='';  }
	} else {
		if (obj.value=='') 	{
			obj.value=text;
		}
	}

}

function select_plan(id) {
	document.getElementById('pln' + id).checked=true;	
	
}

function animate( way ){
	if(way == "up"){
		$('.open').parent().find("ol").slideUp("fast");
	} else {
		$('.open').parent().find("ol").slideDown("fast");
	}
}


function subscribe_newsletter() {
	
	var name=$("#subscribe_name").attr('value');
	var email=$("#subscribe_email").attr('value');
	
	var fail=0; error="";
	
	if ((name=="") || (name=="Enter your name")) { error='Please enter your name\n'; fail=1; }
	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 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('message').innerHTML='<span class="message-text">' + msg + '</span>';
		   }  
		});  
	} else {
		alert(error);
	}
     
}

function sub_focus(id,obj) {

	switch (id) {
		case 1: if (obj.value=="Enter your name") { obj.value=''; } break;
		case 2: if (obj.value=="Enter your email address") { obj.value=''; } break;
	}
}

function sub_blur(id,obj) {

	switch (id) {
		case 1: if (obj.value=="") { obj.value='Enter your name'; } break;
		case 2: if (obj.value=="") { obj.value='Enter your email address'; } break;
	}
}

/* Switch on/off to textfield background texture */
function smarttip_focus(obj) {
		
	obj.style.background='none';
}

function smarttip_blur(obj,pic) {
	if (obj.value=="") { obj.style.background="url(/images/" + pic + ") no-repeat 4px 4px"; }
}

function showprice(obj) {
	
	if (obj.checked) {
		document.getElementById('exam').style.display='';
	} else {
		document.getElementById('exam').style.display='none';
	}
}


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 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);
}


	

function switch_payment(id) {
	switch (id) {
		case 1:
		document.getElementById('box1').style.display='';
		document.getElementById('box2').style.display='none';
		document.getElementById('box3').style.display='none';
		break;
		
		case 2:
		document.getElementById('box1').style.display='none';
		document.getElementById('box2').style.display='';
		document.getElementById('box3').style.display='none';		
		break;


	}
}

