//	String Prototype Function to trim white spaces
String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};


//	Select Object based on element Id
function getObject(id)
{
	return document.getElementById(id);
}


//	Validate Link Submission Form
function linkFormValidation()
{
	//	Video Site Dropdown
	var	videoSite		=	getObject("videoSite");
	//	See if some is selected
	if(videoSite.selectedIndex == 0)
	{
		//	If not, let the user know and exit
		videoSite.focus();
		alert("Please Select Content for Site");
		return false;
	}
	videoSite			=	null;
	
	//	If a user name is less than 2 characters long, it's considered a problem
	var	userName		=	getObject("userName");
	//	Check if the name entered is less than 2 characters long
	if(userName.value.trim().length < 2)
	{
		// If so, alert the user and exit
		userName.focus();
		alert("Your name should atleast 2 characters long");
		return false;
	}
	userName			=	null;
	
	//	User Email
	var userEmail		=	getObject("userEmail");
	//	RexEx for Email Format Check
	var	emailRegEx 		= 	/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	//	If user specified email doesn't match 
	if(!emailRegEx.test(userEmail.value))
	{
		//	If not, alert the user and exit
		userEmail.focus();
		alert("Invalid Email Address!")
		return false;
	}
	userEmail			=	null;

	//	Site URL
	var siteURL			=	getObject("siteURL");
	//	RegEx for URL match
	var urlRegEx		=	/^(http:\/\/www|https:\/\/www|ftp:\/\/www|http:\/\/|https:\/\/|ftp:\/\/|www){1}.[A-Za-z0-9-_]+\.[A-Za-z0-9-_%,&\?\/.=]+$/;
	if(!urlRegEx.test(siteURL.value))
	{
		//	If not correct, alert the user and exit
		siteURL.focus();
		alert("Invalid Site URL!")
		return false;
	}
	urlRegEx			=	null;
	
	//	Site Description
	var siteDesc		=	getObject("siteDesc");
	if(siteDesc.value.trim().length < 15)
	{
		//	If not, alert the user and exit
		siteDesc.focus();
		alert("Description should be at least 15 characters long!");
		return false;
	}
	siteDesc			=	null;
	
	//	Everything is good
	return true;
}

//	Validate Link Submission Form
function adminLinkFormValidation()
{
	//	Star Name
	var	starName		=	getObject("linkStarName");
	if(starName.value.trim().length < 2)
	{
		alert("Please enter minimum 2 charactes for star name");
		return false;
	}
	starName			=	null;
	
	//	If a user name is less than 2 characters long, it's considered a problem
	var	userName		=	getObject("userName");
	if(userName.value.trim().length < 2)
	{
		userName.focus();
		alert("Your name should atleast 2 characters long");
		return false;
	}
	userName			=	null;
	
	//	User Email
	var userEmail		=	getObject("userEmail");
	var	emailRegEx 		= 	/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	if(!emailRegEx.test(userEmail.value))
	{
		userEmail.focus();
		alert("Invalid Email Address!")
		return false;
	}
	userEmail			=	null;

	//	Site URL
	var siteURL			=	getObject("siteURL");
	var urlRegEx		=	/^(http:\/\/www|https:\/\/www|ftp:\/\/www|http:\/\/|https:\/\/|ftp:\/\/|www){1}.[A-Za-z0-9-_]+\.[A-Za-z0-9-_%,&\?\/.=]+$/;
	if(!urlRegEx.test(siteURL.value))
	{
		siteURL.focus();
		alert("Invalid Site URL!")
		return false;
	}
	urlRegEx			=	null;
	
	//	Site Description
	var siteDesc		=	getObject("siteDesc");
	if(siteDesc.value.trim().length < 15)
	{
		siteDesc.focus();
		alert("Description should be at least 15 characters long!");
		return false;
	}
	siteDesc			=	null;
	
	//	Everything is okay
	return true;
}

