// 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();
}

//Function to open pop up window
function openWin(theURL,winName,features) {
	window.open(theURL,winName,features);
}

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

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

// Regenerates Captcha Image
function newCaptcha() {
	jQuery(function() {
		jQuery.ajax({
			url: "secure.php?" + (new Date()).getTime(),
			type: "GET",
			dataType: "xml",
			//timeout: 1000,
			error: function(){
				alert("Error loading XML document");
			},
			success: function(xml){
				jQuery(xml).find("response").each(function(){
					var code = jQuery(this).text();
					//Set Valus
					jQuery("#secure_image").attr("src", "anti_spam.php?key=" + code);	
					jQuery("#signup_csecure").val(code);			
				});
			}	 
		}); //close jQuery.ajax(
	}); //close jQuery(
}

/* Code to get the latest tweets */
/*
getTwitters('myTweets', {
	id: 'websoftdev',	// replace with your twitter user id
	prefix: '<a href="http://twitter.com/%screen_name%">%name%</a> said: ', 
	clearContents: false, // leave the original message in place
	count: 1, 
	withFriends: true,
	ignoreReplies: false,
	enableLinks: true,
	newwindow: true
});
*/

// Toggles Default Search String
function ToggleSearchText(search_object, text) {
	switch(text) {
		case 'Find People ...':
		  search_object.value = '';
		  break;
	}

	switch(text.length) {
		case 0:
		  search_object.value = 'Find People ...';
		  break;
	}
}

// Limits Characters Input
function check_character_limit(id) {
	var maxlength = 255;
	
	if(document.getElementById(id).value.length > maxlength) 
		document.getElementById(id).value = document.getElementById(id).value.substring(0, maxlength); 
}

// ====================
// 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;
				}
			}
		}
	}
}
