// JavaScript Document
// common.js

///// Default Colors /////
var vHex = "#0f034e";
var vLiteHex = "#b3b1cc";
var yHex = "#fff000";
var yLiteHex = "#fffbd5";



///// INPUT FIELD CONTROLS /////
function focusInput(inputBox, color) {
	var defaultV = document.getElementById(inputBox.name + "Default").value;
	if (color == "v") {
		hColor = yHex;
	}
	else {
		hColor = vHex;
	}
	inputBox.style.borderColor = hColor;
	if (inputBox.value == defaultV) {
		inputBox.value = "";
		inputBox.style.color = "#000000";
	}
	if (defaultV == "password") {
		inputBox.setAttribute("type", "password");
	}
}

function blurInput(inputBox, color) {
	var defaultV = document.getElementById(inputBox.name + "Default").value;
	var inputForm = inputBox.parentNode;
	if (color == "v") {
		nColor = vLiteHex;
	}
	else {
		nColor = yLiteHex;
	}
	inputBox.style.borderColor = nColor;
	if (inputBox.value == "") {
		inputBox.value = defaultV;
		inputBox.style.color = "#999999";
		if (defaultV == "password") {
			inputBox.setAttribute("type", "text");
		}
	}
}

function checkAllTextInputs() {
	var allInput = document.getElementsByTagName("input");
	for (i = 0;i < allInput.length; i++) {
		if (allInput[i].type == "text") {
			var defaultV = document.getElementById(allInput[i].name + "Default").value;
			if (allInput[i].value != defaultV) {
				allInput[i].style.color = "#000000";
			}
		}
	}
	var allTextarea = document.getElementsByTagName("textarea");
	for (i = 0;i < allInput.length; i++) {
		var defaultV = document.getElementById(allTextarea[i].name + "Default").value;
		if (allTextarea[i].value != defaultV) {
			allTextarea[i].style.color = "#000000";
		}
	}
}



///// POP UP FUNCTION /////
function popUp() {
	var popUpBG = document.getElementById("popUpBG");
	var popUpWin = document.getElementById("popUpWin");
	
	var popUpW = document.documentElement.scrollWidth;
	var popUpH = document.documentElement.scrollHeight;
	
	var portalW = document.documentElement.clientWidth;
	var portalH = document.documentElement.clientHeight;
	
	popUpBG.style.width = popUpW + "px";
	popUpBG.style.height = popUpH + "px";
	popUpBG.style.visibility = "visible";
	
	var popUpWinW = 400;
	var popUpWinH = 300;
	popUpWin.style.width = popUpWinW + "px";
	popUpWin.style.height = popUpWinH + "px";
	popUpWin.style.left = Math.floor((portalW / 2) - (popUpWinW / 2)) + "px";
	popUpWin.style.top = Math.floor((portalH / 2) - (popUpWinH / 2)) + "px";
	popUpWin.style.visibility = "visible";
}

function closeThis(popUpWin) {
	popUpBG = document.getElementById("popUpBG");
	popUpWin.style.visibility = "hidden";
	popUpBG.style.visibility = "hidden";
}



///// CREATE BOOKMARK /////
function createBookmark() {
	var title = "A Wise Creation - Creative Web Design"; 
	var url = "http://www.awisecreation.com";
	
	// Mozilla Firefox Bookmark
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	}
	// IE Favorite
	else if ( window.external ) {
		window.external.AddFavorite(url, title);
	}
}