//	Checks Star Name field value
function checkAdvanceSearchForm()
{
	var starName		=	getObject("starName");
	if(starName.value.trim().length == 1)
	{
		hideSpinner();
		starName.focus();
		alert("Please enter at least 2 character to search a star name")
		return 			false;
	}
	createAdvanceSearchCookie(); 
	createActionCookie('advance');
	return true;
}

//	Resets Advance Search Page Data
function resetAdvanceSearchForm()
{
	getObject("starName").value 				= 	"";
	getObject("ageMinimum").value 				= 	18;
	getObject("ageMaximum").value				=	60;
	getObject("ethnicityType").value			=	0;
	getObject("eyecolorType").value				=	0;
	getObject("haircolorType").value			=	0;
	getObject("heightMinimum").value			=	"";
	getObject("heightMaximum").value			=	"";
	getObject("weightMinimum").value			=	"";
	getObject("weightMaximum").value			=	"";
	getObject("breastMinimum").value			=	"";
	getObject("breastMaximum").value			=	"";
	getObject("cupSize").value					=	0;
	getObject("waistMinimum").value				=	"";
	getObject("waistMaximum").value				=	"";
	getObject("hipMinimum").value				=	"";
	getObject("hipMaximum").value				=	"";
	getObject("measurementUnit").value			=	"inch";
	getObject("picType").checked				=	false;
	
	deleteCookie('gb_advancesearchdata');
	
	getObject("starName").focus();
	
	return false;
	
}


//	Quick/Common Search Data Validation
function commonSearchValidation(e)
{
	if(getObject("commonSearchText").value.trim().length >= 2)
	{
		showSpinner(e); 
		createQuickSearchCookie(); 
		createActionCookie('quick');
		return true;
	} else {
		alert("Please enter at least 2 characters to search Pornstars");
		return false;
	}
}

//	Changes Gender type to selected gender
function changeGenderType(tp)
{
	getObject("selectedDefaultGender").value = tp;
}


//	Cookie Functions
//	Sets a Cookie
function setCookie(name, value, days)
{
	//	Create Name Value pair. NO SPACE provided before or after = sign and while retrieveing cookie, same should be considered
	var namevalue				=	name + "=" + value + "; ";
	//	Create Path for Cookie
	var path					=	"path=/";
	
	//	Create expiration time
	var expires					=	"";
	
	//	If #days given, calculate it
	if (days)
	{
		//	Calculate a day value
		var dayvalue			=	24 * 60 * 60 * 1000;
		//	Define a Date object
		var date 				= 	new Date();
		//	Set date object time to new time
		date.setTime(date.getTime() + (days * dayvalue));
		//	Create Expiration string
		expires 				= 	"expires=" + date.toGMTString() + "; ";
	}
	//	Finally, create the cookie
	document.cookie 			= 	namevalue + expires + path;
}


//	Reads a Cookie
function getCookie(name) 
{
	//	Add = sign to the given name for searching purpose
	name 						+=	"=";
	
	//	Explode the cookies
	var cookieelements			=	document.cookie.split(';');
	//	Count cookie#
	var	cookiecounter			=	cookieelements.length;
	
	//	Loop through each cookie element
	for(var i=0; i < cookiecounter; i++) 
	{
		//	Must Remove any leading/trailing spaces
		var ck 					= 	cookieelements[i].trim();
		
		//	Check IF this is the cookie we need
		if (cl.indexOf(name) == 0) 
		{
			//	Return Cookie value
			return ck.substring(name.length);
		}
	}
	//	Did not find the specified Cookie. Return null
	return null;
}


//	Deletes a cookie
function deleteCookie(name) 
{
	//	Set the cookie with -1 day (in PAST) to delete it
	setCookie(name, "", -1);
}

//	Creates Age Validation Cookie
function createAgeValidCookie()
{
	setCookie('iam18yearsold', "yes");	
}

//	Create Gender Cookie
function createGenderCookie()
{
	setCookie('gb_selectedgender', getObject("selectedGender").value);
}

//	Create Category Cookie
function createCategoryCookie()
{
	setCookie('gb_selectedcategory', getObject("selectedCategory").value);
}

