$(document).ready(function(){
	// Round the corners of selected div tags
	$(function(){ 
		settings = {
			tl: { radius: 13 },
			tr: { radius: 13 },
			bl: { radius: 13 },
			br: { radius: 13 },
			antiAlias: true,
			autoPad: false,
			validTags: ["div"]
		}
		$('.tr_box, .tr2_box, .bl_box, .bl2_box, .bottom_gallery, #feedback_form, #wholeC', '.main_body').corner(settings);
   });
   
   // Additional box added for client
   // If content added the code below will find height of content and adjust container height css
   // This is to ensure the content doesn't run over the footer, not all pages will have content
   var addBox = $('.add_box').height();
   if (addBox > 14) // 14 as internet explorer is the only one to report a height => 14?
   { 
	  addBox = addBox + 10;
	  $('.add_space').css({'height' : addBox+'px','paddingBottom' : '5px'});
	  $('.add_box').corner(settings);
   }
   
    $('#backtop', '.main_footer').click(function() {
        scrollWin('.main_container');
    });
	$('#backtop', '.main_footer').hover(function () {
		$(this).css("color", "#ffffff");
	}, 
		function () {
			$(this).css("color", "#bbb4be");
		}
	);   
});

function checkPin(v,m,f)
{
	an = m.children('#pin_num');

	if(f.pin_num == "")
	{
		an.css("border","solid #ff0000 1px");
		return false;
	}
	return true;

}

function mycallbackform(v,m,f){
	if(v != undefined)
	{
		$.prompt(v +' ' + f.alertName);
	}
}
	
function submittPin()
{
	var pinTxt = 'Please enter the Bride and Grooms Pin Number:<br /> input type="text" id="pin_num" name="pin_num" value="" />';

	$.prompt(pinTxt,{
	submit: checkPin,
	callback: pinSubmitted,
	buttons: { Ok:true }
	});
}

function vdc_processForm()
{
	var ele = '.formAjax';
	var url = root_url+'/login/forms/process.php';
	var args = $('#contactForm').serialize();

	// Make ajax call
	var vdc_ajaxCall = $.ajax({
		cache: false,
		timeout: 5000,
		type: 'POST',
		url: url,
		data: args,
		success: function(data) {
			$(ele).html(data);
		},
		error: function(jqXHR, textStatus, errorThrown) {
			vdc_catchError(jqXHR, textStatus, errorThrown, ele);
		}
	});
}

function vdc_feedbackForm()
{
	var ele = '.formAjax';
	var url = root_url+'/login/forms/process.php';
	var args = $('#feedbackForm').serialize();
	
	// Make ajax call
	var vdc_ajaxCall = $.ajax({
		cache: false,
		timeout: 5000,
		type: 'POST',
		url: url,
		data: args,
		success: function(data) {
			$(ele).html(data);
		},
		error: function(jqXHR, textStatus, errorThrown) {
			vdc_catchError(jqXHR, textStatus, errorThrown, ele);
		}
	});
}
