/**********************************************************************************************************
	LANG DEFINITION VARS
**********************************************************************************************************/
COUNTRY_NAME_US='USA';
COUNTRY_NAME_CA='Canada';

STATES={
  '7':{
    '':'---',
    'AL':'Alabama',
    'AK':'Alaska',
    'AZ':'Arizona',
    'AR':'Arkansas',
    'CA':'California',
    'CO':'Colorado',
    'CT':'Connecticut',
    'DE':'Delaware',
    'DC':'District of Columbia',
    'GA':'Georgia',
    /*'FL':'Florida',*/
    'HI':'Hawaii',
    'ID':'Idaho',
    'IL':'Illinois',
    'IN':'Indiana',
    'IA':'Iowa',
    'KS':'Kansas',
    'KY':'Kentucky',
    'LA':'Louisiana',
    'ME':'Maine',
    'MD':'Maryland',
    'MA':'Massachusetts',
    'MI':'Michigan',
    'MN':'Minnesota',
    'MS':'Mississippi',
    'MO':'Missouri',
    'MT':'Montana',
    'NE':'Nebraska',
    'NV':'Nevada',
    'NH':'New Hampshire',
    'NJ':'New Jersey',
    'NM':'New Mexico',
    /*'NY':'New York',*/
    'NC':'North Carolina',
    'ND':'North Dakota',
    'OH':'Ohio',
    'OK':'Oklahoma',
    'OR':'Oregon',
    'PA':'Pennsylvania',
    /*'RI':'Rhode Island',*/
    'SC':'South Carolina',
    'SD':'South Dakota',
    'TN':'Tennessee',
    'TX':'Texas',
    'UT':'Utah',
    'VT':'Vermont',
    'VA':'Virginia',
    'WA':'Washington',
    'WV':'West Virginia',
    'WI':'Wisconsin',
    'WY':'Wyoming'
  },
  '16':{ /* Canada */
    '':'---',
    'AB':'Alberta',
    'BC':'Colombie-Britannique',
    'MB':'Manitoba',
    'NB':'Nouveau-Brunswick',
    'NL':'Terre-Neuve-et-Labrador',
    'NS':'Nouvelle-Écosse',
    'ON':'Ontario',
    'PE':'Île-du-Prince-Édouard',
    'QC':'Québec',
    'SK':'Saskatchewan',
    'YT':'Yukon',
    'NT':'Territoires du Nord-Ouest',
    'NU':'Nunavut'
  }
};
STATE=STATES['7']; /* Default value */

GENDER_MISTER='Mr';
GENDER_LADY='Mrs';
GENDER_MISS='Miss';
GENDER_NONE='NA';