//	Create Common/Quick Search Cookie
function createQuickSearchCookie()
{
	setCookie('gb_commonsearchtext', getObject("commonSearchText").value);
}

//	Create Alpha Link Cookie
function createAlphaCookie(alpha)
{
	setCookie('gb_alpha', alpha);
}

//	Create Alpha Link Page Cookie
function createAlphaPageCookie(e)
{
	e				=	e || window.event;
	var tg			=	window.location.href || e.target.href;
	var page		=	parseInt(tg.substring(tg.indexOf("/p/")+3), 10);
	if(page < 1)
	{
		page		=	1;
	}
	setCookie('gb_alpha_page', page);
}

//	Creates Image Cookie
function createImageCookie(img)
{
	setCookie('gb_imgname', img);
	createActionCookie('img');
}

//	Creates Image Cookie
function createImageXtCookie(xt)
{
	setCookie('gb_xt', xt)
	createActionCookie('img');
}

//	Creates Star Id Cookie
function createStarIdCookie(starid)
{
	setCookie('gb_starid', starid);
}

//	Creates Star Name Id Cookie
function createStarNameIdCookie(starnameid)
{
	starnameid.replace(" ", "_");
	setCookie('gb_starnameid', starnameid);
}

//	Creates Video Id Cookie
function createStarVideoIdCookie(videoId)
{
	setCookie('gb_videoid', videoId);
}

//	Creates Action Cookie
function createActionCookie(action)
{
	setCookie('gb_action', action);
}

//	Create Category Search Cookie
function createCategorySearchCookie()
{
	createNextActionCookie('category');
}

//	Create Advance Search Cookie
function createAdvanceSearchCookie()
{
	var tmp;
	tmp							=	"starName/" + getObject("starName").value + "/";
	tmp							+=	"ageMinimum/" + getObject("ageMinimum").value + "/";
	tmp							+=	"ageMaximum/" + getObject("ageMaximum").value + "/";
	tmp							+=	"ethnicityType/" + getObject("ethnicityType").value + "/";
	tmp							+=	"eyecolorType/" + getObject("eyecolorType").value + "/";
	tmp							+=	"haircolorType/" + getObject("haircolorType").value + "/";
	tmp							+=	"heightMinimum/" + getObject("heightMinimum").value + "/";
	tmp							+=	"heightMaximum/" + getObject("heightMaximum").value + "/";
	tmp							+=	"weightMinimum/" + getObject("weightMinimum").value + "/";
	tmp							+=	"weightMaximum/" + getObject("weightMaximum").value + "/";
	tmp							+=	"breastMinimum/" + getObject("breastMinimum").value + "/";
	tmp							+=	"breastMaximum/" + getObject("breastMaximum").value + "/";
	tmp							+=	"cupSize/" + getObject("cupSize").value + "/";
	tmp							+=	"waistMinimum/" + getObject("waistMinimum").value + "/";
	tmp							+=	"waistMaximum/" + getObject("waistMaximum").value + "/";
	tmp							+=	"hipMinimum/" + getObject("hipMinimum").value + "/";
	tmp							+=	"hipMaximum/" + getObject("hipMaximum").value + "/";
	tmp							+=	"measurementUnit/" + getObject("measurementUnit").value + "/";
	tmp							+=	"picType/" + ((getObject("picType").checked) ? "on" : "");
	setCookie('gb_advancesearchdata', tmp);
	
	createNextActionCookie('advance');
}

function createVoteDataCookie(e, id, tp)
{
	showSpinner(e);
	setCookie('gb_voteforstar', '10001');
	setCookie('gb_starid', id);
	//	Star Action
	if(tp == 1)
	{
		createActionCookie('star');
	} else if(tp == 2) {
		createActionCookie('quick');
	} else if(tp == 3) {
		createActionCookie('category');
	} else if(tp == 4) {
		createActionCookie('advance');
	} else if(tp == 5) {
		createActionCookie('img');
	} else if(tp == 6) {
		createActionCookie('video');
	} else if(tp == 7) {
		createActionCookie('default');
	} else if(tp == 8) {
		createActionCookie('starstat');
	}
}


