//Validates Partner Signup Step 1 form
function validateStep1()
{
	trimFields();
	if(obj.email_address.value == "")
	{
		alert(JS_NO_EMAIL_ADDRESS);
		obj.email_address.focus();
		return;
	}
	if(!chkEmail(obj.email_address.value))
	{
		alert(JS_INVALID_EMAIL_ADDRESS);
		obj.email_address.focus();
		return;
	}
	if(obj.password.value == "")
	{
		alert(JS_NO_PASSWORD);
		obj.password.focus();
		return;
	}
	if(obj.password.value.length < 6)
	{
		alert(JS_INVALID_LENGTH_PASSWORD);
		obj.password.focus();
		return;
	}
	if(obj.conf_password.value == "")
	{
		alert(JS_NO_CONFIRM_PASSWORD);
		obj.conf_password.focus();
		return;
	}
	if(obj.password.value != obj.conf_password.value)
	{
		alert(JS_PASSWORD_MISMATCH);
		obj.conf_password.focus();
		obj.conf_password.select();
		return;
	}
	/*if(obj.first_name.value == "")
	{
		alert(JS_NO_FIRST_NAME);
		obj.first_name.focus();
		return;
	}
	if(obj.last_name.value == "")
	{
		alert(JS_NO_LAST_NAME);
		obj.last_name.focus();
		return;
	}*/
	if(obj.nationality.selectedIndex == 0)
	{
		alert(JS_NO_NATIONALITY);
		obj.nationality.focus();
		return;
	}
	/*if(obj.visa_upto.value == "" && !(obj.end_date.checked))
	{
		alert(JS_NO_VISA_VALIDITY);
		obj.end_date.focus();
		return;
	}
	if(obj.visa_upto.value != "" && obj.end_date.checked)
	{
		alert(JS_INVALID_VISA_VALIDITY);
		obj.end_date.focus();
		return;
	}*/
	/*if(obj.job_title.value == "")
	{
		alert(JS_NO_JOB_TITLE);
		obj.job_title.focus();
		return;
	}
	if(obj.address1.value == "")
	{
		alert(JS_NO_ADDRESS);
		obj.address1.focus();
		return;
	}*/
	if(obj.city.value == "")
	{
		alert(JS_NO_CITY);
		obj.city.focus();
		return;
	}
	/*if(obj.state.value == "")
	{
		alert(JS_NO_STATE);
		obj.state.focus();
		return;
	}*/

	if(obj.country_code.selectedIndex == 0)
	{
		alert(JS_NO_COUNTRY);
		obj.country_code.focus();
		return;
	}
	/*if(obj.phone1.value == "")
	{
		alert(JS_NO_PHONE);
		obj.phone1.focus();
		return;
	}*/
	//alert(obj.end_date.checked);
	obj.action = 'partner_signup1.php';
	obj.submit();
}

