﻿$(document).ready(function() {
    $("#pageTop li.search input").focus(function() {
        if ($(this).val() == ' -- Search Site --')
            $(this).val('');
    });
    $("#pageTop li.search input").blur(function() {
        if ($(this).val() == '')
            $(this).val(' -- Search Site --');
    });

    // Up Down key events for autosuggest box
    $("#pageTop .topnav .search input").keydown(
        function(e) {
            if (e.keyCode == 13 || e.charCode == 13 || e.which == 13) {
                e.preventDefault();
                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$pageTop$ctl00$btnLeita", "", true, "", "", false, true));
            }
        });
});


//Post link to facebook
function fbs_click() {
    u = location.href;
    t = document.title;
    window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
    return false;
   }

 function fbs_click2(href, title) {
   	u = href;
   	t = title;
   	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
   	return false;
 }

function validateEmail(elementValue){   
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;   
    return emailPattern.test(elementValue);
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
   }

function CreateBookmarkLink() {

	title = document.title;
	url = window.location.href;

	if (window.sidebar) { // Mozilla Firefox Bookmark 
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) { // IE Favorite 
		window.external.AddFavorite(url, title);
	}
	else if (window.opera && window.print) { // Opera Hotlist 
		return true;
	}
} 
