// Generic Jump Menu
function JumpMenu(targ,selObj){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}

// IE7 Friendly Pop Up
function popItUp(url,name,w,h) {
//function popItUp(url,name,h,w) {	
	var newwindow=window.open(url, 'name','height='+h+',width='+w+',toolbars=no,scrollbars=yes');
	//var newwindow=window.open(url, name,'height='+h+',width='+w+',toolbars=no,scrollbars=yes');
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

// Facebook Sharer
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;
}

// Opens Window PopUp
function winPopUp(winURL,name,winWidth,winHeight)
{
	var w = window.open(winURL, 'name', "width="+winWidth+", height="+winHeight+", toolbars=no, scrollbars=yes");
	w.focus();
}

// Trims White Spaces in the passed values
function trimText(obj) {
	var str = "";
	for (var i=0; i < obj.length; i++) {
		var letter = obj.charAt(i).toLowerCase();
		if (letter == " ")
			continue;
		str = str + letter;
	}
	return str;
}

// Regenerates Captcha Image
function newCaptcha() {
	var url = 'generate_veriword.php?sid='+Math.random();
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
		var code = transport.responseText;
		document.getElementById("captcha_img").src = "anti_spam.php?key=" + code;
		document.getElementById("cveriword").value = code;
	  },
	  onFailure:function(){ alert('Something went wrong...') }
	});
}

// Validates Passed Email Address
function isValidEmail(email){ 
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false) {
		return false;
	} else {
		return true; 
	}
} 

// ====================
// Function:    GetObjectHeight
//
// Purpose:     Returns the height of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the height of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectHeight(objectRef)
{
	var intHeight = -1;

	if (document.getElementById)
	{
		if (document.getElementById(objectRef))
		{
			intHeight = eval(document.getElementById(objectRef).offsetHeight);
		}
	}
	else if (document.all)
	{
		if (document.all[objectRef])
		{
			intHeight = document.all[objectRef].scrollHeight;
		}
	}
	else if (document.layers)
	{
		if (document[objectRef])
		{
			intHeight = document[objectRef].clip.bottom;
		}
	}

	return intHeight;
}

// ====================
// Function:    SetUniformHeight
//
// Purpose:     Sets a number of page objects to a uniform height, being the
//              maximum height of any of the given objects.
//
// Input:       strPageObjects - Comma separated list of object IDs that should
//              be set to a uniform height.
//
// Output:      Updates the height of the given objects.
//
// Assumptions: GetObjectHeight()
//
// History:     20060823 RW Created
// ====================
function SetUniformHeight(strPageObjects) {
	intMaxHeight = 0;

	if (strPageObjects) {
		arrPageObjects = strPageObjects.split(",");
	}

	if (arrPageObjects) {
		// Find the height of the tallest object.
		for (i = 0; i < arrPageObjects.length; i++) {
			intThisHeight = GetObjectHeight(arrPageObjects[i]);
			if (intThisHeight > intMaxHeight) {
				intMaxHeight = intThisHeight;
			}
		}

		// Set all the objects to the same (maximum) height if a height larger
		// than 0 was found.
		if (intMaxHeight > 0 ) {
			for (i = 0; i < arrPageObjects.length; i++) {
				//if (blnIE)  {
				//	strMaxHeight = intMaxHeight;
				//} else {
					strMaxHeight = intMaxHeight + 'px';
				//}
				if(document.getElementById(arrPageObjects[i])) {
					document.getElementById(arrPageObjects[i]).style.height = strMaxHeight;
				}
			}
		}
	}
}