//	Create Action Cookie
function createNextActionCookie(action)
{
	setCookie('gb_action', action);
}


function createStarStatCookies(tp, val)
{
	setCookie('gb_starstattype', tp);;
	setCookie('gb_starstatvalue', val);
}
//	End Cookie functions


//	Displays the Spinner
function showSpinner(e)
{
	e							=	e || window.event;

	var top;
	
	if(!e.clientY)
	{
		top						=	window.pageYOffset;
	} else {
		top						=	document.documentElement.scrollTop + document.body.scrollTop;
	}
	
	top							=	top + (screen.availHeight / 2) - 16;
	
	var left					=	(screen.width / 2) - 32;
	
	var spinner					=	getObject("spinner");
	
	spinner.style.top			=	top + "px";
	spinner.style.left			=	left + "px";
	
	spinner.style.visibility	=	"visible";
}


//	Hides the spinner
function hideSpinner()
{
	getObject("spinner").style.visibility	=	"hidden";
}


//	Counts characters entered
function countCharacters()
{
	var siteDesc				=	getObject("siteDesc");
	var charcount				=	getObject("charcount");
	var ll						=	150 - siteDesc.value.length;
	var color					=	(ll > 134) ? "#ff0000" : "#0000ff";
	
	charcount.innerHTML 		= 	"<small>(e.g. : Jenna Jameson gets pounded by Nick Manning) - </small>";
	charcount.innerHTML			+=	"<div style='display:inline;font-weight:bold;color:" + color + "'><small>" + ll + "</small></div>";
	charcount.innerHTML			+=	"<small> chars left!</small>";
}


//	Adds Parameters into Email
function addParamsIntoEmailLink()
{
	var linebreak = "%0A";

	var submitid				=	getObject("linkSubmitId").value;
	var starname				=	getObject("linkStarName").value;
	var submittime				=	getObject("linkSubmitTime").value;
	var tmp						=	submittime.split(" ");
	var dt						=	tmp[0].split("-");
	var submissiontime			=	dt[1] + "/" + dt[2] + "/" + dt[0] + " at " + tmp[1];
	
	tmp							=	parseInt(getObject("videoSite").value, 10);
	switch (tmp)
	{
		case 1:
			var sitetype		=	"Videos";
			break;
		case 2:
			var sitetype		=	"Images";
			break;
		case 3:
			var sitetype		=	"Both Videos and Images";
			break;
	}
	var username				=	getObject("userName").value;
	var useremail				=	getObject("userEmail").value;
	var siteurl					=	getObject("siteURL").value;
	var description				=	getObject("siteDesc").value;
	var comments				=	getObject("comments").innerHTML;
	var usericq					=	getObject("userICQ").value;
	
	var psd						=	"http://www.PornstarDatabase.com/";
	var subject 				= 	"Ref: Your link submission to Pornstar Database";
	
	var hreflink				=	"mailto:" + useremail;
	hreflink					+=	"?subject=" + subject;
	hreflink					+=	"&body=This is in reference to the external link you submitted to "	+ psd + " with the following details: " + linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	"Submission Date: " + submissiontime + linebreak;
	hreflink					+=	"User Name: " + username + linebreak;
	hreflink					+=	"User ICQ: " + usericq + linebreak;
	hreflink					+=	"Pornstar Name: " + starname + linebreak;
	hreflink					+=	"Site Contents: " + sitetype + linebreak;
	hreflink					+=	"Site URL: " + siteurl + linebreak;
	hreflink					+=	"Site Desc: " + description + linebreak;
	hreflink					+=	"Comments: " + comments + linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	"Please quote #psdb-" + submitid + " in all future correspondence regarding this link submission." + linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	"Thank you." + linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	"Regards," + linebreak;
	hreflink					+=	linebreak;
	hreflink					+=	"Pornstar Database Administration Team" + linebreak;
	hreflink					+=	"Email: pornstardatabase@gmail.com" + linebreak;
	hreflink					+=	psd;

	document.getElementById("emailtolinkuser").href = hreflink;
	return true;
}


