/*	Added by rnair on 25/10/08
*
*	This is a notification function that can be used all around the verkko website
*	This can display the string message passed to it along with the type of notification ie success or fail
*/

function drawNotificationBox(cDivName, cString, cNotificationType, cFunctionName, cDivTop)
{
	cCallFunction = '';
	if( cFunctionName.length > 0) {
		cCallFunction=cFunctionName+"();";
	}

	var cTableStructurePopup="	<table border='0' cellspacing='0' cellpadding='0' width='100%' style='border: 2px solid #9FB1BC; background: #ffffff'>			<tr>				<td>					<table border='0' width='100%' cellspacing='0' cellpadding='0' >						<tr class='popupHead'>							<td width='10%' height='30px'>								&nbsp;							</td>							<td width='60%'>								&nbsp;							</td>							<td width='30%' align='center'>								<a style='text-decoration: underline' href='#' onClick='popupDivHide();"+cCallFunction+"return false'><b>close</b></a>							</td>						</tr>						<tr class='popupHead'>							<td width='10%'>						</td>						<td width='60%' >						<table  width='100%' border='0' cellspacing='1' cellpadding='1' align=center>						<tr>										<td id='showValidationResult'>										"+cString+										"										</td>									</tr>								</table>							</td>"
										
	if(cNotificationType	==	"error")
	{
		cTableStructurePopup+= "							<td width='30%'>								<img src='theme/default/images/errorpopup.jpg'>							</td>							"
	}
	else
	{
		cTableStructurePopup+= "							<td width='30%'>								<img src='theme/default/images/successpopup.jpg'>							</td>							"		
	}
	
	cTableStructurePopup+ "						</tr>						<tr class='popupHead'>							<td colspan='3'>								&nbsp;							</td>						</tr>					</table>				</td>			</tr>		</table>'";
	

	//Now that the dirty work is done, we can now start displaying the popup
	var cDivName				=	document.getElementById(cDivName);
	cDivName.innerHTML			=	cTableStructurePopup;
	//cDivName.appendChild(cTableStructurePopup);
	cDivName.style.left			="30%";
	cDivName.style.top			=cDivTop+"%";
	//cDivName.style.top			="60%";
	cDivName.style.width		="400px";
	cDivName.style.visibility	=	"visible"
	
	//Now I have used innerHTML but need to convert this to DOM later using createElement
	
	
	
	//faderObj.doCenter(cDivName);
	/*document.getElementById("registrationFormValidationLayer").style.left			="250px";
	document.getElementById("registrationFormValidationLayer").style.top			="320px";
	document.getElementById("registrationFormValidationLayer").style.width			="400px";
	document.getElementById("registrationFormValidationLayer").style.visibility		="visible";*/
}
function popupDivHide()
{
	document.getElementById("registrationFormValidationLayer").style.visibility="hidden";
	document.getElementById("notFromsameCollege").style.visibility="hidden";
	document.getElementById("invalidcollerr").style.visibility="hidden";
}

 var cUrl =window.location.href;
 var cBasePathArr = cUrl.split("?");

function noLongerLiveJob()
{
	 curlPath = cBasePathArr[0]+"?L=blogs.browse";
	 window.location.href=curlPath;
}

function checkInviteFriendsEmail()
{
	var cErrorString = "";
	var inviteFriendsEmail = document.getElementById("inviteFriends").value;
	if(inviteFriendsEmail == "" || inviteFriendsEmail == 'email address')
	{
		cDivTop=100;
		showClose = true;
		cErrorString = "Please enter Email Address";
		drawNotificationBox("registrationFormValidationLayer", cErrorString, "error","",cDivTop,showClose);
		return false;
	}
	else
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = inviteFriendsEmail;
		if(reg.test(address) == false)
		{
			cDivTop=100;
			showClose = true;
			cErrorString="Please enter valid Email";
			drawNotificationBox("registrationFormValidationLayer", cErrorString, "error","",cDivTop,showClose);
			return false;
		}
		else
		{
			return true;
		}
	}
}

function showMePreferredDealDiv()
{
	$('#expressInterestDiv').fadeIn(700);
}

function hideExpressInterestDiv()
{
	$('#expressInterestDiv').fadeOut(700);
	$('#formContactNumber').parent().children("div.expressInterestPopup").remove();
	$('#formEmailIdToBeContacted').parent().children("div.expressInterestPopup").remove();
	$('#formTypeOfFlat').parent().children("div.expressInterestPopup").remove();
}

function showMeBulkDealDiv()
{
	$('#FilteredJobsBody').slideUp(1200);
	$('#BulkDealsBody').slideDown(1200);
}

function showMeFilteredJobsDiv()
{
	$('#BulkDealsBody').slideUp(1100);
	$('#FilteredJobsBody').slideDown(1000);
}

function checkExpresInt()
{
	var cErrorString="";
	cErrorString="";

	var cContactNumber					=document.getElementById("formContactNumber").value;
	var cEmailIdToBeContacted			=document.getElementById("formEmailIdToBeContacted").value;
	var cTypeOfFlat						=document.getElementById("formTypeOfFlat").value;
	var flag=true;

	$('#formContactNumber').parent().children("div.expressInterestPopup").remove();
	if(cContactNumber == "")
	{
		$('#formContactNumber').parent().append("<div class='expressInterestPopup'>Mandatory</div>");
		flag = false;
	}

	$('#formEmailIdToBeContacted').parent().children("div.expressInterestPopup").remove();
	if(cEmailIdToBeContacted == "")
	{
		$('#formEmailIdToBeContacted').parent().append("<div class='expressInterestPopup'>Mandatory</div>");
		flag = false;
	}

	$('#formTypeOfFlat').parent().children("div.expressInterestPopup").remove();
	if(cTypeOfFlat == "")
	{
		$('#formTypeOfFlat').parent().append("<div class='expressInterestPopup'>Mandatory</div>");
		flag = false;
	}
	if(flag == false)
	{
		return false;
	}
	else
	{
		return true;
	}
}