//Validates Partner Signup Step 2 form
function validateStep2()
{
	trimFields();
	//alert(obj.elements['sub_categories[]'][1].checked);
	/*if(obj.biz_type_id.selectedIndex == 0)
	{
		alert(JS_NO_BIZ_TYPE);
		obj.biz_type_id.focus();
		return;
	}
	if(obj.biz_direction_id.selectedIndex == 0)
	{
		alert(JS_NO_BIZ_DIRECTION);
		obj.biz_direction_id.focus();
		return;
	}*/
	if(obj.category.selectedIndex == -1 || obj.category.selectedIndex == 0)
	{
		alert(JS_NO_CATEGORY);
		obj.category.focus();
		return;
	}
	var count = 0;
	for (var current=0;current < obj.elements['sub_categories[]'].length;current++)
	{
		if(obj.elements['sub_categories[]'][current].checked)
		{
			count = count + 1;
		}
	}
	if(count == 0)
	{
		alert(JS_NO_SUB_CATEGORY);
		obj.elements['sub_categories[]'][0].focus();
		return;
	}
	if(count > 5)
	{
		alert(JS_INVALID_NUM_OF_SUB_CATEGORIES);
		obj.elements['sub_categories[]'][0].focus();
		return;
	}
	/*if(obj.market_id.selectedIndex == 0)
	{
		alert(JS_NO_MAIN_MARKET);
		obj.market_id.focus();
		return;
	}
	if(obj.company_size_id.selectedIndex == 0)
	{
		alert(JS_NO_COMPANY_SIZE);
		obj.company_size_id.focus();
		return;
	}*/
	/*if((obj.service_area_id.selectedIndex == 0 && obj.service_area_other.value == "") || (obj.service_area_id.selectedIndex != 0 && obj.service_area_other.value != ""))
	{
		alert(JS_NO_AREA_OF_SERVICE);
		obj.service_area_id.focus();
		return;
	}*/
	/*if(obj.turnover_id.selectedIndex == 0)
	{
		alert(JS_NO_TURNOVER);
		obj.turnover_id.focus();
		return;
	}
	if(obj.year_estd.selectedIndex == 0)
	{
		alert(JS_NO_YEAR_ESTD);
		obj.year_estd.focus();
		return;
	}
	if(obj.products_services.value == "")
	{
		alert(JS_NO_PRODUCTS_SERVICES);
		obj.products_services.focus();
		return;
	}*/
	/*if(obj.products_services.value.length > 255)
	{
		alert(JS_INVALID_LENGTH_PRODUCTS_SERVICES);
		obj.products_services.focus();
		return;
	}*/
	/*if(obj.service_industries.value == "")
	{
		alert(JS_NO_SERVICE_INDUSTRY);
		obj.service_industries.focus();
		return;
	}*/
	/*if(obj.service_industries.value.length > 255)
	{
		alert(JS_INVALID_LENGTH_SERVICE_INDUSTRY);
		obj.service_industries.focus();
		return;
	}*/
	/*if(obj.focus_biz_area.value == "")
	{
		alert(JS_NO_FOCUS_BIZ_AREA);
		obj.focus_biz_area.focus();
		return;
	}*/
	/*if(obj.focus_biz_area.value.length > 255)
	{
		alert(JS_INVALID_LENGTH_FOCUS_BIZ_AREA);
		obj.focus_biz_area.focus();
		return;
	}*/
	/*if(obj.description.value == "")
	{
		alert(JS_NO_DESCRIPTION);
		obj.description.focus();
		return;
	}*/
	/*if(obj.description.value.length >= 1200)
	{
		alert(JS_INVALID_LENGTH_DESCRIPTION);
		obj.description.focus();
		return;
	}*/
	if(!(obj.terms_condition.checked))
	{
		alert(JS_NO_TERMS_CONDITION);
		obj.terms_condition.focus();
		return;
	}
	obj.action = 'partner_signup2.php';
	obj.submit();
}

//Send a request to the get_subcategories.php page to get the sub categories
function getSubCategories()
{
	//Change the cursor to wait cursor
	document.body.style.cursor = 'wait';
	//Make a GET request to load sub-categories
	var params = 'id='+obj.category.options[obj.category.selectedIndex].value;
	ajax.getRequest('/get_subcategories.php', params, fillSubCategories);
}

//Fill the sub_category dropdown box with the sub_categories returned.
function fillSubCategories(retVal)
{
	//alert(retVal);
	document.getElementById("sub_cat_list").innerHTML = retVal;
	document.body.style.cursor = 'default';
}

//Whether the user clicks the back button
function goBack(step)
{
	switch(step)
	{
		case 1:
			obj.action = 'partner_signup2.php?opt=back';
			obj.submit();
			break;
		case 2:
			obj.action = 'partner_plan.php?opt=back';
			obj.submit();
			break;
	}

}

//Function for checking of unique email address
function checkAvailabilityEmail()
{
	if(obj.email_address.value != "" && chkEmail(obj.email_address.value) == true)
	{
		//Make a GET request for the availability
		var params = 'email='+obj.email_address.value;
		ajax.getRequest('/get_email_avilability.php', params, getEmailAvailabilityConfirmation);
	}
}

//Get the confirmation for the availability of email
function getEmailAvailabilityConfirmation(retVal)
{
	//alert(retVal);
	if(retVal == "FAILED")
		document.getElementById("email_msg").innerHTML = '<span class="red1b"><em>Duplicate Email Address!<br />Please enter a unique email address.</em></span>';
	else
		document.getElementById("email_msg").innerHTML = '<span class="grn1b"><em>Email address is okay.</em></span>';
}
