//check for namepsace presence
if ( typeof ASlite == 'undefined' ) { var ASlite = {}; }

ASlite.init = function () {
	//initialization of each module in namespace
	for (var i in ASlite) {
		if (typeof ASlite[i].init == 'function') {
			ASlite[i].init ();
		}
	}
}
ASlite.prop = {
	tracking_page_name:'',
	tracking_product_info: new Array() //will be array of objects with name qty price
}
ASlite.loc = {
	searchTxt:'',
	you_must_agree:'You must agree to the terms below by checking the box.'
}
ASlite.submitLangForm = function  (langForm) {
	var qString = document.location.search;
	if(qString.indexOf('?')==0){
		qString = qString.substr(1);
	}
	if(qString != "") {
		qArray = qString.split('&');
		for(var i = 0; i < qArray.length; i++){
			if(qArray[i].split('=')[0] != 'language') {
				var hInput = document.createElement('input');
				hInput.type = 'hidden';
				hInput.name = qArray[i].split('=')[0];
				hInput.value = qArray[i].split('=')[1];
				langForm.appendChild(hInput);
			}
		}
	}
	langForm.submit();
}
//add bind function to Function object
Function.prototype.bind = function(obj) {var method = this;var __f;var args = arguments;__f = function() {var newArgs = new Array;for(i=1;sArg=args[i];i++){newArgs[i-1] = sArg;}return method.apply(obj, newArgs);};return __f;}
ASlite.checkSearchForm = function(formObj,searchTxt) {
	// checkes search for on submit for blanks etc
	try{
	var toCheck = document.forms[formObj.id]['keywords'].value;
	toCheck = toCheck.replace(/^\s+|\s+$/g, '');
	}catch(e){}
	if (toCheck == '' || toCheck.length < 1 || toCheck == searchTxt) {
		return false;
	} else {
		return true;
	}
}
ASlite.popUp = function(content, name , params) {
	//  facilitates popup on several pages
	var newwin =  window.open(content, name, 'directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,copyhistory=no,screenY=150,top=150,left=150,resizable=yes,' + params);
	return false;
}
ASlite.cartCookie = {
	init: function(){
	},
	prop: {
		on:false,
		name:'AScartCount',
		domain:''
	},
	drop: function(){
		if (this.prop.on && as.cart_count > 0) {	
		YAHOO.util.Cookie.set(this.prop.name, as.cart_count, {path: '/', domain: this.prop.domain} );
		}
	}
}
ASlite.changeTab = function(containerName,tabName,contentName) {
	if ( document.getElementById(tabName).className != 'boxHead tab' ){
		for (var i = 0; (div = document.getElementById(containerName).getElementsByTagName('div')[i]); i++) {
			if (div.className == "contentOn") {
			div.style.display = 'none';
			div.className = '';
			}
		}
		for (var i = 0; (tab = document.getElementById(containerName).getElementsByTagName('h2')[i]); i++) {
			if (tab.className == "boxHead tab") {
			tab.className = 'boxHead tabOff';
			}
		}
		document.getElementById(tabName).className = 'boxHead tab';
		document.getElementById(contentName).style.display = 'block';
		document.getElementById(contentName).className = 'contentOn';
	}
}
ASlite.featRotator = {
	init: function(){
		if(typeof this.prop.games == 'object'){
		this.start();
		}
	},
	prop:{
		timer:'',
		loopCount:0,
		rotateTime:5*1000,
		games:'',
		gameImgLink:'',
		gameImage:'',
		buttons:'',
		gameTitle:'',
		gameDesc:'',
		gamePlayButton:'',
		gameClass:'',
		rotatorType:'horizontal'
	},
	start: function(){
		for(i=0;this.prop.buttons[i];i++){
			if(this.prop.rotatorType == 'horizontal'){
				try {
				this.prop.buttons[i].src = this.prop.games[i].gameThumb;
				this.prop.buttons[i].alt = this.prop.games[i].gameName;
				this.prop.buttons[i].title = this.prop.games[i].gameName;
				this.prop.buttons[i].className = this.prop.games[i].gameClass;
				(function(iter){this.prop.buttons[iter].onclick = function(){ASlite.featRotator.displayGame(iter, true);}}).call(this,i);
				}catch(e){}
			}else if(this.prop.rotatorType == 'big'){
				try {
				this.prop.buttons[i].innerHTML = this.prop.games[i].shortGameName;
				(function(iter){this.prop.buttons[iter].onclick = function(){ASlite.featRotator.displayGame(iter, true);}}).call(this,i);
				//for lrotator big
				}catch(e){}			
			}
		}
		this.step();
	},
	step: function(){
		this.prop.loopCount = this.prop.loopCount==this.prop.buttons.length?0:this.prop.loopCount;
		this.displayGame(this.prop.loopCount);
		clearTimeout(this.prop.timer);
		this.prop.loopCount++;
		this.prop.timer = setTimeout('ASlite.featRotator.step.apply(ASlite.featRotator)', this.prop.rotateTime);
	},
	displayGame: function(gameOrd, stop){
		var gameObj = this.prop.games[gameOrd];
		try{
			this.prop.gameImgLink.href = gameObj.gameLink;
			this.prop.gameImage.src = gameObj.gameImg;
			this.prop.gameImage.alt = gameObj.gameName;
			this.prop.gameImage.title = gameObj.gameName;
			this.prop.gameImage.className = gameObj.ImgClass;
			this.prop.gameTitle.innerHTML = gameObj.gameName;
			this.prop.gameTitle.href = gameObj.gameLink;
			this.prop.gameDesc.innerHTML = gameObj.gameDesc;
			this.prop.gamePlayButton.innerHTML = gameObj.gameLinkTitle;
			this.prop.gamePlayButton.href = gameObj.gameLink;
		}catch(e){}	
		for(i=0;this.prop.buttons[i];i++){
			//check if its feat big or thumb		
			if(this.prop.buttons[i].parentNode.className.indexOf('thumbNail')!=-1){
				if (i==gameOrd){
					this.prop.buttons[i].parentNode.className = 'thumbNail on';
				}else{
					this.prop.buttons[i].parentNode.className = 'thumbNail';
				}
			}else if(this.prop.buttons[i].className.indexOf('featRotator_button')!=-1){
				if (i==gameOrd){
					this.prop.buttons[i].className = 'featRotator_buttonOn';
				}else{
					this.prop.buttons[i].className = 'featRotator_button';
				}
			}
		}
		/* set rotator to current ord  and stop*/
		if (stop){
			this.prop.loopCount=gameOrd;
			clearTimeout(this.prop.timer);
		}
	}
}
ASlite.jsReplace = {
	init: function(){
		this.email();
		//this.averageStarRating();	
	},
	email: function(){
	// fills in user email on variouse pages
		if (as.customer_email){
			for (var i = 0; (span = document.getElementsByTagName('span')[i]); i++) {
				if (span.className == 'jsReplace_email') {
				span.innerHTML=as.customer_email;
				}
				if (span.className == 'jsReplace_emailName') {
				span.innerHTML=as.customer_email.split('@')[0];
				}
			}
		}
	},
	
	averageStarRating: function(){
	//fills in star ratings on pages [in_progress]
		if (as.customer_email){
			for (var i = 0; (span = document.getElementsByTagName('span')[i]); i++) {
				if (span.className == 'jsReplace_starRating') {
					//star rating modification
				}
			}
		}
	}
}
ASlite.cartDeleteItem = function(frm,itemId){
	frm = document.getElementsByName(frm)[0];
	var item = document.getElementsByName(itemId)[0];
	var delItem = document.createElement('input');
	delItem.type = "hidden";
	delItem.value = item.value;
	delItem.name = 'cart_delete'+item.name.substr(11);
	frm.appendChild(delItem);
	frm.submit();
}
ASlite.submitOnce = {
	init: function(){
		//expose function outside namespace on checkout confirm page
		if (document.checkout_confirmation){
			window.submitOnce = function(){return ASlite.submitOnce.check()};
		}
	},
	prop: {
		submitted:false
	},
	check: function() {
		if (!this.prop.submitted){
		this.prop.submitted=true;
		return true;
		}else{
		return false ;
		}
	}
}
ASlite.hoverBox = {
// load hoverboxes for variouse things
	show: function(target, offsetX, offsetY, overlayClass) {
		if (overlayClass == null){var overlayClass='gameOverlay'}
		var overlayObjId = target.id + 'Overlay';
		var overlayObj = document.getElementById(overlayObjId);
		if (!overlayObj) {
			// if overlays doesnt exist, create them
			var tbody = document.getElementsByTagName('body')[0];
			var tnode = document.createElement('div');
			tnode.className =  overlayClass + ' ' + overlayClass +'Left';
			tnode.id = overlayObjId;
			tbody.appendChild(tnode);
			//switch fading off for IE
			if (YAHOO.env.ua.ie > 0) {
			target.gameOverlay = new YAHOO.widget.Overlay(overlayObjId, { xy:[0,0],visible:false });
			}else{
			target.gameOverlay = new YAHOO.widget.Overlay(overlayObjId, { xy:[0,0],visible:false, effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.15} });
			}
			target.gameOverlay.render();
			overlayObj = document.getElementById(overlayObjId);
			//content must be provided in this relative path
			contentDiv = YAHOO.util.Dom.getElementsByClassName('overlayContent', 'div', target.parentNode.parentNode);
			content = contentDiv[0].innerHTML;
			overlayObj.innerHTML = content;
		}
		viewportX = YAHOO.util.Dom.getViewportWidth();
		targetPos = YAHOO.util.Dom.getXY(target.id);
		overlayWidth = parseInt(YAHOO.util.Dom.getStyle(overlayObjId, 'width'))+parseInt(YAHOO.util.Dom.getStyle(overlayObjId, 'padding-left'))+parseInt(YAHOO.util.Dom.getStyle(overlayObjId, 'padding-right'));
		if(targetPos[0] + overlayWidth + 100 > viewportX) {
			overlayObj.className = overlayClass + ' ' + overlayClass +'Right';
			overPos = [targetPos[0]-overlayWidth-2,targetPos[1]-offsetY];
		} else {
			overlayObj.className = overlayClass;
			overPos = [targetPos[0]+offsetX,targetPos[1]-offsetY];
		}
		target.gameOverlay.moveTo(overPos[0], overPos[1]);
		target.gameOverlay.show();
	},
	
	hide: function(target) {
		target.gameOverlay.hide();
	}
}
ASlite.securom = {
	//securom checkbox(modified for reeading ors data)
	init: function(){
		this.showSecuromCheckbox();
	},
	prop: {
		gameDetected:false
	},
	showSecuromCheckbox: function() {
	//check prodcut array is securomItems is populated
		if (this.prop.gameDetected){
			//found game
			document.getElementById('securom_agree').checked == false;
			document.getElementById('securomCheckbox').style.display = 'block';
			// adds onclick specificaly to button "proceedchecout"
			document.getElementById('proceedcheckout').onclick = function(){return ASlite.cartcheck.checkProducts();}
		}
	}
}
ASlite.agecheck = {
	init: function(){
		this.showAgeCheckbox();
	},
	prop: {
		ageDetected:false
	},
	showAgeCheckbox: function () {
		if (this.prop.ageDetected){
			document.getElementById('age_agree').checked = false;
			document.getElementById('ageCheckbox').style.display = 'block';
			document.getElementById('proceedcheckout').onclick = function(){return ASlite.cartcheck.checkProducts();}
		}
	}
}
ASlite.cartcheck = {
	init: function(){
		try{
			if ((ASlite.securom.prop.gameDetected && document.getElementById('securom_agree').checked == false) || (ASlite.agecheck.prop.ageDetected && document.getElementById('age_agree').checked == false)){
			} else {
				document.getElementById('proceedcheckout').onclick = function(){return 1;}
			}
		}catch(e){}
	},
	prop: {
		checkTrue:false
	},
	checkProducts: function() {
		if ((ASlite.securom.prop.gameDetected && document.getElementById('securom_agree').checked == false) || (ASlite.agecheck.prop.ageDetected && document.getElementById('age_agree').checked == false)){
			alert(ASlite.loc.you_must_agree);
			return false;
		} else {
			return true;
		}
	}
}

