function emailValidator(val){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(val.match(emailExp)){
		return true
	}else{
		return false;
	}
}

function validateReview()
{
	if (document.getElementById("name").value != "") 
		if (emailValidator(document.getElementById("email").value) ) 
			if (document.getElementById("reviews").value != "") 
				return true;
			else
				alert('Please write reviews');				
		else
			alert('Please enter a Valid Email Address');	
	 else 
		alert('Please enter Your Name');
	
	return false;
}


function reviewWindowHTML(userid)
{
	html = '<form id="reviewForm" name="reviewForm" method="post" action="" onsubmit="return validateReview()"><table width="500" border="0" cellspacing="0" cellpadding="0" class="borderTable" bgcolor="#FFFFFF">  <tr>  <td align="right" class="titleTd" style="padding:3px"><table width="99%" border="0" cellspacing="0" cellpadding="0">    <tr>      <td width="97%" align="left" class="titleTd">Rate and Review this Member</td>      <td width="3%" align="center" style="cursor:pointer" onclick="closeReview()"><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #ffffff;background-color: #D10000">X</span></td>    </tr>  </table></td></tr>  <tr>  <td align="center"><table width="98%" border="0" cellspacing="2" cellpadding="2">  <tr>    <td width="16%"  align="right" class="inputlLabel">Name:</td>    <td width="84%" align="left">        <input type="text" name="name" id="name" style="width:375px" />    </td>  </tr>  <tr>    <td align="right" class="inputlLabel">Email:</td>    <td align="left"><input type="text" name="email" id="email" style="width:375px" /></td>  </tr>  <tr>    <td align="right" class="inputlLabel">Comments:</td>    <td align="left">      <textarea name="reviews" id="reviews" style="width:375px" rows="8"></textarea>    </td>  </tr>  <tr>    <td align="right" class="inputlLabel" >Rating:</td>    <td align="left" class="inputlLabel" valign="middle">        <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">          <tr>            <td><input name="rating" id="rating" type="radio" value="1" /></td>            <td class="inputlLabel">Poor</td>            <td><input name="rating" id="rating" type="radio" value="2" /></td>            <td class="inputlLabel">Fair</td>            <td><input name="rating" id="rating" type="radio" value="3"  /></td>            <td class="inputlLabel">Good</td>            <td><input name="rating" id="rating" type="radio" value="4"/></td>            <td class="inputlLabel">Very Good</td>            <td><input name="rating" id="rating" type="radio" value="5" checked="checked"   align="middle"/></td>            <td class="inputlLabel">Excellent</td>          </tr>        </table></td>  </tr>  <tr>    <td align="right" class="inputlLabel" ><input type="hidden" name="userid" value="' + userid + '" /></td>    <td align="center"  valign="middle">      <input type="submit" name="reviewSubmit" value="Submit" class="bt" />	</td>  </tr></table></td></tr></table></form>';

	return html;
}


function mailHTML()
{
	html = '<form id="mailForm" name="mailForm" method="post" action="">  <table width="500" border="0" cellspacing="0" cellpadding="0" class="borderTable" align="center" bgcolor="#FFFFFF">   <tr>      <td colspan="2" align="right" class="titleTd" style="padding:3px"><span style="cursor:pointer" onclick="closeMail()">X</span></td>      </tr>    <tr>      <td width="30%" height="25" align="right" class="inputlLabel" style="padding-right:5px">Your Name: </td>      <td width="70%" height="25" align="left"><input type="text" name="sender_name" value="" class="inputTextbox" size="32" style="width:300px"></td>    </tr>    <tr>      <td height="25" align="right" class="inputlLabel" style="padding-right:5px">Email Address: </td>      <td height="25" align="left"><input type="text" name="sender_email" value="" class="inputTextbox" size="32" style="width:300px" /></td>    </tr>    <tr>      <td height="25" align="right" class="inputlLabel" valign="top" style="padding-right:5px">Message Body: </td>      <td height="25" align="left"><textarea  rows="8" cols="28" class="inputTextbox" name="mail_message" maxlength="2500" style="width:300px; height:200px" ></textarea></td>    </tr>       <tr>      <td>&nbsp;</td>      <td align="left"><input type="submit" name="mailSubmit" value=" Send Mail " class="bt"></td>    </tr>    <tr>      <td colspan="2" height="5"></td>      </tr>  </table>  </form>';
	return html;
}

function gatherKeyValues(theForm) 
{

	var num_of_elements = theForm.length;
	var paramString = '';
	var paramString1 = '';
	for (var i=0; i<num_of_elements; i++) 
	{
		var theElement    = theForm.elements[i];
		var element_type  = theElement.type;
		var element_name  = theElement.name;
		var element_value = theElement.value;
		var element_id    = theElement.id;
		
		if (i==0)
			prm = '';
		else
			prm = '|';
		
		
		if (element_type == "hidden") 
			paramString += prm + element_name + '=' + element_value;
		
		if (element_type == "text") 
		{
			if (element_value != "") 
			{
				if (element_name == "email")
				{
					var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
					/*
					if(! (element_value.match(emailExp)) ) {
						alert("Please enter Valid Email address");
						return false;	
					}*/
				}
				paramString += prm + element_name + '=' + element_value;
			}
			else
			{
				if (element_name == 'name')
					alert("Please enter Name");
				else if (element_name == 'email')
					alert("Please enter Email Address");

				return false;
			}
		}
		
		if (element_type == "radio") {
			if (theElement.checked == true)
				paramString += prm + element_name + '=' + element_value;
		}
		if (element_type == "textarea") {
			if (element_value == "") {
				alert("Please enter Comments");
				return false;
			}
			else
			{
				newValue = element_value.replace(/[\r\n]/g, "<br />");
				newValue = newValue.replace("'", "\\'");
				paramString += prm + element_name + '=' + newValue;
			}
		}
	}
	
	return paramString;

 }