﻿function notEmpty(elem, helperMsg) {
    if (elem.value.length == 0) {
        alert(helperMsg);
        elem.focus(); // set the focus to this input
        return false;
    }
    return true;
}
function isNumeric(elem, helperMsg) {
    var numericExpression = /^[0-9]+$/;
    if (elem.value.match(numericExpression)) {
        return true;
    } else {
        alert(helperMsg);
        elem.focus();
        return false;
    }
}
function emailValidator(elem, helperMsg) {
    var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
    if (elem.value.match(emailExp)) {
        return true;
    } else {
        alert(helperMsg);
        elem.focus();
        return false;
    }
}
function isAlphabet(elem, helperMsg) {
    var alphaExp = /^[a-zA-Z']+$/;
    if (elem.value.match(alphaExp)) {
        return true;
    } else {
        alert(helperMsg);
        elem.focus();
        return false;
    }
}
function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3) {
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }
}
function Tabs(obj) {
    var select = function (link) {
        var div = $(link).attr("href");
        if (div) {
            $(obj).find('div.tab').hide();
            $(obj).find('ul.tabnav li a').removeClass("selected");
            $(link).addClass("selected");
            $(div).show();
        }
        return false;
    }
    var onclick = function () { return select(this); };
    var links = $(obj).find('ul.tabnav li a');
    links.each(function (index) { $(this).click(onclick); });
    select(links[0]);
}
$(function () {
    $(".tabs").each(function () {
        Tabs(this)
    });
});

$(function () {
	if($.fancybox) {
		$("#location1,#location2,#location3,#location4,#location5,#location6,#location7,#location8").fancybox({
			'width': 620,
			'height': 800,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'iframe',
			'showCloseButton': false
		});
		$("#schedule,#schedule2").fancybox({
			'width': 715,
			'height': 800,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'iframe',
			'showCloseButton': false
		});
		$("#message").fancybox({
			'width': 750,
			'height': 1000,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'iframe',
			'showCloseButton': false
		});
		$("#faq").fancybox({
			'width': 750,
			'height': 800,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'iframe',
			'showCloseButton': false
		});
	}
});

function addScript(url) 
{
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = url;
	$('body').append(script);
}

$(function () {
    if (document.getElementById("twitter_update_list")) {
        addScript("http://twitter.com/javascripts/blogger.js");
        addScript("http://twitter.com/statuses/user_timeline/SafeWay_Driving.json?callback=twitterCallback2&count=1");
    }
    
    //heat map script
    addScript("http://counter.goingup.com/track/heatmap/clickheat.js?st=bdrjfgw");

    var img = new Image();
    img.src = "http://counter.goingup.com/default.php?st=bdrjfgw&amp;b=5";
    
    $(document.body).append('<div class="st_sharethis_custom" style="display: none; position:fixed; right:0px; float:right; margin:0px; z-index:99999; top:200px; cursor: pointer;"><img src="images/btn_share.png" /></div>');
    addScript("http://w.sharethis.com/button/buttons.js");
    
    var load_stLight = function() {
    	if(typeof stLight === 'undefined') {
    		setTimeout(load_stLight, 500);
		}
		else {
			$(".st_sharethis_custom").show();
			stLight.options({
				publisher:'05938b4a-bc77-4cf2-83b7-fd03b2451ebc',
				onhover: false,
				embeds: true
			});			
		}
	};
	
	load_stLight();
});

/*
function hide(layerName) {
	document.getElementById(layerName).style.display="none";
}

function show(layerName) {
	document.getElementById(layerName).style.display="block";
}
*/
/*$(document).ready(function(){

	$("li").click(function () {
		$(".selected").removeClass("selected");
      	$(this).addClass("selected");
	});

  });
*/