//	Changes site visit url to the actual value in the field
function changesitevisiturl()
{
	getObject("sitevisiturl").href = getObject("siteURL").value;
}



function validateStarPageData()
{
/*	var urlRegEx		=	"^(http://www|https://www|ftp://www)\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%,&\?\/.=]+$";
	var siteURL			=	getObject("siteURLHome");
	if(!urlRegEx.test(siteURL.value))
	{
		siteURL.focus();
		alert("Invalid Site URL!")
		return false;
	}
	siteURL				=	getObject("siteURLxPeeps");
	if(!urlRegEx.test(siteURL.value))
	{
		siteURL.focus();
		alert("Invalid Site URL!")
		return false;
	}
	urlRegEx			=	null;
	
	var siteName		=	getObject("siteDescHome");
	if(siteName.value.trim().length < 50)
	{
		siteDesc.focus();
		alert("Description should be at least 50 characters long!");
		return false;
	}
	siteName			=	getObject("siteDescxPeeps");
	if(siteName.value.trim().length < 50)
	{
		siteDesc.focus();
		alert("Description should be at least 50 characters long!");
		return false;
	}
	siteName			=	null;
*/	
	return true;
}


//	Checks if keypress is 13 for quick search and after form validation, submits / stops form submit
function checkIfNeedtoSubmitForm(e)
{
	e					=	e || window.event;
	var kCode			=	e.keyCode || e.which;
	if(kCode == 13)
	{
		if(getObject("commonSearchText").value.trim().length >= 2)
		{
			getObject("commonSearch").click();
		} else {
			alert("Please enter at least 2 characters to search Pornstars");
			return false;
		}
	}
}





/**
 * Auto Suggest Functions
*/

//	Shows/hides result div
function showHideSearchResultDiv(divid, tp)
{
	var obj						=	getObject(divid);
	if(tp == 1)
	{
		obj.style.visibility 	= 	"visible";
		obj.zIndex				=	1000;
	} else if(tp == 2) {
		obj.style.visibility	= 	"hidden";
		obj.zIndex				=	1;
	}
}