RECIPIENT_SERVICE='recipient service';
SECURITY_CODE='The security code';
YOUR_EMAIL='Your email';
YOUR_EMAIL_CONFIRMATION='Your Email confirmation';
YOUR_MESSAGE='Your message';
PLEASE_CHECK='Please check';
SEND_YOUR_MESSAGE='Send Your message ?';
TOMBOLA_CONFIRM='Do you confirm Tombola partherepation : %1$s ?';
STORE_CONFIRM='Do you confirm points redeemed for a prize : %1$s ?';
NUMBER_MAXIMUM_REACHED='You have already selected %1$s numbers';
YOU_MUST_CLICK_ON_A_BANNER='You must click on a banner';
YOU_MUST_SELECT_X_NUMBERS='You must select %1$s numbers !';
NOT_VALID_EMAIL_ADDRESS='Invalid email.';
YOU_MUST_ENTER_PASS='Please enter a new password.';
YOUR_GENDER='Your title';
YOUR_NAME='Your lastname';
YOUR_FIRSTNAME='Your firstname';
YOUR_PASSWORD='Your password (Must have 2 to 10 letters/digits)';
YOUR_PASSWORD_SHORT='Your password';
YOUR_PASSWORD_CONFIRMATION='Your password confirmation';
YOUR_OLD_PASSWORD='Your previous password';
YOUR_POSTAL_ADDRESS='Your address';
YOUR_GSM_NUMBER='Your mobile phone number';
YOUR_PHONE_NUMBER='Your phone number';
YOUR_POSTCODE='Your zipcode';
YOUR_TOWN='Your city';
YOUR_STATE='Your state';
FORM_ERROR='An error as occured.\nPlease delete temporary files from Your browser and try again.\nThank you.';
PLEASE_FILL_HILIGHT_FIELDS='Please complete highlighted fields.';
YOUR_BIRTHDATE='Your date of birth';
PARTNER_SUBSCRIPTION='Partners good deals subscription';
ACCEPT_RULES='Accept Rules and T&Cs';
YOU_NEED_TO_MAKE_A_CHOICE='You need to make a choice.';
INCORRECT_NEW_EMAIL_ADDRESS='Invalid email.';
PRIZE_CHOICE='Prize choice';
EMAIL_FIELDS='email field';
TOO_OLD_BROWSER='Your navigator (internet explorer/firefox version) is too old. Please update new version available. We recommend you to use Firefox : http://www.getfirefox.com/';
LEGAL_NOTES='T&Cs and Private Policy';
LEGAL_NOTES_ALERT="Click on this button and &quot;join and play now!&quot;, your personal details will be transmitted to our company %1$s. Please check our Privacy policy for all details below";
ENDED='Terminé';
DELETE_FAVORITE='Are you sure you want to erase your lucky numbers?';
GRID_SELECT_NUMBER='Please select a grid number';
THE_GRID_NUMBER='Grid number %1$s';
DUPLICATE_GRID_NOT_COMPLETED='Cette grille ne peut pas être dupliquée car elle n\'est pas complète.';
ON_ALL_GRIDS='Sur toutes les grilles';

var lg_formPleaseCheck='Please Check :';
var lg_birthdateDay='Date of birth (day)';
var lg_birthdateMonth='Date of birth (month)';
var lg_birthdateYear='Date of birth (year)';
var lg_gender='Title';
var lg_country='Country';
var fb_pleaseFinish='<img height="11" width="16" alt="Facebook" src="http://img.mediastay.com/core/img/fbLoader.gif">';

/**********************************************************************************************************
	--- DON'T MODIFY BELOW ---
	COUNTRY SPECIFIC CONF
**********************************************************************************************************/
// profile
CIVILITE_SELECT_OPTIONS={'0':'--','1':GENDER_MISTER,'2':GENDER_LADY,'3':GENDER_MISS};
COUNTRY_SELECT_OPTIONS={'7':COUNTRY_NAME_US,'16':COUNTRY_NAME_CA};
BIRTH_SELECT_ORDER={1:'month',2:'day',3:'year'};

// name of play page and delay for tracker
TRACKER_VALID_URL='play.php';
TRACKER_VALID_TIME=3000;

// img sub path (on static server)
PUB_SUBPATH='kingo';

// enabled magic number or not
ENABLED_GRID_MAGIC_NUMBER=false;

// grid per day
GRIDS_PER_DAY=10;

