
var Ajax = new sack();

function displayInfo()
{
	eval(Ajax.response);
}

////////******* FUNCTINO FOR VALIDATING VENDOR SIGNUP ********/////////

function viewWeddingDate(id)
{
    if(id == 21)	
	{
		document.getElementById('td_WedDate').className = 'left_panel_inactive';
	}
	else
	{
        document.getElementById('td_WedDate').className = 'left_panel_active';
	}
}

function validateAdditionalServiceAreas(form)
{
	if (document.getElementById('serve_country_1') && form.serve_country_1.value >= 1) {
		if (SelectValidation(form.serve_state_1,'Serve Area #1 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_1').value == "" && SelectValidation(form.serve_city_1,'Serve Area #1 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_2') && form.serve_country_2.value >= 1) {
		if (SelectValidation(form.serve_state_2,'Serve Area #2 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_2').value == "" && SelectValidation(form.serve_city_2,'Serve Area #2 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_3') && form.serve_country_3.value >= 1) {
		if (SelectValidation(form.serve_state_3,'Serve Area #3 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_3').value == "" && SelectValidation(form.serve_city_3,'Serve Area #3 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_4') && form.serve_country_4.value >= 1) {
		if (SelectValidation(form.serve_state_4,'Serve Area #4 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_4').value == "" && SelectValidation(form.serve_city_4,'Serve Area #4 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_5') && form.serve_country_5.value >= 1) {
		if (SelectValidation(form.serve_state_5,'Serve Area #5 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_5').value == "" && SelectValidation(form.serve_city_5,'Serve Area #5 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_6') && form.serve_country_6.value >= 1) {
		if (SelectValidation(form.serve_state_6,'Serve Area #6 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_6').value == "" && SelectValidation(form.serve_city_6,'Serve Area #6 City')=='') {
			return false;
		}
	}
	if (document.getElementById('serve_country_7') && form.serve_country_7.value >= 1) {
		if (SelectValidation(form.serve_state_7,'Serve Area #7 State/Providence')=='') {
			return false;
		} else if (document.getElementById('new_serve_city_7').value == "" && SelectValidation(form.serve_city_7,'Serve Area #7 City')=='') {
			return false;
		}
	}
	return true;
}

function validate_vendor_signup(signup_vendor)
{
    if(GenValidation(signup_vendor.txt_fname,'First Name','','')=='')
	{
		return false;
	}
	else if(namevalidation(signup_vendor.txt_fname, 'First Name','','') == '')
    {
        return false;
    }
	else if(GenValidation(signup_vendor.txt_lname,'Last Name','','')=='')
	{
		return false;
	}
    else if(namevalidation(signup_vendor.txt_lname, 'Last Name','','') == '')
    {
        return false;
    }
	else if(GenValidation(signup_vendor.txt_email,'Email Id','','')=='')
	{
		return false;
	}
	else if(EmailValidation(signup_vendor.txt_email)=='')
	{
		return false;
	}
	else if(GenValidation(signup_vendor.txt_pswd,'Password','','')=='')
	{
		return false;
	}
	else if(GenValidation(signup_vendor.txt_bname,'Business Name','','')=='')
	{
		return false;
	}
    else if(NumValidation(signup_vendor.txt_1,'Phone code','spl','num')=='')
	{
		return false;
	}
	else if(NumValidation(signup_vendor.txt_2,'Extension code','spl','num')=='')
	{
		return false;
	}
	else if(GenValidation(signup_vendor.txt_3,'Phone number','','')=='')
	{
		return false;
	}
	else if(NumValidation(signup_vendor.txt_3,'Phone number','spl','num')=='')
	{
		return false;
	}
	else if(GenValidation(signup_vendor.txt_add,'Address','','')=='')
	{
		return false;
	}else if(SelectValidation(signup_vendor.sel_country,'Country')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.sel_state,'State/Province')=='')
	{
		return false;
	}
    //else if (document.getElementById('new_city').value == "" && SelectValidation(signup_vendor.sel_city,'City')=='')
    //else if (SelectValidation(signup_vendor.sel_city,'City')=='')
    else if(GenValidation(signup_vendor.txt_city,'City','','')=='')
	{
       return false;
    }
	else if(GenValidation(signup_vendor.txt_zip,'Zip','','')=='')
	{
		return false;
	}
	else if(document.getElementById('txt_others').value=='' && SelectValidation(signup_vendor.heardabt,'Heard About option.')=='')
	{
		return false;
	}
    else if(SelectValidation(signup_vendor.serve_country,'Country you serve.')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.serve_state,'State/Province you serve.')=='')
	{
		return false;
	}
    /*else if(SelectValidation(signup_vendor.serve_city,'City you serve.')=='')
	{
        return false;
    }*/
    //else if (document.getElementById('new_serve_city').value == "" && SelectValidation(signup_vendor.serve_city,'City')=='')
    else if (SelectValidation(signup_vendor.serve_city,'Service City')=='')
    {
       return false;
    }
	else if(document.getElementById('txt_special').value=='' && SelectValidation(signup_vendor.category,'Category/Speciality.')=='')
	{
		return false;
	}
	else if(signup_vendor.chk_agree.checked==false)
	{
		alert("Please read and accept our terms and conditions!");
		signup_vendor.chk_agree.focus();
		return false;		
	}
	else if(GenValidation(signup_vendor.txt_code,"code shown below",'','')=='')
	{
		return false;
	}
    else
    {
        return true;
    }
}

function validateVendorAccountEdit(signup_vendor)
{
    if(GenValidation(signup_vendor.Txt_BusinessName,'Business Name','','')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.sel_Category,'Category')=='')
	{
		return false;
	}
    else if(GenValidation(signup_vendor.txt_Address,'Address','','')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.sel_country,'Country')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.sel_state,'State/Province')=='')
	{
		return false;
	}
    else if(GenValidation(signup_vendor.txt_city,'City','','')=='')
	{
       return false;
    }
	else if(GenValidation(signup_vendor.txt_zip,'Zip','','')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.serve_country,'Country you serve.')=='')
	{
		return false;
	}
	else if(SelectValidation(signup_vendor.serve_state,'State/Province you serve.')=='')
	{
		return false;
	}
    else if (SelectValidation(signup_vendor.serve_city,'Service City')=='')
    {
       return false;
    }
	else if(GenValidation(signup_vendor.txtPhone,'Phone','','')=='')
	{
		return false;
	}
	else if(GenValidation(signup_vendor.txt_Email,'Email','','')=='')
	{
		return false;
	}
	else if(EmailValidation(signup_vendor.txt_Email)=='')
	{
		return false;
	}
	else
    {
        return true;
    }
}

