WebFontConfig = {
	google: { families: [ 'Droid+Sans:400,700:latin' ] }
};
(function() {
	var wf = document.createElement('script');
	wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
	  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
	wf.type = 'text/javascript';
	wf.async = 'true';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(wf, s);
})();
  
function setBodyWidth() {
	// SET BODY WIDTH IF BELOW 980
	var win_w = $(window).width();
	//
	if(win_w < 980){
		$('body').width(980);
	} else {
		$('body').width(win_w);	
	}
}

$(window).load(function () {
	$('#lng li').hover(
	function(){
		$(this).find('img').fadeIn();
	},
	function(){
		$(this).find('img').fadeOut();
	});
});

function get_val(fld){
	if($(fld).length){
		v = $(fld).val();
		return v;
	} else {
		alert('No Matching Field!\nID:'+fld);
		return false;
	}
}

function is_email(eml) {
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	if(eml=='' || !emailReg.test(eml)) {
		return false;
	} else {
		return true;
	}
}
//
function pop_msg(id){
	$.colorbox({
		scrolling:false,
		inline:true,
		href:"#"+id,
		transition:'none',
		initialWidth:50,
		initialHeight:14,
		onLoad: function() {
			//alert('onLoad');
		},
		onComplete: function() {

		}
	});	
}

$(window).resize(function () {setBodyWidth();});

$(window).load(function(){
	// SET BODY WIDTH
	setBodyWidth();
	//
	// GIVE ALL ONCLICK ELEMENTS A CURSOR
	$('td,div,img').each(function(){
		if($(this).attr('onclick')){
			$(this).css('cursor', 'pointer');
		}
	});
	//
	// SET IMG BTN ROLLOVERS
	$('div.btn').each(function(index) {		
		$(this).css('display', 'block');
		//
		var btn_w = $(this).find("img").width();
		var btn_h = ($(this).find("img").height())*0.5;
		//
		//alert('btn:'+btn_w+'x'+btn_h+';');
		//		
		$(this).css('width', btn_w+'px');
		$(this).css('height', btn_h+'px');
		//
		$(this).mouseover(function() {
			$(this).find("img").css('top', '-'+btn_h+'px');
		}).mouseout(function() {
			$(this).find("img").css('top', '0px');
		});
	});
	//
	// ALIGN FOOTER ICONS
	//var ftr_nav_w = $('#ftr ul.nav').outerWidth();
	$('#ftr ul.nav').each(function(){
	   ftr_nav_w = 0;   
	   $(this).children('li').each(function(i, e){
		  ftr_nav_w = ftr_nav_w + $(e).outerWidth();
	   });
	});
	//
	//alert(ftr_nav_w);
	var ftr_nav_m = (920-ftr_nav_w)/2;
	$('#ftr ul.nav').css('margin', '230px 0px 0px '+ftr_nav_m+'px');
	//
	$('#ip_btn').mouseover(function() {
		$(this).css('background-position', '0px -24px');
	}).mouseout(function() {
		$(this).css('background-position', '0px 0px');
	});
	//
	// SET COLORBOX LINKS
	$("a[rel='tmb']").colorbox({current:'Photo {current} of {total}'});
	$("a[rel='lnk']").colorbox({current:'Menu {current} of {total}'});
	$("a[rel='tst']").colorbox({current:'Testimonial {current} of {total}'});
	//
	$("li[class='vid_link']").colorbox({
		href:"http://www.residencesvictoria.com/videos.asp?vidzpls",
		iframe:'true',
		nofollow:'true',
		innerHeight:'570',
		innerWidth:'480'
	});
	//
	// ADD FUNCTIONALITY TO CHKBOX DIVS
	$('div.chkbox').bind('click', function() {
		var real_input = $(this).attr('id').replace('chk_', '');
		//
		if($(this).hasClass('chkd')){
			$(this).removeClass('chkd');
			$('#'+real_input).val(0);
		} else {
			$(this).addClass('chkd');
			$('#'+real_input).val(1);
		}
	});
	//
	$('#frm_btn_en').bind('click', function() {
		valform_en();
	});
	//
	$('#frm_btn_pt').bind('click', function() {
		valform_pt();
	});
});
//
function input_err(id){
	if(id.substring(0,1) != "#"){
		var id = "#"+id;
	}
	//
	var input_fld = $(id);
	var input_div = input_fld.parent().find('p').addClass('input_err');
}
//
function valform_en(){
	//
	var sub_form = true;
	$('p').removeClass('input_err');
	$('#err_inf ul').empty();
	//
	if($("#enq_fname").val() == ""){
		input_err('#enq_fname');
		$('#err_inf ul').append('<li>Please enter a first name</li>');
		sub_form = false;
	}
	//
	if($("#enq_lname").val() == ""){
		input_err('#enq_lname');
		$('#err_inf ul').append('<li>Please enter a last name</li>');
		sub_form = false;
	}
	//
	if($("#enq_phone").val() == ""){
		input_err('#enq_phone');
		$('#err_inf ul').append('<li>Please enter a phone number</li>');
		sub_form = false;
	}
	//
	if(!is_email($("#enq_email").val())){
		input_err('#enq_email');
		$('#err_inf ul').append('<li>Please enter a valid email address</li>');
		sub_form = false;
	}
	//
	if($("#enq_comments").val() == ""){
		input_err('#enq_comments');
		$('#err_inf ul').append('<li>Please enter some comments</li>');
		sub_form = false;
	}
	//
	if (!sub_form) {
		pop_msg('err_inf');
		return false;
	} else {
		//alert('Success');
		$("#form_div").wrap('<form id="enq_info" />');
		//$('#enq_info').attr('action', 'mailers/contactus_en.php');
		$('#enq_info').attr('action', 'contactus.asp');
		$('#enq_info').attr('method', 'post');
		$('#enq_info').submit();
		return true;
	}
}
			
//
$(window).load(function(){
	$('.fade_slide_show li').css('display', 'block');
	fade_show();
});
//
function fade_show(){
	if($('.fade_slide_show li').size() > 1){
		$('.fade_slide_show').fadeSlideShow({
			width:720,
			height:300,
			speed: 1000, // default animation transition speed
			interval: 2000, // default interval between image change
			PlayPauseElement: '', // default css id for the play / pause element
			PlayText: '', // default play text
			PauseText: '', // default pause text
			NextElement: '', // default id for next button
			NextElementText: '', // default text for next button
			PrevElement: '', // default id for prev button
			PrevElementText: '', // default text for prev button
			ListElement: 'fssCtrl', // default id for image / content controll list
			ListLi: 'fssLi', // default class for li's in the image / content controll 
			ListLiActive: 'fssActive', // default class for active state in the controll list
			addListToId: 'fss_ctrl', // add the controll list to special id in your code - default false
			allowKeyboardCtrl: true, // allow keyboard controlls left / right / space
			autoplay: true // autoplay the slideshow
		});
	}
}
