function focusSearch(){
	if(document.getElementById("searchkeywords").value == "New Search"){
		document.getElementById("searchkeywords").value = "";
		document.getElementById("searchkeywords").style.color = "#000000";
	}
}

function resetSearch(){
	var value = document.getElementById("searchkeywords").value;
	if(value.length < 1){
		document.getElementById("searchkeywords").style.color = "#c0c0c0";
		document.getElementById("searchkeywords").value = "New Search";
	}
}


function validateFriend(){
	var checked = false;
	for (i=form1.rel.length-1; i > -1; i--) {
		if (form1.rel[i].checked) {
			checked = true;
		}
	}
	if(!checked){
		alert("You must indicate the nature of your relationship! Please try again.");
		return false;
	}else{
		document.getElementById("submitBtn").disabled = true;
		return true;
	}
}

function focusCategory(){
	document.getElementById("page_category_reference_category_id").style.color = "#000000";
}

function resetCategory(){
	if(document.getElementById("page_category_reference_category_id").value == ""){
		document.getElementById("page_category_reference_category_id").style.color = "#c0c0c0";
	}
}

function submitCategory(){
	var category = "Category: " + document.getElementById("category").value;
	document.getElementById("suggest_category").innerHTML = "<BR/><center>Thank You!<BR/><BR/>Have a Good Day!</center><BR/><BR/>";
	loadURL("category/email?sub=IG Category Suggestion&body=" + category);
	setTimeout("hideDlg('suggest_category')", 1500);
}


function submitComments(){
	var comments = "Comments: " + document.getElementById("comments_text").value;
	document.getElementById("comments").innerHTML = "<BR/><BR/><BR/><BR/><BR/><center>Thank You!<BR/><BR/>Have a Good Day!</center><BR/><BR/>";
	loadURL("category/email?sub=IG Comments&body=" + comments);
	setTimeout("hideDlg('comments')", 1500);
}

function hideDlg(which){
	document.getElementById(which).style.display = "none";
}

function suggestCategory(){
	document.getElementById("suggest_category").innerHTML = "<BR/><p align='center'><font class='SUBTITLE'>Suggest a New Category</font><BR/><BR/><input type='text' size='20' id='category' /><BR/><BR/><input type='button' value='Cancel' onclick='hideDlg(\"suggest_category\")'/>&nbsp;&nbsp;<input type='button' value='Suggest It!' onclick='submitCategory()' /><BR/><BR/></p>";
	document.getElementById("suggest_category").style.display = "block";
	document.getElementById("suggest_category").focus();
}

function sendComments(){
	document.getElementById("comments").innerHTML = "<BR/><p align='center'><font class='SUBTITLE'>Send Us Your Comments</font><BR/><BR/><p align='center'>At " + APP_NAME + ", we are fanatical about making you happy.  Your opinion is extremely important to us.  Please send us your feedback so we can continuously improve the site for you.  <BR/><BR/>Cheers!<BR/><BR/><textarea cols='50' rows='5' id='comments_text'></textarea><BR/><BR/><input type='button' value='Cancel' onclick='hideDlg(\"comments\")'/>&nbsp;&nbsp;<input type='button' value='Send' onclick='submitComments()' /></p>";
	document.getElementById("comments").style.display = "block";
	document.getElementById("comments_text").focus();
}


function loadURL(url){
	xmlhttp=null
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
  		xmlhttp=new XMLHttpRequest()
  	}
	// code for IE
	else if (window.ActiveXObject){
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
	if (xmlhttp!=null){
  		xmlhttp.open("GET",url,true)
  		xmlhttp.send(null)
  	}
}

function focusLogin(){

	if(document.getElementById("user_username")){
		document.getElementById("user_username").focus();
	}

}

function uploadProfilePicDlg(){
	document.getElementById("profilePicUpload").innerHTML = "<BR/><p><font class=\"SUBTITLE\">Profile Picture Upload</font><BR/><font class=\"SUBTEXT\">Select a picture file to upload</font><BR/><BR/><form action=\"/user/savePic\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"file\" name=\"page_picture[image_file]\" id=\"profilePic\" size=\"30\"/></p><p><input type=\"button\" value=\"Cancel\" onclick=\"hideDlg('profilePicUpload')\"/>&nbsp;&nbsp;<input type=\"submit\" value=\"Upload\" /></form><BR/><BR/>";
	document.getElementById("profilePicUpload").style.display = "block";
}