////****** USED IN VENDOR SIGN UP AND VENDOR WEBPAGE FORM ****///////

function getStates(countryid)
{
    Ajax.requestFile='../models/Ajax-Server.php?country_id2='+countryid;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();

}

////****** USED IN VENDOR ACCOUNT PAGE *****/////////

function get_States(countryid)
{
    if (countryid == 38)
    {
        document.getElementById('sel_city').style.display = 'none';
    }
    else if (countryid == 224)
    {
        document.getElementById('sel_city').style.display = '';
    }

    Ajax.requestFile='../models/Ajax-Server.php?country_id2='+countryid;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();

}

////////////////// for fetching the cities ///////////////////////////

function getCities(val)
{
	Ajax.requestFile='../models/Ajax-Server.php?state_id='+val;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}

//******** For Fetching the Serve Cities *****////

function getServeCities(val)
{
	Ajax.requestFile='../models/Ajax-Server.php?serve_state_id='+val;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}

function getServeStates(servecountryid)
{
    Ajax.requestFile='../models/Ajax-Server.php?serve_country_id='+servecountryid;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}
/////******** For checking the Email ****//////////

function checkEmail(EID,TID) //TID specifies Type ID and takes either 1 or 2. 1 indicates Member, 2 indicates Vendor
{
	Ajax.requestFile='../models/Ajax-Server.php?email_id='+EID+'&ptype='+TID;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}

//additional server areas
function getAdditionalServeStates(sID, num) {
	Ajax.requestFile='../models/Ajax-Server.php?serve_country_id='+sID+'&serve_area_num='+num;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}
function getAdditionalServeCities(cID, num) {
	Ajax.requestFile='../models/Ajax-Server.php?serve_state_id='+cID+'&serve_area_num='+num;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}
// *************** validation for the memeber registratiom page *******************//