//	Gets data to display in result division using AJAX/Native Javascript
function showStarNames(e, inputid, divid, calltype)
{
	var obj						=	getObject(inputid);
	var objValue				=	obj.value.replace(/^\s+/, '');
	//	Minimum 2 characters required
	if(objValue.length > 1)
	{
		e							=	e || window.event;
		var kCode					=	e.keyCode || e.which;
		
		
		var high					=	getObject("highlightRow");
		var	highlight				=	parseInt(high.value, 10);
		
		var result					=	getObject(divid);
		var highestVal				=	parseInt(getObject("resultCounter").value, 10);

		showHideSearchResultDiv(divid, 1);
		
		//	Enter Key, hide result div and get out
		if (kCode == 13) 
		{
			showHideSearchResultDiv(divid, 2);
			return false;
		}
		
		//	Down Arrow Key
		if(kCode ==	40)
		{
			if(highlight == highestVal)
			{
				highlight			=	0;
				obj.value			=	getObject("hidden"+inputid).value;
			} else {
				highlight++;
			}
			high.value				=	highlight;
			result.innerHTML = createResultDataToShow(getObject("hidden"+inputid+"Data").value, highlight, calltype, inputid);
		//	Up Arrow Key
		} else if(kCode == 38) {
			if(highlight == 0)
			{
				highlight			=	highestVal;
			} else if(highlight == 1) {
				highlight			=	0;
				obj.value			=	getObject("hidden"+inputid).value;
			} else {
				highlight--;
			}
			high.value				=	highlight;
			result.innerHTML = createResultDataToShow(getObject("hidden"+inputid+"Data").value, highlight, calltype, inputid);
		//	Left/right, home/end, page up/page down keys
		} else if(kCode == 33 || kCode == 34 || kCode == 35 || kCode == 36 || kCode == 37 || kCode ==39) {
		//	Escape
		} else if(kCode == 27) {
			showHideSearchResultDiv(divid, 2);
		//	Otherwise do everything now
		} else {
			//	Reset high, highlight and hidden data to 0/nothing
			high.value				=	0;
			highlight				=	0;
			getObject("hidden"+inputid+"Data").value	=	"";
			
			//	Take out the space with _
			var tt					=	objValue.replace(/\s+$/, '_');
			//	Define URL to call through AJAX
			var url					=	(calltype == "Large") ? "/admin/default/starnames/starnamelike/" : "/star/default/starnames/starnamelike/";
			result.innerHTML		=	'<img src="/public/img/wait.gif" border="0" />';
			//	AJAX Call
//			$.get(url + objValue + "/high/" + highlight, function(data) 
			$.ajax({
				type: "GET",
				url: url + objValue + "/high/" + highlight,
				error: function(xhr, desc, exceptionobj)
				{
					data			=	xhr.responseText
					if(data)
					{
						//	Store Data for future use in the hidden variable
						getObject("hidden"+inputid+"Data").value	=	data;
						//	Fill in the data in the result division
						result.innerHTML = createResultDataToShow(data, highlight, calltype, inputid);
					} else {
						getObject(divid).innerHTML	=	createNoResultData(calltype);
					}
				},
				
				success: function(data)
				{ 
					if(data)
					{
						//	Store Data for future use in the hidden variable
						getObject("hidden"+inputid+"Data").value	=	data;
						//	Fill in the data in the result division
						result.innerHTML = createResultDataToShow(data, highlight, calltype, inputid);
					} else {
						getObject(divid).innerHTML	=	createNoResultData(calltype);
					}
				}
			});
			//	Whatever is in the input field should be the value for the hidden input field variable
			getObject("hidden"+inputid).value = obj.value;
		}
	//	Otherwise if length is one
	} else if(objValue.length == 1) {
		showHideSearchResultDiv(divid, 1);
		getObject(divid).innerHTML	=	createMinimum2CharData(calltype);
	//	Nothing in the input search field
	} else {
		getObject(divid).innerHTML 	=	"";
		showHideSearchResultDiv(divid, 2);
	}
	return true;
}


//	Shows data in the division
function createResultDataToShow(data, highlight, calltype, inputid)
{
	//	Split the data
	var tmp							=	data.split("GBROWSEPARATORGB");
	//	First element is the counter 
	var cntr						=	tmp[0];
	//	Store the counter value on the form
	getObject("resultCounter").value=	cntr;
	
	//	Initialize the variable to return	
	var dd							=	'<div id="resultRowDiv' + (calltype == "Large" ? 'Large' : 'Small') + '">';
	
	//	Loop through the data
	for(i=1; i<=cntr; i++)
	{
		//	Add data to return value
		dd							+=	'<div class="resultStarName' + ((highlight == i) ? 'Selected' : '') + ((calltype == "Large") ? 'Large' : 'Small') + '" id="dispRowName' + i + '" name="dispRowName' + i + '" onmousemove="selectThisDiv(' + i + ');" onmouseout="deSelectThisDiv(' + i + ');" onclick="moveTextToBox(' + i + ', ' + "'" + inputid + "'" + ', ' + "'" + calltype + "'" + ');">' + tmp[i] + '</div>';
		
		//	Check if we need to put the value in the input field
		if(highlight == i)
		{
			//	Put this value in the input field
			getObject(inputid).value = tmp[i];
		}
	}
	//	Close the div
	dd								+=	'</div>';
	return dd;
}


//	Selects the given div
function selectThisDiv(id)
{
	//	Get the value for the current highlighted row
	var highlight				=	getObject("highlightRow");
	//	If the value is greater than 0
	if(parseInt(highlight.value, 10) > 0) 
	{	
		//	Remove the highlight from this row
		deSelectThisDiv(parseInt(highlight.value, 10));
	}
	
	//	Get the object which we need to highlight
	var obj						=	getObject("dispRowName"+id);
	//	Define highlight properties
	obj.style.color				=	"#ffffff";
	obj.style.background		=	"#3366cc";
	//	Store this value to the highlight for future use
	highlight.value				=	id;
	
}