ASlite.populateContent = function(sUrl,objId) {
	//general function to load remote data into an object(AJAX)
	var callback = { success: function(o) {document.getElementById(objId).innerHTML = o.responseText;} , failure: function(o) {} }
	var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);
}
ASlite.prodUserRating = {
	//on product page funtions to manage user ratings
	prop: {
		userRating:0,
		is_logged_in:'',
		product_info_rating_ajax_link:'',
		user_rating_rategame_link:'',
		ratingImg:'',
		update_rating_ajax_link:''
		},
	
	populateUserRating: function() {
		if (this.prop.is_logged_in == '1') {
			var callback = { success: function(o) {document.getElementById('thisUserRating').innerHTML = o.responseText;ASlite.prodUserRating.populateThisUserRating(true);} , failure: function(o) {} }
			var sUrl = this.prop.product_info_rating_ajax_link;
			var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);
		} else {
			window.location=this.prop.user_rating_rategame_link;
		}
	},
	
	getAverageRating: function(){
		var rating = parseInt(this.prop.ratingImg.split('star_')[1].split('.gif')[0]);
		if(rating > 0) {
		document.getElementById('gameDetail_averageRating').style.width = rating * 20 + 'px';
		}
	},
	
	rateGame: function(rating) {
		this.prop.userRating = rating;
		var callback = { success: function(o) {ASlite.prodUserRating.populateThisUserRating(false);} , failure: function(o) {} }
		var sUrl = this.prop.update_rating_ajax_link + '&rating=' + rating;
		var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);
	},
	
	populateThisUserRating: function(grab){
	//if grab is true, it updates the userrating from reported rating on remote page
		if (grab){this.prop.userRating = document.getElementById('passThrough_thisUserRating').value;}
		if(this.prop.userRating > 0) {
			document.getElementById('gameDetail_thisUserRating').style.width = this.prop.userRating * 20 + 'px';
		}
	}
}			
ASlite.displayScreenShot = function(toDisplay) {
	//rotate product page screenshots on mouseover.
	//need to intigrate ET version [in_progress]
	try{
	document.getElementById('gamesDetail_screenShot1').style.display = 'none';
	document.getElementById('gamesDetail_screenShot2').style.display = 'none';
	document.getElementById('gamesDetail_screenShot3').style.display = 'none';
	}catch(e){}
	if (toDisplay != null) {
	document.getElementById('gamesDetail_gameInfoBottomText').style.display = 'none';
	document.getElementById(toDisplay).style.display = 'block';
	} else {
	document.getElementById('gamesDetail_gameInfoBottomText').style.display = 'block';
	}
}
ASlite.leaderBoard = {
	init: function(){},
	prop: {
		containerObjId:'leaderboard', //ID of table to be populated with leaderboard info
		gameID:'',
		gameLic:'',
		delay:5*60*1000, //five minutes
		repeat:24, // for 2 hours(24 times)
		firstFlag:true,
		maxScoresShown:50
	},
	populate: function(score){
		//no callback for refresh
		if (score == 'refresh'){
			var sUrl2 = '/app/community/leaderboard/' + score + '?products_id=' + this.prop.gameID + '&products_licensing_offering=' + this.prop.gameLic;
			var callback = {success:function(o){} ,failure:function(o){}};
			var transaction2 = YAHOO.util.Connect.asyncRequest('GET', sUrl2, callback);		
		}else{
			var sUrl = '/app/community/leaderboard/' + score + '?products_id=' + this.prop.gameID + '&products_licensing_offering=' + this.prop.gameLic;
			var callback = {success:ASlite.leaderBoard.parse ,failure:ASlite.leaderBoard.fail};
			//force request header to xml, becusae feed is improper xml.
			YAHOO.util.Connect.initHeader('Content-Type','text/xml', false);
			YAHOO.util.Connect.setDefaultXhrHeader(false);
			var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
			YAHOO.util.Connect.resetDefaultHeaders();
		}
	},
	parse: function(o){
		try {
			var entries = o.responseXML.getElementsByTagName("Entry");
			// loop through <item> elements, and add each nested
			// <title> element to Topics select element
			//clear tbody(must use dom, not inner html
			var holder = document.getElementById(ASlite.leaderBoard.prop.containerObjId).getElementsByTagName('tbody')[0];
			while(holder.hasChildNodes()){
				holder.removeChild(holder.lastChild);
			}
			var scoresShown = entries.length<=ASlite.leaderBoard.prop.maxScoresShown?entries.length:ASlite.leaderBoard.prop.maxScoresShown;
			for (var i = 0; i < scoresShown; i++) {
				var evenOdd = i%2==0?'even':'';
				var tr = document.createElement('tr');
				tr.className = evenOdd;
				var td1 = document.createElement('td');
				td1.className = 'rank';
				td1.innerHTML = entries[i].getElementsByTagName('Rank')[0].childNodes[0].nodeValue;
				var td2 = document.createElement('td');
				td2.className = 'username';
				td2.innerHTML = entries[i].getElementsByTagName('Screenname')[0].childNodes[0].nodeValue;
				var td3 = document.createElement('td');
				td3.className = 'score';
				td3.innerHTML = entries[i].getElementsByTagName('Score')[0].childNodes[0].nodeValue;
				tr.appendChild(td1);
				tr.appendChild(td2);
				tr.appendChild(td3);
				document.getElementById(ASlite.leaderBoard.prop.containerObjId).getElementsByTagName('tbody')[0].appendChild(tr);
			}
		} catch (e) {
			try{document.getElementById(ASlite.leaderBoard.prop.containerObjId).innerHTML = '<tr><td class="message">Not available</td></tr>';}catch(e){}
		}
	},
	fail: function(o){
		try{document.getElementById(ASlite.leaderBoard.prop.containerObjId).innerHTML = '<tr><td class="message">Not available</td></tr>';}catch(e){}
	},
	timer: function(){
		if (this.prop.repeat > 0){
			// make support other buttons later now, set to only all_time
			if(!this.prop.firstFlag){this.populate('refresh');}
			this.populate('all_time');
			this.prop.repeat--;
			this.prop.firstFlag = false;
			var refresh = setTimeout('ASlite.leaderBoard.timer()',this.prop.delay);
		}
		
	}
}
ASlite.ads = {
	//add tags and functionality
	prop: {
		thirdParty:'',
		gameID:'',
		pageName:'',
		publisher:'',
		genre:'',
		isCustom:false,
		adRefreshTime:5*60*1000, //refreshtime in microseconds
		ord:Math.random()*100000000000000000,
		interAdTime:15*1000 //used in ASlite.webGame
	},

	display: function() {
		if(!this.prop.isCustom){
			try {
				document.getElementById('ad300x250').src = 'http://ad.doubleclick.net/adi/gamesco.syndication/'+this.prop.thirdParty+'/'+this.prop.pageName+'/'+this.prop.gameID+';channel='+this.prop.thirdParty+';page='+this.prop.pageName+';game='+this.prop.gameID+';dev='+this.prop.publisher+';genre='+this.prop.genre+';age=;gender=;dcopt=ist;sz=300x250;ord='+this.prop.ord;
			} catch(e) {}	
			try {
				document.getElementById('ad728x90').src = 'http://ad.doubleclick.net/adi/gamesco.syndication/'+this.prop.thirdParty+'/'+this.prop.pageName+'/'+this.prop.gameID+';channel='+this.prop.thirdParty+';page='+this.prop.pageName+';game='+this.prop.gameID+';dev='+this.prop.publisher+';genre='+this.prop.genre+';age=;gender=;dcopt=ist;sz=728x90;ord='+this.prop.ord;
			} catch(e) {}
			this.prop.ord = Math.random()*100000000000000000;
		}
	},
	
	refresh: function() {
		try {
			this.display();
		} catch(e) {}
		setTimeout( 'ASlite.ads.refresh()', this.prop.adRefreshTime);
	},
	
	interAd: function() {
		if(!this.prop.isCustom){
			try {
				document.getElementById('interAd').src = 'http://ad.doubleclick.net/adi/gamesco.syndication/'+this.prop.thirdParty+'/'+this.prop.pageName+'/'+this.prop.gameID+';channel='+this.prop.thirdParty+';page='+this.prop.pageName+';game='+this.prop.gameID+';dev='+this.prop.publisher+';genre='+this.prop.genre+';age=;gender=;dcopt=ist;sz=300x250;ord='+this.prop.ord;
			} catch(e) {}
		}
	}
}
ASlite.webGame = {
	//load webgame and set interad cookie
	prop: {
		gameID:'',
		gameSrc:'',
		gameWidth:'640', //height and width not varied right now
		gameHeight:'480',
		interAdTime:ASlite.ads.prop.interAdTime,
		cookieTimeout:2 //in minutes
	},
	
	start: function(){
		document.getElementById('webgame_interAd').style.display = 'none';
		document.getElementById('webgame_game').style.display = 'block';
		document.getElementById('webgame_gameFrame').style.width = this.prop.gameWidth+'px';
		document.getElementById('webgame_gameFrame').style.height = this.prop.gameHeight+'px';
		document.getElementById('webgame_gameFrame').src = this.prop.gameSrc;
		if(document.cookie.indexOf("wginit='"+this.prop.gameID+"'") == -1){
			var exp = new Date();
			exp.setMinutes(exp.getMinutes()+this.prop.cookieTimeout);
			YAHOO.util.Cookie.set('wginit',this.prop.gameID,{expires:exp});
		}
	},
	
	checkCookie: function(){
		if(document.cookie.indexOf("wginit='"+this.prop.gameID+"'") != -1){
			this.start();
		} else {
			setTimeout('ASlite.webGame.start();',this.prop.interAdTime);
		}
	}
}
ASlite.checkoutValidate = {
	init: function() {
		//set functions available outside namespace if checkout form exists
		if(document.one_page_checkout){
			window.ShowOrHideStateMenu = function(){return ASlite.checkoutValidate.showOrHideStateMenu()};
			window.ShowOrHideShippingStateMenu = function(){return ASlite.checkoutValidate.showOrHideShippingStateMenu()};
			window.ShowOrHiddenGiftFields = function(){return ASlite.checkoutValidate.showOrHiddenGiftFields()};
			window.setShippingState = function(){return ASlite.checkoutValidate.setShippingState()};
			window.setState = function(){return ASlite.checkoutValidate.setState()};
			window.check_addresses = function(theForm){return ASlite.checkoutValidate.check_addresses(theForm)};
			window.copy_shipping = function(theCheckBox){return ASlite.checkoutValidate.copy_shipping(theCheckBox)};
			
			//setup state menu
			this.setupStateMenu();
			
			//these functions probablynot needed
			window.selectRowEffect_ship = function(object, buttonSelect){ASlite.checkoutValidate.selectRowEffect_ship(object, buttonSelect)};
			window.rowOverEffect_ship = function(object){ASlite.checkoutValidate.rowOverEffect(object)};
			window.rowOutEffect_ship = function(object){ASlite.checkoutValidate.rowOutEffect(object)};
			window.selectRowEffect_paym = function(object, buttonSelect){ASlite.checkoutValidate.selectRowEffect_paym(object, buttonSelect)};
			window.rowOverEffect_paym = function(object){ASlite.checkoutValidate.rowOverEffect(object)};
			window.rowOutEffect_paym = function(object){ASlite.checkoutValidate.rowOutEffect(object)};
		}
	},
	
	prop: {
		submitted: false,
		first_element: false,
		selected_shipping:false,
		selected_payment:false
	},
	
	loc: {
		errors_have_occured:"Errors have occured during the process of your form.\n \n Please make the following corrections:\n \n ",
		already_submitted:"This form has already been submitted. Please press Ok and wait for this process to be completed.",
		email_must_be_identical:"* E-mail and e-mail confirmation fields must be idential.\n ",
		first_name_character:"* The 'First Name' entry must have at least 1 characters.\n ",
		last_name_character:"* The 'Last Name' entry must have at least 1 characters.\n ",
		street_address_character:"* The 'Street Address' entry must have at least 1 characters.\n ",
		shipping_address_character:"* The 'Shipping Street Address' entry must have at least 1 characters.\n ",
		postcode_character:"* The 'Post Code' entry must have at least 1 characters.\n ",
		shipping_postcode_character:"* The 'Shipping Post Code' entry must have at least 1 characters.\n ",
		city_character:"* The 'City' entry must have at least 1 characters.\n ",
		shipping_city_character:"* The 'Shipping City' entry must have at least 1 characters.\n ",
		state_must_be_selected:"* The 'State' entry must be selected. \n ",
		shipping_state_must_be_selected:"* The 'Shipping State' entry must be selected.\n ",
		country_must_be_selected:"* The 'Country' entry must be selected.\n ",
		shipping_country_must_be_selected:"* The 'Shipping Country' entry must be selected.\n ",
		email_6_character:"* The 'E-Mail Address' entry must have at least 6 characters.\n ",
		incorrect_email:"* Incorrect E-Mail address\n",
		word_ver_required:"* The 'Word Verification' code is required.",
		cannot_ship_to_country:"We cannot ship to the selected country : ",
		owner_name_3_character:"* The owner's name of the credit card must be at least 3 characters.\n ",
		card_number_character:"* The credit card number must be at least 10 characters.\n ",
		invalid_code:"* Invalid security code",
		AMEX_code_4_digits:"* AMEX cards must have a security code of 4 digits",
		card_security_required:"* The credit card security code is obligatory except for Switch/Solo cards.\n",
		account_number_character:"* The account number must be at least 7 characters.\n ",
		bank_name_character:"* The bank name must be at least 8 characters.\n ",
		bank_city_character:"* The bank city must be at least 1 characters.\n ",
		bank_code_character:"* The bank code must be at least 8 characters.\n ",
		select_payment:"* Please select a payment method for your order.\n "
	},
	
	setStyle: function(sType, sField, sInputField){
		if (sType == 'normal'){
			document.getElementById(sField).style.fontWeight = 'normal';
			document.getElementById(sField).style.color = 'black';
		}else{
			document.getElementById(sField).style.fontWeight = 'bold';
			document.getElementById(sField).style.color = 'red';
			if (!this.prop.first_element) this.prop.first_element = sInputField;
		}
	},
	
	showOrHideStateMenu: function(){
		if(document.one_page_checkout.country.value==document.one_page_checkout.us_country_code.value){
			document.getElementById('state_txt_row').style.display='none';
			document.getElementById('state_list_row').style.display='';
		}else{
			document.getElementById('state_txt_row').style.display='';
			document.getElementById('state_list_row').style.display='none';
		}
	},

	setupStateMenu: function() {
		this.showOrHideStateMenu();
		if (document.getElementById('ship_country') != null) {
			this.showOrHideShippingStateMenu();
		}
	},

	setState: function(){
		if(document.one_page_checkout.country.value==document.one_page_checkout.us_country_code.value){
			document.one_page_checkout.state.value=document.one_page_checkout.state_list.value;
		}
	},

	showOrHideShippingStateMenu: function(){
		if(document.one_page_checkout.ship_country.value==document.one_page_checkout.us_country_code.value){
			document.getElementById('ship_state_txt_row').style.display='none';
			document.getElementById('ship_state_list_row').style.display='';
		}else{
			document.getElementById('ship_state_txt_row').style.display='';
			document.getElementById('ship_state_list_row').style.display='none';
		}
	},

	setShippingState: function(){
		if(document.one_page_checkout.ship_country.value==document.one_page_checkout.us_country_code.value){
			document.one_page_checkout.ship_state.value=document.one_page_checkout.ship_state_list.value;
		}
	},
	
	showOrHiddenGiftFields: function() {
		var send_as_gift_checkbox = document.getElementById('send_as_gift');
		var gift_fields_div = document.getElementById('gift_fields');
		if (send_as_gift_checkbox.checked == false) {
			gift_fields_div.style.display = 'none';
		}
		else {
			gift_fields_div.style.display = 'block';
		}	
	},
	
	isValidEmail: function(s){
		//this function could be updated to just use a regex
		var flag=true;
		for(var i = 0; i < s.length; i++) {
			var c = s.charAt(i);
			if (c == '@') break;
			if(i==(s.length-1)) flag=false;
		}
		if(i==0) flag=false;
		for(var j = i; j < s.length; j++) {
			var c = s.charAt(j);
			if (c == '.') break;
			if(j==(s.length-1)) flag=false;
		}
		if(j==i) flag=false;
		if(j==(s.length-1)) flag=false;
		return flag;
	},

	check_addresses: function(theForm) {
		var error = false;
		var error_message = this.loc.errors_have_occured;

		if(this.prop.submitted){
			alert( this.loc.already_submitted );
			return false;
		}
		this.prop.first_element = false;

		if(theForm.country.value==theForm.us_country_code.value){
			document.getElementById('state_txt_row').style.display='none';
			document.getElementById('state_list_row').style.display='';
		}else{
			document.getElementById('state_txt_row').style.display='';
			document.getElementById('state_list_row').style.display='none';
		}
		if(theForm.country.value==theForm.us_country_code.value){
			theForm.state.value=theForm.state_list.value;
		}
		var first_name = theForm.firstname.value;
		var last_name = theForm.lastname.value;
		var email_address = theForm.email_address.value;
		var email_address_confirm = theForm.email_address_confirm.value;
		var street_address = theForm.street_address_line1.value;
		var postcode = theForm.postcode.value;
		var city = theForm.city.value;
		if(theForm.gift_email) {
			var gift_email = theForm.gift_email.value;
			var gift_email_confirm = theForm.gift_email_confirm.value;
		}
		if(theForm.ship_firstname) {
			var ship_firstname = theForm.ship_firstname.value;
			var ship_lastname = theForm.ship_lastname.value;
			var ship_street_address = theForm.ship_street_address_line1.value;
			var ship_postcode = theForm.ship_postcode.value;
			var ship_city = theForm.ship_city.value;
		}
		if (theForm.elements['email_address_confirm'].type != "hidden"){
			this.setStyle('normal', 'js_email_confirm', 'email_address_confirm');
			if (email_address_confirm == '' || email_address_confirm != email_address) {
			error_message += this.loc.email_must_be_identical;
			this.setStyle('select', 'js_email_confirm', 'email_address_confirm');
			error = true;
			}
		}
		if (theForm.elements['firstname'].type != "hidden") {
			this.setStyle('normal', 'js_firstname', 'firstname');
			if (first_name == '' || first_name.length < 1) {
			error_message += this.loc.first_name_character;
			this.setStyle('select', 'js_firstname', 'firstname');
			error = true;
			}
		}
		if (theForm.elements['lastname'].type != "hidden") {
			this.setStyle('normal', 'js_lastname', 'lastname');
			if (last_name == '' || last_name.length < 1) {
			error_message += this.loc.last_name_character;
			this.setStyle('select', 'js_lastname', 'lastname');
			error = true;
			}
		}
		if (theForm.elements['street_address_line1'].type != "hidden") {
			this.setStyle('normal', 'js_street', 'street_address_line1');
			if (street_address == '' || street_address.length < 1) {
			this.setStyle('select', 'js_street', 'street_address_line1');
			error_message += this.loc.street_address_character;
			error = true;
			}
		}
		if (theForm.elements['postcode'].type != "hidden") {
			this.setStyle('normal', 'js_postcode', 'postcode');
			if (postcode == '' || postcode.length < 1) {
			this.setStyle('select', 'js_postcode', 'postcode');
			error_message += this.loc.postcode_character;
			error = true;
			}
		}
		if (theForm.elements['city'].type != "hidden") {
			this.setStyle('normal', 'js_city', 'city');
			if (city == '' || city.length < 1) {
			error_message += this.loc.city_character;
			this.setStyle('select', 'js_city', 'city');
			error = true;
			}
		}
		// State text input field hidden
		if (document.getElementById('state_txt_row').style.display == 'none') {
			// Check state list input field
			this.setStyle('normal', 'js_state', 'state_list');
			if ( theForm.state_list.value == '' ) {
			this.setStyle('select', 'js_state', 'state_list');
			error_message += this.loc.state_must_be_selected;
			error = true;
			}
		}
		// State list input field hidden
		if (document.getElementById('state_list_row').style.display == 'none') {
			// Check state text input field
			this.setStyle('normal', 'js_state', 'state');
			if ((theForm.state.value == '' || theForm.state.value.length < 2 || theForm.state.value == '-- Select Above --') ) {
			this.setStyle('select', 'js_state', 'state');
			error_message += this.loc.state_must_be_selected;
			error = true;
			}
		}
		if (theForm.elements['country'].type != "hidden") {
			this.setStyle('normal', 'js_country', 'country');
			if (theForm.country.value == 0) {
			this.setStyle('select', 'js_country', 'country');
			error_message += this.loc.country_must_be_selected;
			error = true;
			}
		}
		if(theForm.elements['ship_street_address_line1']) {
			if (theForm.elements['ship_firstname'].type != "hidden") {
				this.setStyle('normal', 'js_ship_firstname', 'ship_firstname');
				if (ship_firstname == '' || ship_firstname.length < 1) {
				error_message += this.loc.first_name_character;
				this.setStyle('select', 'js_ship_firstname', 'ship_firstname');
				error = true;
				}
			}
			if (theForm.elements['ship_lastname'].type != "hidden") {
				this.setStyle('normal', 'js_ship_lastname', 'ship_lastname');
				if (ship_lastname == '' || ship_lastname.length < 1) {
				error_message += this.loc.last_name_character;
				this.setStyle('select', 'js_ship_lastname', 'ship_lastname');
				error = true;
				}
			}
			if (theForm.elements['ship_street_address_line1'].type != "hidden") {
				this.setStyle('normal', 'js_ship_street_address', 'ship_street_address_line1');
				if (ship_street_address == '' || ship_street_address.length < 1) {
				this.setStyle('select', 'js_ship_street_address', 'ship_street_address_line1');
				error_message += this.loc.shipping_address_character;
				error = true;
				}
			}
			if (theForm.elements['ship_postcode'].type != "hidden") {
				this.setStyle('normal', 'js_ship_postcode', 'ship_postcode');
				if (ship_postcode == '' || ship_postcode.length < 1) {
				this.setStyle('select', 'js_ship_postcode', 'ship_postcode');
				error_message += this.loc.shipping_postcode_character;
				error = true;
				}
			}
			if (theForm.elements['ship_city'].type != "hidden") {
				this.setStyle('normal', 'js_ship_city', 'city');
				if (ship_city == '' || ship_city.length < 1) {
				error_message += this.loc.shipping_city_character;
				this.setStyle('select', 'js_ship_city', 'city');
				error = true;
				}
			}
			if (theForm.elements['ship_state'].type != "hidden") {
				this.setStyle('normal', 'js_ship_state1', 'ship_state');
				this.setStyle('normal', 'js_ship_state2', 'ship_state');
				if (theForm.ship_state.value == '' || theForm.ship_state.value.length < 2 ) {
				this.setStyle('select', 'js_ship_state1', 'ship_state');
				this.setStyle('select', 'js_ship_state2', 'ship_state');
				error_message += this.loc.shipping_state_must_be_selected;
				error = true;
				}
			}
			if (theForm.elements['ship_country'].type != "hidden") {
				this.setStyle('normal', 'js_ship_country', 'ship_country');
				if (theForm.ship_country.value == 0) {
				this.setStyle('select', 'js_ship_country', 'ship_country');
				error_message += this.loc.shipping_country_must_be_selected;
				error = true;
				}
			}
		}
		if(theForm.elements['send_as_gift'] && theForm.elements['send_as_gift'].checked == true) {
			if (theForm.elements['gift_email'].type != "hidden") {
				this.setStyle('normal', 'js_gift_email', 'gift_email');
				if (gift_email == '' || gift_email.length < 6) {
				this.setStyle('select', 'js_gift_email', 'gift_email');
				error_message += this.loc.email_6_character;
				error = true;
				}
				else if(!this.isValidEmail(gift_email)) {
				this.setStyle('select', 'js_gift_email', 'gift_email');
				error_message += this.loc.incorrect_email;
				error = true;
				}
			}
			if (theForm.elements['gift_email_confirm'].type != "hidden") {
				this.setStyle('normal', 'js_gift_email_confirm', 'gift_email_confirm');
				if (gift_email_confirm == '' || gift_email_confirm != gift_email) {
				this.setStyle('select', 'js_gift_email_confirm', 'gift_email_confirm');
				error_message += this.loc.email_must_be_identical;
				error = true;
				}
			}
		}
		if (theForm.elements['email_address'].type != "hidden") {
			this.setStyle('normal', 'js_email', 'email_address');
			if (email_address == '' || email_address.length < 6) {
			this.setStyle('select', 'js_email', 'email_address');
			error_message += this.loc.email_6_character;
			error = true;
			}
		}
		if (theForm.elements['captcha'] && theForm.elements['captcha'].type != "hidden"){
			this.setStyle('normal', 'js_captcha', 'captcha');
			if (theForm.elements['captcha'].value == '') {
			error_message += this.loc.word_ver_required;
			this.setStyle('select', 'js_captcha', 'captcha');
			error = true;
			}
		}
		if (error) {
			if (this.prop.first_element != false){
			theForm[this.prop.first_element].focus();
			//alert(this.prop.first_element);
			//document.getElementById(this.prop.first_element).focus();
			}
			alert(error_message);
			return false;
		} else {
			if (!this.check_form()){
				return false;
			}
			this.prop.submitted = true;
			return true;
		}
	},

	copy_shipping: function(theCheckBox) {
		var f = theCheckBox.form;
		if (theCheckBox.checked){
			if(f.ship_firstname) {
				f.ship_firstname.value = f.firstname.value;
				f.ship_lastname.value = f.lastname.value;
				f.ship_street_address_line1.value = f.street_address_line1.value;
				f.ship_city.value = f.city.value;
				if(f.country.value!='223'){
				  f.ship_state.value = f.state.value;
				}else{
				  f.ship_state.value = f.state_list.value;
				  f.ship_state_list.value = f.state_list.value;
				}
				f.ship_postcode.value = f.postcode.value;
				f.ship_country.value = '';

				for(i=0;i<f.ship_country.length;i++){
					if(f.ship_country.options[i].value == f.country.options[f.country.selectedIndex].value) {
						f.ship_country.value = f.country.options[f.country.selectedIndex].value;
					}
				}
				if(f.ship_country.value==''){
					c_name = f.country.options[f.country.selectedIndex].text;
					alert(this.loc.cannot_ship_to_country + c_name);
				}
			}
		}
		else{
			if(f.ship_firstname) {
				f.ship_firstname.value = '';
				f.ship_lastname.value = '';
				f.ship_street_address_line1.value = '';
				f.ship_city.value = '';
				f.ship_state.value = '';
				f.ship_postcode.value = '';
				f.ship_country.value = '';
			}
		}
	},

	selectRowEffect_ship: function(object, buttonSelect) {
		if (!this.prop.selected_shipping) {
			this.prop.selected_shipping = document.getElementById('defaultSelected_ship');
		}
		if (this.prop.selected_shipping){this.prop.selected_shipping.className = 'moduleRow'};
		object.className = 'moduleRowSelected';
		this.prop.selected_shipping = object;
		// one button is not an array
		if (document.one_page_checkout.shipping[0]) {
			document.one_page_checkout.shipping[buttonSelect].checked=true;
		} else {
			document.one_page_checkout.shipping.checked=true;
		}
	},

	selectRowEffect_paym: function(object, buttonSelect) {
		if (!this.prop.selected_payment) {
			this.prop.selected_payment = document.getElementById('defaultSelected_paym');
		}
		if (this.prop.selected_payment){this.prop.selected_payment.className = 'moduleRow'};
		object.className = 'moduleRowSelected';
		this.prop.selected_payment = object;
		// one button is not an array
		if (document.one_page_checkout.payment[0]) {
			document.one_page_checkout.payment[buttonSelect].checked=true;
		} else {
			document.one_page_checkout.payment.checked=true;
		}
	},

	rowOverEffect: function(object) {
		if (object.className == 'moduleRow') object.className = 'moduleRowOver';
	},

	rowOutEffect: function(object) {
		if (object.className == 'moduleRowOver') object.className = 'moduleRow';
	},

	check_form: function() {
		var error = false;
		var error_message = this.loc.errors_have_occured;
		var coupon_code = "";
		var payment_value = null;
		if(document.one_page_checkout.gv_redeem_code != null) {
			coupon_code = document.one_page_checkout.gv_redeem_code.value;
		}
		if ((document.one_page_checkout.cot_gv != null && document.one_page_checkout.cot_gv != 'undefined') && document.one_page_checkout.cot_gv.checked){
			return true;
		}
		if (document.one_page_checkout.payment.length) {
			for (var i=0; i<document.one_page_checkout.payment.length; i++) {
				if (document.one_page_checkout.payment[i].checked) {
					payment_value = document.one_page_checkout.payment[i].value;
				}
			}
		} else if (document.one_page_checkout.payment.checked) {
			payment_value = document.one_page_checkout.payment.value;
		} else if (document.one_page_checkout.payment.value) {
			payment_value = document.one_page_checkout.payment.value;
		}
		//Code for Parse credit cards numbers  and relative information about it rather than submit all the user information to the payment gateway without  advertise to the end user about errors.
		//Each pay.gateway will check again the c. card data and will warning for errors if found.
		if (payment_value == "bibit") {
			var cc_owner = document.one_page_checkout.bibit_cc_owner.value;
			cc_owner=cc_owner.replace(/^\s+/, "");
			cc_owner=cc_owner.replace(/\s+$/, "");
			var cc_number = document.one_page_checkout.bibit_cc_number.value;
			cc_number=cc_number.replace(/^\s+/, "");
			cc_number=cc_number.replace(/\s+$/, "");
			var cc_checkcode = document.one_page_checkout.bibit_cc_checkcode.value;
			cc_checkcode=cc_checkcode.replace(/^\s+/, "");
			cc_checkcode=cc_checkcode.replace(/\s+$/, "");
			var cc_issue = "";
			if (document.one_page_checkout.bibit_cc_issue) {
				document.one_page_checkout.bibit_cc_issue.value;
				cc_issue=cc_issue.replace(/^\s+/, "");
				cc_issue=cc_issue.replace(/\s+$/, "");
			}
			if (cc_owner == "" || cc_owner.length < 3) {
				error_message += this.loc.owner_name_3_character;
				error = true;
			}
			if (cc_number == "" || cc_number.length < 10) {
				error_message += this.loc.card_number_character;
				error = true;
			}
			if(! cc_checkcode.match(/^[0-9]*$/)) {
				error_message += this.loc.invalid_code; 
				error = true;
			}
			//AMEX validation:
			if (Number(cc_number.length) >=2 && (cc_number.substring(0,2)=="34" || cc_number.substring(0,2)=="37")) {   
				if(Number(cc_checkcode.length) != 4) { 
					error_message += this.loc.AMEX_code_4_digits; 
					error = true;
				}
			}    
			var is_switch_solo = false;
			if((cc_number.match(/^49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\d{10}(\d{2,3})?$/)) || 
			(cc_number.match(/^564182\d{10}(\d{2,3})?$/)) ||
			(cc_number.match(/^6(3(33[0-4][0-9])|759[0-9]{2})\d{10}(\d{2,3})?$/)) ||
			(cc_number.match(/^6(3(34[5-9][0-9])|767[0-9]{2})\d{10}(\d{2,3})?$/)) ) {
				is_switch_solo = true;
			}
			if (!is_switch_solo&& cc_checkcode.length <  3 && cc_issue == "") {
				error_message += this.loc.card_security_required;
				error = true;            
			}
		}
		if (payment_value == "bibit_elv") {
			var first_name = document.one_page_checkout.bibit_elv_name.value;
			var account_number = document.one_page_checkout.bibit_elv_account_number.value;
			var bank_name = document.one_page_checkout.bibit_elv_bank_name.value;
			var bank_location = document.one_page_checkout.bibit_elv_bank_location.value;
			var bank_code = document.one_page_checkout.bibit_elv_bank_code.value;
			if (first_name == "" || first_name.length < 3) {
				error_message += this.loc.owner_name_3_character;
				error = true;
			}
			if (account_number == "" || account_number.length < 7) {
				error_message += this.loc.account_number_character;
				error = true;
			}
			if (bank_name == "" || bank_name.length < 8) {
				error_message += this.loc.bank_name_character;
				error = true;
			}
			if (bank_location == "" || bank_location.length < 1) {
				error_message += this.loc.bank_city_character;
				error = true;
			}
			if (bank_code == "" || bank_code.length < 8) {
				error_message += this.loc.bank_code_character;
				error = true;
			}
		}
		if (payment_value == null && !this.prop.submitted && coupon_code == "") {
			error_message += this.loc.select_payment;
			error = true;
		}
		if (error && !this.prop.submitted) {
			alert(error_message);
			return false;
		} else {
			return true;
		}
	}
}
ASlite.accountValidate = {
	init: function() {
		//expose function outside namespace(not sure if it is used somewhere else
		//window.check_form = function(form_name){return ASlite.accountValidate.check_form(form_name)}
	},
	
	prop: {
		form:'',
		submitted:false,
		error:false,
		error_message:''
	},
	
	loc: {
		has_been_submitted:"This form has already been submitted. Please press Ok and wait for this process to be completed.",
		errors_have_occured:"Errors have occured during the process of your form.\n \n Please make the following corrections:\n \n ",
		first_name_character:"Your First Name must contain a minimum of 1 characters.",
		last_name_character:"Your Last Name must contain a minimum of 1 characters.",
		email_character:"Your E-Mail Address must contain a minimum of 6 characters.",
		street_address_character:"Your Street Address must contain a minimum of 1 characters.",
		post_code_character:"Your Post Code must contain a minimum of 1 characters.",
		city_character:"Your City must contain a minimum of 1 characters.",
		state_character:"Your State must contain a minimum of 2 characters.",
		email_must_be_identical:"E-mail and e-mail confirmation fields must be idential.",
		password_character:"Your Password must contain a minimum of 4 characters.",
		password_must_match:"The Password Confirmation must match your Password.",
		email_must_match:"The E-mail Confirmation must match your E-mail.",
		password_not_empty:"Password fields should not be empty.",
		email_not_empty:"The Email fields should not be empty.",
		new_password_character:"Your new Password must contain a minimum of 4 characters.",
		must_select_country:"You must select a country from the Countries pull down menu."
	},
	
	check_input: function(field_name, field_size, message) {
		if (this.prop.form.elements[field_name] && (this.prop.form.elements[field_name].type != "hidden")) {
			var field_value = this.prop.form.elements[field_name].value;
			if (field_value == '' || field_value.length < field_size) {
			this.prop.error_message += "* " + message + "\n";
			this.prop.error = true;
			}
		}
	},

	check_radio: function(field_name, message) {
		var isChecked = false;
		if (this.prop.form.elements[field_name] && (this.prop.form.elements[field_name].type != "hidden")) {
			var radio = this.prop.form.elements[field_name];
			for (var i=0; i<radio.length; i++) {
				if (radio[i].checked == true) {
				isChecked = true;
				break;
				}
			}
			if (isChecked == false) {
			this.prop.error_message += "* " + message + "\n";
			this.prop.error = true;
			}
		}
	},

	check_select: function(field_name, field_default, message) {
		if (this.prop.form.elements[field_name] && (this.prop.form.elements[field_name].type != "hidden")) {
			var field_value = this.prop.form.elements[field_name].value;

			if (field_value == field_default) {
			this.prop.error_message += "* " + message + "\n";
			this.prop.error = true;
			}
		}
	},

	check_password: function(field_name_1, field_name_2, field_size, message_1, message_2, message_3, message_4) {
		if (this.prop.form.elements[field_name_1] && (this.prop.form.elements[field_name_1].type != "hidden")) {
			var password = this.prop.form.elements[field_name_1].value;
			if (! password) {
				this.prop.error_message += "* " + message_3 + "\n";
				this.prop.error = true;		  
			} else {
				if (password == '' || password.length < field_size) {
				this.prop.error_message += "* " + message_1 + "\n";
				this.prop.error = true;
				}
				if (this.prop.form.elements[field_name_2] && (this.prop.form.elements[field_name_2].type != "hidden")) {
					var confirmation = this.prop.form.elements[field_name_2].value;
					if (! confirmation) {
						this.prop.error_message += "* " + message_4 + "\n";
						this.prop.error = true;	    
					} else {
						if (password != confirmation) {
						this.prop.error_message += "* " + message_2 + "\n";
						this.prop.error = true;
						}
					}
				}
			}
		}
	},

	check_password_new: function(field_name_1, field_name_2, field_name_3, field_size, message_1, message_2, message_3, message_4) {
		if (this.prop.form.elements[field_name_1] && (this.prop.form.elements[field_name_1].type != "hidden")) {
			var password_current = this.prop.form.elements[field_name_1].value;
			var password_new = this.prop.form.elements[field_name_2].value;
			var password_confirmation = this.prop.form.elements[field_name_3].value;
			if ((! password_current) || (! password_new) || (! password_confirmation)) {
				this.prop.error_message += "* " + message_4 + "\n";
				this.prop.error = true;		
			} else {
				if (password_current == '' || password_current.length < field_size) {
				this.prop.error_message += "* " + message_1 + "\n";
				this.prop.error = true;
				} else if (password_new == '' || password_new.length < field_size) {
				this.prop.error_message += "* " + message_2 + "\n";
				this.prop.error = true;
				} else if (password_new != password_confirmation) {
				this.prop.error_message += "* " + message_3 + "\n";
				this.prop.error = true;
				}
			}
		}
	},

	check_form: function(formObj) {
		if (this.prop.submitted == true) {
		alert(this.loc.has_been_submitted);
		return false;
		}
		this.prop.error = false;
		this.prop.form = formObj;
		this.prop.error_message = this.loc.errors_have_occured;
		this.check_input("firstname", 1, this.loc.first_name_character);
		this.check_input("lastname", 1, this.loc.last_name_character);
		this.check_input("email_address", 6, this.loc.email_character);
		this.check_input("street_address", 1, this.loc.street_address_character);
		this.check_input("postcode", 1, this.loc.post_code_character);
		this.check_input("city", 1, this.loc.city_character);
		//checking emails match
		this.check_password("email_address", "email_confirm", 6, this.loc.email_character, this.loc.email_must_match,this.loc.email_character,this.loc.email_not_empty);
	
		if (this.prop.form.elements['state'] != null && this.prop.form.elements['state'] != 'undefined'){
			if (this.prop.form.elements['state'].type != "hidden") {
				if (this.prop.form.state.value == '' || this.prop.form.state.value.length < 2) {
				this.prop.error_message += "* " + this.loc.state_character + "\n";
				this.prop.error = true;
				}
			}
		}
		if (this.prop.form.elements['email_address_confirm'] && this.prop.form.elements['email_address']){
			if (this.prop.form.elements['email_address_confirm'].value == '' || this.prop.form.elements['email_address_confirm'].value != this.prop.form.elements['email_address'].value){
			this.prop.error_message += "* " + this.loc.email_must_be_identical + "\n";
			this.prop.error = true;
			}
		}
		this.check_select("country", "", this.loc.must_select_country);
		//  this.check_input("telephone", 0, "Your Telephone Number must contain a minimum of 0 characters.");
		this.check_password("password", "confirmation", 4, this.loc.password_character, this.loc.password_must_match,this.loc.password_not_empty,this.loc.password_not_empty);
		this.check_password_new("password_current", "password_new", "password_confirmation", 4, this.loc.password_character, this.loc.new_password_character, this.loc.password_must_match,this.loc.password_not_empty);
		if (this.prop.error == true) {
			alert(this.prop.error_message);
			return false;
		} else {
			this.prop.submitted = true;
			return true;
		}
	}
}
function closemoreinfooverlay() {
	var moreinfooverlay = document.getElementById('GPMoreInfoOverlay');
	moreinfooverlay.style.visibility = 'hidden';
}

//call before securom one
function showAgeCheckbox() {
	document.getElementById('age_agree').checked == false;
	var chkObj = document.getElementById('ageCheckbox');
	chkObj.style.display = 'block';
	document.getElementById('proceedcheckout').onclick = function(){return checkAge();}
}
function checkAge(){
	if (document.getElementById('age_agree').checked == false){
		alert('You must agree to the terms below by checking the Age Verification box.');
		return false;
	} else {
		return true;
	}
}


// init modules on pageload
YAHOO.util.Event.addListener(window, 'load', ASlite.init);