function validate_member(Form_Name)
{
	if(GenValidation(Form_Name.txt_fname,'First Name','','')=='')
	{
		return false;
	}
	else if(namevalidation(Form_Name.txt_fname, 'First Name','','') == '')
    {
        return false;
    }
	else if(GenValidation(Form_Name.txt_lname,'Last Name','','')=='')
	{
		return false;
	}
	else if(namevalidation(Form_Name.txt_lname, 'Last Name','','') == '')
    {
        return false;
    }
	else if(GenValidation(Form_Name.txt_email,'Email Id','','')=='')
	{
		return false;
	}
	else if(EmailValidation(Form_Name.txt_email)=='')
	{
		return false;
	}
	else if(GenValidation(Form_Name.txt_conf_email,'Email Id','','')=='')
	{
		return false;
	}
	else if(EmailValidation(Form_Name.txt_conf_email)=='')
	{
		return false;
	}
	else if(document.getElementById('txt_conf_email').value != document.getElementById('txt_email').value)
	{
		alert('Confirmed Email does not match');
		return false;
	}
	else if(SelectValidation(Form_Name.you_r_the,'You are the.......')=='')
	{
		return false;
	}
	else if(SelectValidation(Form_Name.defines_you,'Defines You option')=='')
	{
		return false;
	}
	else if(GenValidation(Form_Name.txt_fianc_fname,'Fiances First Name','','')=='')
	{
		return false;
	}
	else if(namevalidation(Form_Name.txt_fianc_fname, 'Fiances First Name','','') == '')
    {
        return false;
    }
    else if(document.getElementById('txt_fianc_email').value != '' && EmailValidation(Form_Name.txt_fianc_email)=='')
    {
        return false;
    }
    else if(SelectValidation(Form_Name.fianc_role,'Fiances role')=='')
	{
        return false;
	}
	else if(document.getElementById('defines_you').value != 21) //  ie the person has no wedding ring yet then
	{
        if(document.getElementById('txt_DateWedding').value!='')
		{
            
			var now = new Date();
			var monthnumber = now.getMonth();
			var monthday    = now.getDate();
			var year        = now.getFullYear();
			monthnumber = monthnumber+1;
			var frmdate = document.getElementById('txt_DateWedding').value;
			var exdate = frmdate.split("-");
			
			if(exdate[0] < year)
			{
				alert('Wedding date must be greater than current date.');
				document.getElementById('txt_DateWedding').focus();
				return false;
			}
			
			if((year==exdate[0]))
			{
				if(exdate[1] < monthnumber)
				{
					alert('Wedding date must be greater than current date.');
					document.getElementById('txt_DateWedding').focus();
					return false;
					
				}
				if((monthnumber == exdate[1]))
				{
					if(exdate[2] < monthday)
					{
						alert('Wedding date must be greater than current date.');
						document.getElementById('txt_DateWedding').focus();
						return false;
						
					}
				}
			}
		}
		else
		{
			alert('Please enter the wedding date.');
			return false;
		}
	}
	if(SelectValidation(Form_Name.txt_state,'State')=='')
	{
		return false;
	}
    else if(SelectValidation(Form_Name.sel_city,'City','','')=='')
    {
        return false;
    }
    else if(GenValidation(Form_Name.txt_zip,'Zip code','','')=='')
	{
		return false;
	}
    else if(GenValidation(Form_Name.txt_pswd,'Password','','')=='')
	{
		return false;
	}
	else if(GenValidation(Form_Name.txt_cpswd,'Verified Password','','')=='')
	{
		return false;
	}
	else if(PassValidation(Form_Name.txt_pswd,Form_Name.txt_cpswd)=='')
	{
		return false;
	}
    else if(document.getElementById('defines_you').value != 21)
	{
		document.getElementById('Div_Confirmation').className = '';
		if(document.getElementById('hid_Submit').value == 'No')
		{
            return false;
		}
        else
        {
            return true;
        }
	
	}
	else if(document.getElementById('defines_you').value == 21)
	{
		document.getElementById('Div_Confirmation').className = 'hidden';
        return true;
	}
}
function regConfirmed(id)
{
	if(id == 1)
	{
		document.getElementById('hid_Submit').value = 'Yes';
		document.Form_Name.submit();
		return true;
	}
	if(id == 2)
	{
		document.getElementById('hid_Submit').value = 'No';
		document.getElementById('Div_Confirmation').className = 'hidden';
		document.getElementById('txt_DateWedding').focus();
		return false;
	}
}