//	Deselects the given div
function deSelectThisDiv(id)
{
	//	Get the object to remove highlight from
	var obj						=	getObject("dispRowName"+id);
	//	Change the properties
	obj.style.color				=	"#26333b";
	obj.style.background		=	"#dcdcdc";
}

//	Moves the text to the input box
function moveTextToBox(id, inputid, calltype)
{
	//	Assign the value to both hidden input field and input field 
	getObject("hidden" + inputid).value = getObject(inputid).value = getObject("dispRowName"+id).innerHTML;
	//	No highlight is needed
	getObject("highlightRow").value		=	0;
	//	Reset the hidden input field data to nothing
	getObject("hidden" + inputid + "Data").value	=	"";
	//	If it is for admin, set the focus to the video site control
	if(calltype == "Large") 
	{
		getObject("videoSite").focus();
	}
}

//	Creates Dummy Data to show when the length is 1 for the text in the input field
function createMinimum2CharData(calltype)
{
	var dd							=	'<div id="resultRowDiv' + (calltype == "Large" ? 'Large' : 'Small') + '">';
	dd								+=	'<div id="min2CharDiv' + (calltype == "Large" ? 'Large' : 'Small') + '" name="min2CharDiv' + (calltype == "Large" ? 'Large' : 'Small') + '">Minimum 2 Characters to Search</div>';
	dd								+=	'</div>';
	return dd;
}


//	No Results available display
function createNoResultData(calltype)
{
	var dd							=	'<div id="resultRowDiv' + (calltype == "Large" ? 'Large' : 'Small') + '">';
	dd								+=	'<div id="min2CharDiv' + (calltype == "Large" ? 'Large' : 'Small') + '" name="min2CharDiv' + (calltype == "Large" ? 'Large' : 'Small') + '">No Results Found</div>';
	dd								+=	'</div>';
	return dd;
}

//	End of Auto Suggest Functions


//	Checks a review/comment form submission
function reviewFormValidation()
{
	//	If a user name is less than 2 characters long, it's considered a problem
	var	userName					=	getObject("userName");
	//	Check if the name entered is less than 2 characters long
	if(userName.value.trim().length < 2)
	{
		// If so, alert the user and exit
		userName.focus();
		alert("Your name should atleast 2 characters long");
		return false;
	}
	userName						=	null;
	
	//	User Email
	var userEmail					=	getObject("userEmail");
	//	RexEx for Email Format Check
	var	emailRegEx 					= 	/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
	//	If user specified email doesn't match 
	if(!emailRegEx.test(userEmail.value))
	{
		//	If not, alert the user and exit
		userEmail.focus();
		alert("Invalid Email Address!")
		return false;
	}
	userEmail						=	null;

	//	Get Comment Text
	var txt							=	getObject("reviewText").value;
	if(txt.length < 2)
	{
		alert("Please enter at least 2 characters for the review!");
		return false;
	}
	txt								=	null;

	return true;
}

//	Checks Admin Section Comment field length
function adminReviewFormValidation()
{
	//	Get Comment Text
	var txt							=	getObject("reviewText").value;
	if(txt.length < 2)
	{
		alert("Please enter at least 2 characters for the review!");
		return false;
	}
	txt								=	null;

	return true;
}


//	Resizes the image to 75%
function resizeImageReviewImage(imgsrc, val)
{
	var img							=	new Image();
	img.src							=	imgsrc;
	img.height						=	parseInt(img.height, 10) * (val / 100);
	img.width						=	parseInt(img.width, 10) * (val / 100);
	var oldimg						=	getObject("imageReviewImage");
	oldimg.src						=	img.src;
	oldimg.height 					= 	img.height;
	oldimg.width					=	img.width;
}