/**********************************************************************************************************
	COUNTRY SPECIFIC FUNCTIONS
**********************************************************************************************************/
function clearPhoneNumber(num,country){
	if(typeof(country)=='undefined') country='7';
	num=num.replace(/[^0-9+]/g,'');
	if(COUNTRIES[country]['code']=='US'||COUNTRIES[country]['code']=='CA'){
	  num=num.replace(/^(\+|00)1/i,'0');
	}
	num=num.replace(/[^0-9]/g,'');
	return(num);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function isValidGsmNumber(num,country){
	if(typeof(country)=='undefined') country='7';
	if(COUNTRIES[country]['code']=='US'||COUNTRIES[country]['code']=='CA')
		return(num.match(/^[0-9]{10}$/i));
	else return(true);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function isValidPhoneNumber(num,country){
	if(typeof(country)=='undefined') country='7';
	if(COUNTRIES[country]['code']=='US'||COUNTRIES[country]['code']=='CA')
		return(num.match(/^[0-9]{10}$/i));
	else return(true);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function isValidZipCode(zipCode,country){
	var rv=true;
	if(typeof(country)=='undefined') country='7';
	if(COUNTRIES[country]['code']=='US'){
		if(zipCode.match(/^[0-9]{3,5}(-[0-9]{1,6})?$/i)){
			zipCode=zipCode.replace(/-.*$/,'');
			zipCode=zipCode.replace(/^0+/,'');
			zipCode=parseInt(zipCode);
			if(zipCode==96799|| /* American Samoa */
			  (zipCode>=96941&&zipCode<=96944)|| /* Federated States of Micronesia */
			  (zipCode>=32000&&zipCode<=34999)|| /* Florida */
			  (zipCode>=96910&&zipCode<=96932)|| /* Guam */
			  (zipCode>=96960&&zipCode<=96970)|| /* Marshall Islands */
			  (zipCode>=10000&&zipCode<=14999)||zipCode==6390||zipCode==501||zipCode==544|| /* New York */
			  (zipCode>=96950&&zipCode<=96952)|| /* Northern Mariana Islands */
			  zipCode==96940||/* Palau */
			  (zipCode>=600&&zipCode<=799)||(zipCode>=900 && zipCode<=999)|| /* Puerto Rico */
			  (zipCode>=2800&&zipCode<=2999)|| /* Rhode Island */
			  (zipCode>=800&&zipCode<=899)|| /* Virgin Island */
			  (zipCode>=34002&&zipCode<=34078)||(zipCode>=9003&&zipCode<=9898)||(zipCode>=96201&&zipCode<=96562) /* Military mail */
			){
				rv=false;
			}
		}else{
			rv=false;
		}
	}else if(COUNTRIES[country]['code']=='CA'){
	  rv=zipCode.match(/^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/i);
	}
	return rv;
}

/**********************************************************************************************************
	MDSTOOLS EXTEND
**********************************************************************************************************/

if(typeof(MFC)=='undefined'){
	var MFC={};
}
if(typeof(MFC.fieldsTypes)=='undefined'){
	MFC.fieldsTypes={};
}

MFC.fieldsTypes.gsmNumber={ /* A REVOIR ----------------------------------------------------------------------------------------------------------- */
	'regExp':null,
	'check':function(elm){
	        	var v=MU.formTagGetValue(elm);
	        	var rv=(v=='');
	        	var f=elm.form;
	        	if((!rv)&&f.elements['pays']){
	        		var country=MU.formTagGetValue(f.elements['pays']);
	        		v=clearPhoneNumber(v,country);
	        		rv=isValidGsmNumber(v,country);
	        	}
	        	if(rv) MU.formTagSetValue(elm,v);
	        	rv=(elm.readOnly||rv);
	        	return rv;
	        }
};

MFC.fieldsTypes.homeNumber={
	'regExp':null,
	'check':function(elm){
	        	var v=MU.formTagGetValue(elm);
	        	var rv=(v=='');
	        	var f=elm.form;
	        	if((!rv)&&f.elements['pays']){
	        		var country=MU.formTagGetValue(f.elements['pays']);
	        		v=clearPhoneNumber(v,country);
	        		rv=isValidPhoneNumber(v,country);
	        	}
	        	if(rv) MU.formTagSetValue(elm,v);
	        	rv=(elm.readOnly||rv);
	        	return rv;
	        }
};

MFC.fieldsTypes.zipcode={
	'regExp':null,
	'check':function(elm){
	        	var v=MU.formTagGetValue(elm);
	        	var rv=true;
	        	var f=elm.form;
	        	if(f.elements['pays']){
	        		var country=MU.formTagGetValue(f.elements['pays']);
	        		rv=isValidZipCode(v,country);
	        	}else{
	        		v='';
	        	}
	        	if(rv) MU.formTagSetValue(elm,v);
	        	rv=(elm.readOnly||rv);
	        	return rv;
	        }
};

