/* 
	Parkland Careers - Global Functions
	Michael Spellacy, Senior UI Developer <michael.spellacy@tmp.com>, TMP Worldwide, LLC
*/

$("html").attr("class", "js"); // Make template JS active

/* ====== Supress BOM Script Errors ====== */

function errorsuppressor(){

	return true;

}

if(location.href.indexOf("localhost") == -1){

	window.onerror = errorsuppressor;

}

/* ====== Multiple Onload Utility ====== */

function addLoadEvent(func) {

	var oldonload = window.onload;

	if (typeof window.onload != 'function') {

		window.onload = func;

	} else {

		window.onload = function() {
		oldonload();
		func();

		}

	}

}

/* ====== Insert-after Function ====== */

function insertAfter(newElement, targetElement) {

	var parent = targetElement.parentNode;

	if (parent.lastChild == targetElement) {

		parent.appendChild(newElement);

	} else {

		parent.insertBefore(newElement, targetElement.nextSibling);

	}

}

// Hide input/textarea placeholder text on focus, return on blur

function populateElement(selector, defvalue) {

	$(selector).each(function() {

		if($.trim(this.value) == "") {

			this.value = defvalue;

		}

	});

	$(selector).focus(function() {

		if(this.value == defvalue) {

			this.value = "";

		}

	});

	$(selector).blur(function() {

		if($.trim(this.value) == "") {

			this.value = defvalue;

		}

	});

}

/* ====== Search Bar ====== */

var searchLabel = $(".search-label").text();
var searchQuestion = $(".search-text");

searchQuestion.val(searchLabel);
populateElement(searchQuestion, searchLabel);

/* ====== New Window ====== */

$("a.external").click(function(){

	this.target = "_blank";

});

/* ====== jQuery Functionality ====== */

$(function() { // Begin Document Ready

	/* ====== Facebook Open Graph ====== */

	// Write needed elements to page

	//$("#aspnetForm").prepend("<div id=\"fb-root\"></div>");

	//$("#footer").append("<fb:like id=\"like-button-content\" ref=\"content\"></fb:like>");

	// Initiate, Append and Import FB JavaScript SDK

	/* window.fbAsyncInit = function() {

			FB.init({appId: "150531684982543", status: true, cookie: true, xfbml: true});

	};

	(function() {

		var lang = "en_US";
		var e = document.createElement("script"); 
		e.async = true;
		e.src = document.location.protocol + "//connect.facebook.net/" + lang + "/all.js"; 
		document.getElementById("fb-root").appendChild(e);

	}()); */

}); // End Document Ready

function fnSearch()
{
     var q = document.getElementById('ctl00_txtSearchWebsite').value;
     window.location = "/search.aspx?cx=000790870211751247117:3sbmncs6xjq&client=google-csbe&output=xml_no_dtd&q=" + q + "&proxyreload=1&start=0";
}
