/*function popup(strURL,strType,strHeight,strWidth) {
	var strOptions="";
	if (strType=="console") 
		strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") 
		strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") 
		strOptions="toolbar,menubar,scrollbars,resizable,location,
		height="+strHeight+",width="+strWidth;
	window.open(strURL, 'newWin', strOptions);
}


function sel( parent , id ){
	parent = document.getElementById( parent ) ;
	children = document.getElementsByTagName( "div" ) ;
	for ( i = 0 ; i < children.length ; i++ ) {
		if ( children[ i ].id == id ) {
			children[ i ].style.visibility = 'visible' ;
		} else {
			children[ i ].style.visibility = 'hidden' ;
		}
	}
}
function getStudentSearchResultPage(pageNum){
	document.studentSearch.page.value = pageNum;
	document.studentSearch.submit();
}
function MM_findObj(n, d) { //v3.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_changeProp(objName,x,theProp,theValue) { //v3.0
	var obj = MM_findObj(objName);
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
//		if (obj.style) { obj=obj.style; obj.visibility=(v=='show')?'visible':(v='hide')?'hidden':v; }
		obj = document.getElementById( args[ i ] ) ;
		if (obj.style) { obj=obj.style; obj.visibility=(v=='show')?'visible':(v='hide')?'hidden':v; }
	}
}
function loginBB(){
	document.BBLogin.submit();
}
function checkValues(value1, value2, theForm){
	var pass1 = value1;
	var pass2 = value2;
	if(pass1 != pass2){
		alert("The values you have entered do not match.\nPlease try again.");
		theForm.reset();
		return false;
	}
}

function checkPassword1(theForm) {
    var password = theForm.Password1.value;
    var confirmation = theForm.Password2.value;
    if ( (password != confirmation) || document.theForm.Password1.value.length < 1 ) { 
        alert("The values you have entered do not match.\nPlease try again.");
        theForm.reset();
        theForm.Password1.focus();
        return false;
    }

    return true;
}

           function checkPassword( form ) {
                if ( form.Password1.value.length < 1 ) {
                    alert( "You must enter a Password question" ) ;
                    return false ;
                }
                if ( form.Password2.value.length < 1 ) {
                    alert( "You must enter a confirm Password question" ) ;
                    return false ;
                }
				
                if ( form.Password1.value != form.Password2.value ) {
                    alert( "The values you have entered do not match.\nPlease try again." ) ;
        					theForm.reset();
        					theForm.Password1.focus();
                    return false ;
                }
                return true ;
            }
*/
//-- Jepages javascript code


function checkDropDownValue(drop_down_value)
{	
	selectedChoice =  drop_down_value.selectedIndex;
	
	if (drop_down_value.options[selectedChoice].value == "")
	{
		return false;
	}

	return true;
}


// general purpose function to see if an input value has been entered at all
function isEmpty(inputStr) {
	if (inputStr == "" || inputStr == null) {
		return true
	}
	return false
}

// function to determine if value is in acceptable range for this application
function inRange(inputStr, lo, hi) {
	var num = parseInt(inputStr, 10)
	if (num < lo || num > hi) {
		return false
	}
	return true
}


function deBugger()
{	
	alert("H , and welcome in..On the global front 22.");
	return false;

}
 
function comparePasswords( Password1,Password2 ) 

{
	var returnValue = "Ok";
	//alert(Password1);
	if ( Password1.length < 1 ) 
	{
		//alert( "You must enter a Password question" ) ;
		returnValue = "You must enter a Password "
		return returnValue ;
	}
	
	if ( Password2.length < 1 ) 
	{
		//alert( "You must enter a confirm Password question" ) ;
		returnValue = "You must enter a confirming password" ;
		return returnValue ;
	}
	
	if ( Password1 != Password2 ) 
	{
		//alert( "The values you have entered do not match.\nPlease try again." ) ;
		returnValue = "The values of the passwords do not match." ;
		return returnValue ;
	}/**/
	return returnValue ;
}
function checkRadioButton(radio_value)
{
	capturedValue = -1;
	
	for(i=0; i < radio_value.length;i++)
	{
		if (radio_value[i].checked)
		{
			capturedValue = i;
		}
	
	}
	
	if (capturedValue == -1)
	{
		return false;
	}
	
	return true;
}

function checkEmail(email_in)
{
	re  = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (re.test(email_in))
	{
		return true;
	}

	//alert("Invalid email address");

	return false;
}

function validateYear(field) {
	var input = field.value
	var currentDate = new Date();
	var youngYear 	=  currentDate.getYear() - 18;
	var oldYear 	=  currentDate.getYear() - 100;
		
	if (isEmpty(input)) 
	{
		return "Please enter a year value";
	} 
	else 
	{
		input = parseInt(field.value, 10)
		if (isNaN(input)) 
		{
			return "Date must be numbers only";
		} 
		else 
		{
			if (!inRange(input,oldYear,youngYear)) 
			{
				return "Please enter a valid year of birth";
			}
		}
	}
	
	return "Ok";
}

function checkSearchCriteria(form)
{
	if (isEmpty(form.CategoryString.value))
	{
		alert("Please enter the business type / name required for searching.");
		return true;
	}
	else
	{
		return true;
	}

}
function submitform()
{
	 if(document.mainform.onsubmit())
	 {
		document.mainform.submit();
	 }
 }
function locationPick(selectedTown,areaId)
{
	var x;
	//alert("You have selected " + selectedTown + "." );
	document.mainform.locationString.value = selectedTown;
	document.mainform.area_id.value = areaId;
	document.mainform.submit(); 
	return false;
}
function insertCategory(selectedCategory,form)
{
	//alert("You have selected kkk" + selectedCategory + "." );
	//form.CategoryString.value = selectedCategory;
	document.mainform.CategoryString.value = selectedCategory;
	document.mainform.locationString.value = 'covent garden';
	
	
	document.mainform.submit(); 
	return true;
}

function fireSearchForm()
{
	
	document.mainform.locationString.value = document.mainform2.locationString.value;
	document.mainform.area_id.value = document.mainform2.area_id.value;
	document.mainform.display.value = document.mainform2.display.value;
	document.mainform.CategoryString.value = document.mainform2.CategoryString.value;
	document.mainform.search_type = document.mainform2.search_type;
	//Just in case the company search has been selected then we want that selection to continue
	//if (document.mainform2.search_type[1].checked == true)
	//{
		//document.mainform.search_type[1].checked = true;
	//}
	var valueX =  submitform();
	//document.mainform.submit(); 
	
	return true;
}	
function informUser(releaseTime)
{	
	var msgStringRegistration =  "The User Module is presently in development. This is expected to be";
		msgStringRegistration += "\n";
		msgStringRegistration += "completed by 17th December 2007. If you would like to be kept";
		msgStringRegistration += "\n";
		msgStringRegistration += "posted, please send an email to info@jetpages.com.";
		
	var msgStringSearch =  "The Search Module is presently in development. This is expected to be";
		msgStringSearch += "\n";
		msgStringSearch += "ready by 30th May 2007. If you would like to be kept";
		msgStringSearch += "\n";
		msgStringSearch += "posted, please send an email to info@jetpages.com.";
	
	var displayMessage;	
		

	
	if ((releaseTime == 'registration') || (releaseTime == 'login') )  
	{
		displayMessage = msgStringRegistration;
	}
	 
	else 
	{
		displayMessage = msgStringSearch;
	}
	
	alert(displayMessage);
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