function changeState()
{
	if(document.getElementById('sel_state').value=="0")
	{
		alert('Please select a state from the list');
		return false;
	}
	else
	{
		var state_link=document.getElementById('sel_state').value;
		document.getElementById('urlid').href=state_link+'.html';
	}
	
}
function validateVendWebsite(frm)
{
	if(GenValidation(frm.txt_Title,'Title','','')=='')
	{
		return false;
	}

    if(GenValidation(frm.txt_BusHeading,'Business Heading','','')=='')
	{
		return false;
	}
	
	if(GenValidation(frm.txt_BusAddress,'Business Address','','')=='')
	{
		return false;
	}
	
	if(SelectValidation(frm.sel_state,'state')=='')
	{
		return false;
	}

    if (document.getElementById('tr_city').style.display == '')
    {
        if(SelectValidation(frm.sel_city,'city')=='')
        {
            return false;
        }
    }
	
	if(GenValidation(frm.txt_Phone,'Phone number','','')=='')
	{
		return false;
	}
	
	if(GenValidation(frm.txt_WebSite,'Website','','')=='')
	{
		return false;
	}
	
	if(GenValidation(frm.txt_Email,'Email Id','','')=='')
	{
		return false;
	}
	if(EmailValidation(frm.txt_Email)=='')
	{
		return false;
	}
	
	if(GenValidation(frm.txt_Heading,'Description Heading','','')=='')
	{
		return false;
	}
	
	if(GenValidation(frm.txt_Desc,'Description','','')=='')
	
	{
		return false;
	}
}

function getCitiesById(site_url,val)
{
	Ajax.requestFile = site_url+'/models/Ajax-Server.php?state_id='+val;
	Ajax.onCompletion = displayInfo;
	Ajax.runAJAX();
}

function changePayType(id)
{
	if(id == 'ECHECK')	
	{
		document.getElementById('td_CreditCard').style.display = 'none';
		document.getElementById('td_Echeck').style.display = '';
	}
	if(id == 'CC')	
	{
		document.getElementById('td_CreditCard').style.display = '';
		document.getElementById('td_Echeck').style.display = 'none';
	}
}


function getVendorBillInfo()
{
	if(document.getElementById('chkBillInfo').checked == true)
	{
		
		document.getElementById('txtBillName').value = document.getElementById('hid_txtName').value;
		document.getElementById('txtBusiness').value = document.getElementById('hid_Business').value;
		document.getElementById('sel_country').value = document.getElementById('hid_sel_country').value;
		document.getElementById('txtAddress').value = document.getElementById('hid_txtAddress').value ;
		document.getElementById('sel_state').value = document.getElementById('hid_sel_state').value;
		document.getElementById('txt_city').value = document.getElementById('hid_txt_city').value;
		document.getElementById('txt_Zip').value = document.getElementById('hid_txt_Zip').value;
	}
	else
	{
		document.getElementById('txtBillName').value = '';
		document.getElementById('txtBusiness').value = '';
		document.getElementById('sel_country').value = 0;
		document.getElementById('txtAddress').value = '';
		document.getElementById('txt_city').value = '';
		document.getElementById('sel_state').value = 0;
		document.getElementById('txt_Zip').value = '';
	}
}



function getStatesByCountryId2(site_url,cid)
{
    Ajax.requestFile = site_url+'/models/Ajax-Server.php?country_id2='+cid;
    Ajax.onCompletion = displayInfo;
    Ajax.runAJAX();
}
function validatePayMethod()
{
	frm = document.Form_Name;
	
		if(document.getElementById('sel_PayType').value == 'CC')
		{
			if(GenValidation(frm.txtCardNo,'card number.','','')=='')
			{
				return false;
			}
			if(GenValidation(frm.txtSecCode,'security code.','','')=='')
			{
				return false;
			}
		}
		if(document.getElementById('sel_PayType').value == 'ECHECK')
		{
			if(GenValidation(frm.txtBankName,'bank name.','','')=='')
			{
				return false;
			}
			if(GenValidation(frm.txtBAcNumber,'account number.','','')=='')
			{
				return false;
			}
			if(GenValidation(frm.txtBNameAc,'name on account.','','')=='')
			{
				return false;
			}
			
			if(SelectValidation(frm.sel_AcType,'account type.')=='')
			{
				return false;
			}
			if(GenValidation(frm.txtBRoutNumber,'routing number.','','')=='')
			{
				return false;
			}		
		}
	
		if(GenValidation(frm.fname,'first name.','','')=='')
		{
			return false;
		}
        if(GenValidation(frm.lname,'last name.','','')=='')
		{
			return false;
		}
		if(GenValidation(frm.txtBusiness,'business name.','','')=='')
		{
			return false;
		}
		if(GenValidation(frm.txtAddress,'billing address.','','')=='')
		{
			return false;
		}
		if(SelectValidation(frm.sel_country,'country')=='')
		{
			return false;
		}
		if(SelectValidation(frm.sel_state,'state / province')=='')
		{
			return false;
		}
		if(GenValidation(frm.txt_city,'city','','')=='')
		{
			return false;
		}
		
		if(GenValidation(frm.txt_Zip,'zip code.','','')=='')
		{
			return false;
		}
		
}