$(function() {
	/*$(".galleries #changeGallery").bind("change", function() {
		var hElem = $(this);
		var sType = hElem.attr("type");
		document.location.href = "gallery.php?t=" + sType + "&cid=" + this[this.selectedIndex].value;
	});*/
	
	$('#print').bind('click', function() {
		window.print();
	});
	
	$('#email').bind('click', function() {
		$('#pr_email form').resetForm();
		$('#pr_email form').show();
		$('#pr_email #form_wrapper div').hide();
		$('#pr_email').show();
		
	});
	
	$('#pr_email #win_header a').bind('click', function() {
		$('#pr_email').hide();
		
	});
});

function highlightTab() {
	var sLocation = document.location.href;
	var sId = sLocation.substring(sLocation.indexOf("txtID=") + 6, sLocation.length);
	if(sLocation.indexOf("txtID=") == -1) {
		sId = "0";
	}
	$("#nav a#i" + sId).addClass("active");
}

function fFocus(tthis) {
	tthis.className = "cssFocus";
}

function fBlur(tthis) {
	tthis.className = "";
}

function fMouseOut(tthis) {
	if(tthis.className != "cssFocus") {
		tthis.className = "";
	}
}

function fMouseOver(tthis) {
	if(tthis.className != "cssFocus") {
		tthis.className = "cssOver";
	}
}

function fVerifyEmail(strEmail) {
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if (re.test(strEmail)) {
		return true;
	} else {
		return false;
	}
}

function fVerifyInput(strID, strText) {
	var oInput = document.getElementById(strID);
	if(oInput.value == "") {
		oInput.style.background = "#ffcccc";
		return strText;
	} else {
		oInput.style.background = "";
		return "";
	}
}

function fVerifyInputLength(strID, intLength, strText) {
	var oInput = document.getElementById(strID);
	if(oInput.value.length < intLength) {
		oInput.style.background = "#ffcccc";
		return strText;
	} else {
		oInput.style.background = "";
		return "";
	}
}

function fVerifyRadio(strID, strText) {
	var oRadio = document.getElementsByName(strID);
	for(i=0; i<oRadio.length; i++) {
		if(oRadio[i].checked) {
			return "";
		}
	}
	return "Please answer " + strText + ".\n";
}

function fVerifySelect(strID, strText) {
	var oElement = document.getElementById(strID);
	if(oElement.selectedIndex == 0) {
		oElement.style.background = "#ffcccc";
		oElement.focus();
		return strText;
	} else {
		oElement.style.background = "#ffffff";
	}
	return "";
}

function fShow(strDiv) {
	document.getElementById(strDiv).style.visibility = "visible";
	document.getElementById(strDiv).style.display = "block";
}

function fHide(strDiv) {
	document.getElementById(strDiv).style.visibility = "hidden";
	document.getElementById(strDiv).style.display = "none";
}


function fToggle(strID) {
	if(document.getElementById(strID).style.visibility == "hidden") {
		fShow(strID);
	} else {
		fHide(strID);
	}
}

function fToggleDiv(strDiv) {
	var objDiv = document.getElementById(strDiv);
	if(objDiv.style.visibility == "hidden") {
		objDiv.style.visibility = "visible";
		objDiv.style.display = "block";
		if(document.getElementById(strDiv + "plus")) {
			document.getElementById(strDiv + "plus").src = strRootPath + "img/img_minus.gif";
		}
		if(document.getElementById(strDiv + "Header")) {
			document.getElementById(strDiv + "Header").className = "cssLeftNavRed";
		}
	} else {
		objDiv.style.visibility = "hidden";
		objDiv.style.display = "none";
		if(document.getElementById(strDiv + "plus")) {
			document.getElementById(strDiv + "plus").src = strRootPath + "img/img_plus.gif";
		}
		if(document.getElementById(strDiv + "Header")) {
			document.getElementById(strDiv + "Header").className = "cssLeftNav";
		}
	}
}

function fAJAXRequest(strTarget, strURL) {
//alert(strTarget);
	if(window.XMLHttpRequest) {
		oRequest = new XMLHttpRequest();
		oTarget = strTarget;
		oRequest.onreadystatechange = fAJAXChangeWhenReady;
		oRequest.open("GET", strURL, true);
		oRequest.send(null);
	} else if(window.ActiveXObject) {
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		if(oRequest) {
			oTarget = strTarget;
			oRequest.onreadystatechange = fAJAXChangeWhenReady;
			oRequest.open("GET", strURL, true);
			oRequest.send();
		}
	}
}

function fAJAXChangeWhenReady() {
    if(oRequest.readyState == 4) {
    	if(document.getElementById(oTarget)) {
    		//alert(oRequest.responseText);
    		document.getElementById(oTarget).innerHTML = oRequest.responseText;
    	}
    }
}


