/* 
Title: Verizon Wireless Retail Leadership Development Program
Author: Michael "Spell" Spellacy, Senior UI Developer
Email: michael.spellacy@tmp.com
Company: TMP Worldwide Advertising and Communications, LLC
*/

// Check Browser CSS Compatibility

// alert(document.compatMode);

// Check Browser Mode

// alert(document.documentMode);

// 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);
		
	}
	
}

// Back to top

function scrollToTop() {
		
	scroll(0, 0);
	
}
	
// Toggle, Show/Hide Element(s)

function toggleElement(val, obj){

if(document.getElementById(val).style.display == "none") { 

	obj.className = "expandon";
	document.getElementById(val).style.display = "block";

} else {

	obj.className = "expand";
	document.getElementById(val).style.display = "none";
	}
}

function randomBackground() {

	if (!document.getElementById) return false;
	
	var container = document.getElementById("article");
	
	if (document.getElementById("index")) {
		
		// var bgsArray = ["tile-a", "tile-b", "tile-c", "tile-d", "tile-e"];

		var bgsArray = ["tile-a", "tile-b", "tile-c", "tile-d"];
	
		container.className = bgsArray[Math.floor(Math.random()*bgsArray.length)];
	
	} else {
	
		container.className = "tile-default";
	
	}

}

addLoadEvent(randomBackground);
	
// Set Year in Footer :-)

function SetCurrentYear() {

	if (!document.getElementById) return false;
	if (!document.getElementById("currentyear")) return false;

	var clientDate = new Date()
	var currentYear = clientDate.getFullYear();
	document.getElementById("currentyear").innerHTML = currentYear;
}

addLoadEvent(SetCurrentYear);

function newWinLinks() {

	for (var i=0; i < document.links.length; i++) {

		if (document.links[i].className == "newwindow") {
		document.links[i].onclick = displayNewWindow;
		}

	}
}

addLoadEvent(newWinLinks);

function displayNewWindow() {

	var featureWindow = window.open(this.href,"win", 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=yes,resizable=1,top=100,left=100,width=800,height=600');
	featureWindow.focus();
	return false;
}

// Just appends "addthis" to desired element (global)

function appendAddThis() {
	
	if (!document.getElementById) return false;
	if (!document.getElementById("addthis")) return false;
	
	var list_addthis = document.getElementById("addthis").getElementsByTagName("a")[0];

	list_addthis.onmouseover = function() {
		return addthis_open(this, '', '[URL]', '[TITLE]');
	}

	list_addthis.onmouseout = function() {
		addthis_close();
	}

	list_addthis.onclick = function() {
		return addthis_sendto();
		return false;
	}
	
}

//addLoadEvent(appendAddThis);

// Addthis variables

var addthis_brand = "vzwrldp.com";	

// var addthis_pub = "";
// var addthis_options = "delicious, digg, email, favorites, facebook, fark, furl, google, live, myweb, newsvine, reddit, stumbleupon, technorati, twitter, more";
//var addthis_offset_top = -6;
//var addthis_offset_left = -208;

// Twitter Updates

function twitterUpdates() { 

	new TWTR.Widget({

		profile: true,
		id: 'twitter',
		loop: true,
		width: 213,
		height: 230,

		theme: {

			shell: {

				background: '#3082af',
				color: '#ffffff'

				},

			tweets: {

				background: '#ffffff',
				color: '#444444',
				links: '#1985b5'

			}

		}

	}).render().setProfile('CareersatVZW').start();

}

addLoadEvent(twitterUpdates);

// Add title attribute to all select boxes for usability (global)

function addOptionTitle() { 

if (!document.getElementsByTagName("select")) return false;

var list = document.getElementsByTagName("select");

for(var i = 0; i < list.length; i++) {

	var option = list[i].getElementsByTagName("option")

		for(var j = 0; j < option.length; j++) {
			option[j].setAttribute("title", option[j].text);
		}
	}
}

addLoadEvent(addOptionTitle);
