$(document).ready(function()
{
	lostPwdClick = false;
	
	$('#lostpwusr-a').click(function(){
											 
		lostPwdClick = true;
		return false;
		
	});

	$('#register-a[rel="modal"]').click(function(){ return false; 	});
	$('.login-combo[rel="modal"]').click(function(){ return false; 	});
	
	
   //loads register form lightbox		
   $('#register-a[rel="modal"]').qtip(
   {
      content: {
         title: {
            text: 'Register Now!',
            button: 'Close'
         },
         text: '<form method="post" action="" class="access-form"  id="register-form" name="register-form"><div class="loading"></div>' +
				'<p class="frm-title">Required</p>' +		 		
				'<p><label for="username">Username*</label><input type="text" id="username" name="username" value="" /></p>' +
		 		'<p><label for="pw">Password*</label><input type="password" id="pw" name="pw" value="" /></p>' +
		 		'<p><label for="pw_conf">Confirm Password*</label><input type="password" id="pw_conf" name="pw_conf" value="" /></p>' +
		 		'<p><label for="email">Email Address*</label><input class="required email" type="text" id="email" name="email" value="" /></p>' +
				'<p><label for="newsletter">Receive Newsletters?</label><input value="0" type="checkbox" id="newsletter" name="newsletter" /></p>' +

				'<p class="frm-title opt-fields"><a href="#">Optional</a></p>' +		 		

				'<div id="opt-fields">' +
				
				'<p><label for="fname">First Name</label><input type="text" id="fname" name="fname" value="" /></p>' +
				'<p><label for="lname">Last Name</label><input type="text" id="lname" name="lname" value="" /></p>' +
				'<p><label for="title">Title</label><input type="text" id="title" name="title" value="" /></p>' +
				
				'<p class="frm-title billing-fields"><a href="#">Billing Address</a></p>' +
				
				'<div id="billing-fields">' +
				
					'<p><label for="baddress">Address</label><input type="text" id="baddress" name="baddress" value="" /></p>' +
					'<p><label for="baddress1">Address1</label><input type="text" id="baddress1" name="baddress1" value="" /></p>' +
					'<p><label for="bcity">City</label><input type="text" id="bcity" name="bcity" value="" /></p>' +
					'<p><label for="baddress2">County</label><input type="text" id="baddress2" name="baddress2" value="" /></p>' +
					'<p><label for="bzip">Postcode</label><input type="text" id="bzip" name="bzip" value="" /></p>' +
					'<p><label for="bcountry">Country</label><select id="bcountry" name="bcountry"><option value="0">--- select country ---</option></select></p>' +
	
					'<br /><p><label for="bsameasd">Delivery Address Same as Billing Address?</label><input value="1" type="checkbox" id="bsameasd" name="bsameasd" /></p>' +
				'</div>' +

				'<p class="frm-title delivery-fields"><a href="#">Delivery Address</a></p>' +

				'<div id="delivery-fields">' +
				
					'<p><label for="daddress">Address</label><input type="text" id="daddress" name="daddress" value="" /></p>' +
					'<p><label for="daddress1">Address1</label><input type="text" id="daddress1" name="daddress1" value="" /></p>' +
					'<p><label for="dcity">City</label><input type="text" id="dcity" name="dcity" value="" /></p>' +
					'<p><label for="daddress2">County</label><input type="text" id="daddress2" name="daddress2" value="" /></p>' +
					'<p><label for="dzip">Postcode</label><input type="text" id="dzip" name="dzip" value="" /></p>' +
					'<p><label for="dcountry">Country</label><select id="dcountry" name="dcountry"><option value="0">--- select country ---</option></select></p>' +
				'</div>' +
	 		
				
				'</div>' +		 		
				
		 		'<p><input class="btn access-submit" type="submit" id="register-submit" name="register-submit" value="Register" /></p>' +				
				'</form>' +
				'<script type="text/javascript">$("#register-submit").click(function() {  setTimeout("createUser()",1000);	}); $("#register-form").submit(function() {  return false;	}); </script>'

				
				
				
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'click', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { max: 850 },
         padding: '14px',
		 border: {
            width: 9,
            radius: 9,
            color: '#4D6033'
         },
         name: 'light'
		 
      },
      api: {
         beforeShow: function()
         {


		$('.opt-fields a').click(function(){
			toggleOptFields(); 
			return false;
		});

		$('.billing-fields a').click(function(){
			toggleAddressFields('billing'); 
			return false;
		});

		$('.delivery-fields a').click(function(){
			toggleAddressFields('delivery'); 
			return false;
		});
		
		$('#bsameasd').click(function(){
			bSameAsD(this); 
			return false;
			
		});	

		registerValidator();

			// Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
			
         },
         beforeHide: function()
         {
			 //$('#register-a[rel="modal"]').qtip('destroy');
			//window.location.reload();						  

            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });

   // Create the modal backdrop on document load so all modal tooltips can use it
   $('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: $(document).scrollTop(), // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: $(document).height(), // Span the full document height...
         width: '100%', // ...and full width

         opacity: 0.7, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
		 
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially
	  

	//loads login form lightbox
	
   $('.login-combo[rel="modal"]').qtip(
   {
      content: {
         title: {
            text: 'Login',
            button: 'Close'
         },
         text: '<form method="post" action="" class="access-form" id="login-form" name="login-form"><div class="loading"></div>' +
				'<div id="body-form"><label for="username">Username</label><input tabindex="1" type="text" id="username" name="username" value="" /></div><br/>' +
		 		'<div id="body-form"><label for="pw">Password</label><input tabindex="2" type="password" id="pw" name="pw" value="" /></div>' +
				
		 		'<div class="buttons"><button class="positive" type="submit" id="login-submit" name="login-submit" value="Login"><img src="/images/icons/key_go.png" alt=""/>Login</button></div>' +				
				'</form>' +

				'<p class="frm-title lostpw"><a tabindex="4" href="#">Forgotten your username or password?</a></p>' +		 		

				'<div id="lostpw">' +		 		
				'<form method="post" action="" class="access-form" id="lostpwd-form" name="lostpwd-form">' +				
				'<p>If you have forgotten your username or password, simply enter your e-mail address below and we\'ll e-mail a reminder to you.</p><div id="body-form"><label for="lostpwd">E-mail Address</label><input tabindex="5" type="text" id="lostpwd" name="lostpwd" value="" /></div><br/>' +
				'<div class="buttons"><button class="positive" type="submit" id="lostpwd-submit" name="lostpwd_submit" value="Reset Password"><img src="/images/icons/key.png" alt=""/>Reset Password</button></div><div class="buttons"><button class="positive" type="submit" id="lostusr-submit" name="lostusr_submit" value="E-mail Username"><img src="/images/icons/user_o.png" alt=""/>E-mail Username</button></div>' +
				
				
				'</form>' +
				'</div>' +	
				
				
				'<script type="text/javascript">' +
				
				'$("#login-submit").click(function() {  setTimeout("loginUser()",300);	}); '+
				'$("#login-form").submit(function() {  return false;	}); '+

				'$("#lostpwd-submit").click(function() {  setTimeout("getPwd()",300);	}); '+
				'$("#lostusr-submit").click(function() {  setTimeout("getUsr()",300);	}); '+
				'$("#lostpwd-form").submit(function() {  return false;	}); '+


				'</script>'

				
				
				
      },
      position: {
         target: $(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'click', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { max: 550 },
         padding: '14px',
		 border: {
            width: 9,
            radius: 9,
            color: '#4D6033'
         },
         name: 'light'
		 
      },
      api: {
         beforeShow: function()
         {

			$('.lostpw a').click(function(){
				toggleLostPw(); 
				return false;
				
			});
	
			$('.overlay').click(function(){
				$(this).css('display', 'none');	
				$(this).parents('.text_box').children('input').focus();
				return false;
	
			});

			$('.text_box').children('input').blur(function(){
				if ($(this).val() == '') $(this).parents('.text_box').children('.overlay').css('display', 'block');
			});
			
			loginValidator();
			lostpwusrValidator();
			if (lostPwdClick) toggleLostPw();

			// Fade in the modal "blanket" using the defined show speed
            $('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
			 //$('#register-a[rel="modal"]').qtip('destroy');
			//window.location.reload();						  

            // Fade out the modal "blanket" using the defined hide speed
            $('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });	

		
		
});

//================================
function getPwd()	{
//================================

	noGood = false;
	
	$('#lostpwd-form .error').each(function(){
		
		if ( $(this).css('display') != 'none'	)	noGood = true;	

	});
	
	if (!noGood)	{
		
		$.ajaxSetup({ type: "POST" });
		
		$(".loading").ajaxStart(function(){ $(this).fadeIn(); });
		$(".loading").ajaxComplete(function(){ $(this).fadeOut(); });
		
				var adata = {};
				
				adata.email				=	$('#lostpwd').val();
				
				$.ajax({
					url: "/auth/lost/pwd",
					data: adata,
					success: function(response){
						if(response == '0')
						{
							alert('Ouch something went wrong with your password retrieval process. Please try again!');
							return;
						}
						if(response == '1')
						{
							alert('Thank you for requesting a new password. Please check your email for our new password message.');
							window.location = '/';
							return;
						}
						
						if(response != '1' && response != '0')
						{
							alert(response);
							return;
						}
					}
				});
	
					
	}
		return;	


}

//================================
function getUsr()	{
//================================

	noGood = false;
	
	$('#lostusr-form .error').each(function(){
		
		if ( $(this).css('display') != 'none'	)	noGood = true;	

	});
	
	if (!noGood)	{
		
		$.ajaxSetup({ type: "POST" });
		
		$(".loading").ajaxStart(function(){ $(this).fadeIn(); });
		$(".loading").ajaxComplete(function(){ $(this).fadeOut(); });
		
				var adata = {};
				
				adata.email				=	$('#lostpwd').val();
				
				$.ajax({
					url: "/auth/lost/usr",
					data: adata,
					success: function(response){
						if(response == '0')
						{
							alert('Ouch something went wrong with your username retrieval process. Please try again!');
							return;
						}
						if(response == '1')
						{
							alert('Please check your email for our username retrieval message.');
							window.location = '/';
							return;
						}
						
						if(response != '1' && response != '0')
						{
							alert(response);
							return;
						}
					}
				});
	
					
	}
		return;	


}



//================================
function loginUser()	{
//================================

	noGood = false;
	
	$('#login-form .error').each(function(){
		
		if ( $(this).css('display') != 'none'	)	noGood = true;	

	});
	
	if (!noGood)	{
		
		$.ajaxSetup({ type: "POST" });
		
		$(".loading").ajaxStart(function(){ $(this).fadeIn(); });
		$(".loading").ajaxComplete(function(){ $(this).fadeOut(); });
		
				var adata = {};
				
				adata.username			=	$('#username').val();
				adata.pw				=	$('#pw').val();
				
				$.ajax({
					url: "/auth/login",
					data: adata,
					success: function(response){
						if(response == '0')
						{
							alert('Ouch something went wrong with your login. Please try again!');
							return;
						}
						if(response == '1')
						{
							//alert('You are now logged in!');
							window.location = window.location;
							return;
						}
						
						if(response != '1' && response != '0')
						{
							alert(response);
							return;
						}
					}
				});
	
					
	}
		return;		
}

//================================
function createUser()	{
//================================

	noGood = false;
	
	$('#register-form .error').each(function(){
		
		if ( $(this).css('display') != 'none'	)	noGood = true;	

	});
	
	if (!noGood)	{
		
		$.ajaxSetup({ type: "POST" });
		
		$(".loading").ajaxStart(function(){ $(this).fadeIn(); });
		$(".loading").ajaxComplete(function(){ $(this).fadeOut(); });
		
				var adata = {};
				
				adata.username			=	$('#username').val();
				adata.pw				=	$('#pw').val();
				adata.pw_conf			=	$('#pw_conf').val();
				adata.email				=	$('#email').val();
				adata.newsletter		=	($('#newsletter').attr('checked') == true)		?	1	:	0;

				adata.fname				=	$('#fname').val();
				adata.lname				=	$('#lname').val();
				adata.title				=	$('#title').val();

				adata.baddress			=	$('#baddress').val();
				adata.baddress1			=	$('#baddress1').val();
				adata.baddress2			=	$('#baddress2').val();
				adata.bcity				=	$('#bcity').val();
				adata.bzip				=	$('#bzip').val();
				adata.bcountry			=	$('#bcountry').val();

				adata.daddress			=	$('#daddress').val();
				adata.daddress1			=	$('#daddress1').val();
				adata.daddress2			=	$('#daddress2').val();
				adata.dcity				=	$('#dcity').val();
				adata.dzip				=	$('#dzip').val();
				adata.dcountry			=	$('#dcountry').val();


				$.ajax({
					url: "/auth/register/create_User",
					data: adata,
					success: function(response){
						if(response == '0')
						{
							alert('Ouch something went wrong with your registration. Please try again!');
							return;
						}
						if(response == '1')
						{
							alert('Thank you for registering with CardTribe. Please check your email for our activation message.');
							window.location = '/';
							return;
						}

						if(response == '2')
						{
							alert('You have been registered but sending email confirmation failed');
							window.location = '/';
							return;
						}
						
						if(response != '1' && response != '0' && response != '2')
						{
							alert(response);
							window.location = '/';							
							return;
						}
					}
				});
	
					
	}
		return;		
}


//================================
function toggleOptFields()	{
//================================
			
	$('#opt-fields').animate({
				height: 'toggle'
			  }, 500, function() {
				// Animation complete.
				if ($('#opt-fields').css('display') == 'block') 
				{
					$('.opt-fields').css('background', 'url("../images/tri_d_grn.gif") no-repeat scroll 20%');

								if ($('#bcountry').length == 1)
								{
				//////////////
					// Defautl AJAX properties
									$.ajaxSetup({ type: "POST" });
									
									$(".loading").ajaxStart(function(){ $(this).fadeIn(); });
									$(".loading").ajaxComplete(function(){ $(this).fadeOut(); });
									
											var adata = {};
											
											$.ajax({
												url: "/auth/register/get_countries",
												data: adata,
												success: function(response){
													if(response != '0')
													{
														$('#bcountry').append(response);
														$('#dcountry').append(response);
													}
													else alert('Failed to retrieve country list');
												}
											});
							
							
				////////////////
									
								}
								
				
				}
				
				else $('.opt-fields').css('background', 'url("../images/tri_r_grn.gif") no-repeat scroll 20%');

				
			});


	
}
//================================
function toggleAddressFields(what)	{
//================================

	other = (what == 'billing')		?		'delivery' 		:		'billing';
	
	if ($('#' + other + '-fields').css('display') == 'block') 
	{

	   $('#' + other + '-fields').animate({
			height: 'toggle'
		  }, 500, function() {
			// Animation complete.
			$('.' + other + '-fields').css('background', 'url("../images/tri_r_grn.gif") no-repeat scroll 30%');

		   $('#' + what + '-fields').animate({
				height: 'toggle'
			  }, 500, function() {
				// Animation complete.
				if ($('#' + what + '-fields').css('display') == 'block') 
				{				
					$('.' + what + '-fields').css('background', 'url("../images/tri_d_grn.gif") no-repeat scroll 30%');
				
				}
				else $('.' + what + '-fields').css('background', 'url("../images/tri_r_grn.gif") no-repeat scroll 30%');
			});
	   
		});
	

	}
	else
	{

	   $('#' + what + '-fields').animate({
			height: 'toggle'
		  }, 500, function() {
			// Animation complete.
			if ($('#' + what + '-fields').css('display') == 'block') 
			{				
				$('.' + what + '-fields').css('background', 'url("../images/tri_d_grn.gif") no-repeat scroll 30%');
			
			}
			else $('.' + what + '-fields').css('background', 'url("../images/tri_r_grn.gif") no-repeat scroll 30%');
		});
		
		
	}
				

}
//================================
function toggleLostPw()	{
//================================
			
	$('#lostpw').animate({
				height: 'toggle'
			  }, 500, function() {
				// Animation complete.
				if ($('#lostpw').css('display') == 'block') 
				{
					$('.lostpw').css('background', 'url("../images/tri_d_grn.gif") no-repeat scroll 50%');

								
				
				}
				
				else $('.lostpw').css('background', 'url("../images/tri_r_grn.gif") no-repeat scroll 50%');

				
			});


	
}	



//================================
function lostpwusrValidator()	{
//================================

$("#lostpwd-form").validate({

	onkeyup:false,
	onsubmit: true,
	rules: {
	lostpwd: {
	required:true,
	email:true,
	emailCheck:true    // remote check for duplicate email address
	}
	},
	messages: {
	lostpwd: {
	required: "email address is required.",
	email: "email address must be valid.",
	emailCheck:"this email address is NOT in our database."	
	}
	}
	});

	jQuery.validator.addMethod('emailCheck', function(email) {
	var postURL = "auth/register/emailCheck";
	$.ajax({
	cache:false,
	async:false,
	type: "POST",
	data: "email=" + email,
	url: postURL,
	success: function(msg) {
	result = (msg==true) ? true : false;
	}
	});
	return result;
	}, '');
	
	
	
}


//================================
function loginValidator()	{
//================================

$("#login-form").validate({

	onkeyup:false,
	onsubmit: true,
	rules: {
	username: {
	required:true,
	minlength:5,
	maxlength:20,
	validChars:true
	},
	pw: {
	required:true,
	minlength:5,
	maxlength:20,
	validChars:true	
	}
	},
	messages: {
	username: {
	required: "username is required.",
	minlength: jQuery.format("username must be at least {0} characters in length."),
	maxlength: jQuery.format("username can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."
	},
	pw: {
	required: "password is required.",
	minlength: jQuery.format("password must be at least {0} characters in length."),
	maxlength: jQuery.format("password can not exceed {0} characters in length.")
	}
	}
	});
	
	// check for unwanted characters
	$.validator.addMethod('validChars', function (value) {
	var result = true;
	// unwanted characters
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < value.length; i++) {
	if (iChars.indexOf(value.charAt(i)) != -1) {
	return false;
	}
	}
	return result;
	}, '');

	
	
	
	
	
}

//================================
function registerValidator()	{
//================================

$("#register-form").validate({

	onkeyup:false,
	onsubmit: true,
	rules: {
	username: {
	required:true,
	minlength:5,
	maxlength:20,
	validChars:true,
	usernameCheck:true    // remote check for duplicate username
	},
	email: {
	required:true,
	email:true,
	maxlength:100,
	emailCheck:true    // remote check for duplicate email address
	},
	pw: {
	required:true,
	minlength:5,
	maxlength:20,
	validChars:true	
	},
	pw_conf: {
	required:true,
	equalTo: "#pw"
	},
	fname: {
	maxlength:50,
	validChars:true	
	},
	lname: {
	maxlength:50,
	validChars:true	
	},
	title: {
	maxlength:50,
	validChars:true	
	},
	baddress: {
	maxlength:100,
	validChars:true	
	},	
	baddress: {
	maxlength:100,
	validChars:true	
	},
	baddress1: {
	maxlength:100,
	validChars:true	
	},	
	baddress2: {
	maxlength:100,
	validChars:true	
	},	
	bcity: {
	maxlength:100,
	validChars:true	
	},	
	bzip: {
	maxlength:20,
	validChars:true	
	},
	bcountry: {
	maxlength:2,
	validChars:true	
	},
	daddress: {
	maxlength:100,
	validChars:true	
	},
	daddress1: {
	maxlength:100,
	validChars:true	
	},	
	daddress2: {
	maxlength:100,
	validChars:true	
	},	
	dcity: {
	maxlength:100,
	validChars:true	
	},	
	dzip: {
	maxlength:20,
	validChars:true	
	},
	dcountry: {
	maxlength:2,
	validChars:true	
	}	
	},
	messages: {
	username: {
	required: "username is required.",
	minlength: jQuery.format("username must be at least {0} characters in length."),
	maxlength: jQuery.format("username can not exceed {0} characters in length."),
	validChars: "please supply valid characters only.",
	usernameCheck:"this username is already in use."
	},
	email: {
	required: "email address is required.",
	email: "email address must be valid.",
	maxlength: jQuery.format("email address can not exceed {0} characters in length."),
	emailCheck:"this email address is already in use."
	},
	pw: {
	required: "password is required.",
	minlength: jQuery.format("password must be at least {0} characters in length."),
	maxlength: jQuery.format("password can not exceed {0} characters in length.")
	},
	pw_conf: {
	required: "confirmed password is required.",
	equalTo: "confirmed password does not match."
	},
	baddress: {
	maxlength: jQuery.format("billing address can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	fname: {
	maxlength: jQuery.format("first name can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	lname: {
	maxlength: jQuery.format("last name can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	title: {
	maxlength: jQuery.format("title can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	baddress1: {
	maxlength: jQuery.format("billing address1 can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	baddress2: {
	maxlength: jQuery.format("billing address2 can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	bcity: {
	maxlength: jQuery.format("billing city can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	},
	bzip: {
	maxlength: jQuery.format("billing city can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	},
	bcountry: {
	maxlength: jQuery.format("billing city can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	},
	daddress: {
	maxlength: jQuery.format("delivery address can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	daddress1: {
	maxlength: jQuery.format("delivery address1 can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	daddress2: {
	maxlength: jQuery.format("delivery address2 can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."	
	},
	dcity: {
	maxlength: jQuery.format("delivery city can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	},
	dzip: {
	maxlength: jQuery.format("delivery zip code can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	},
	dcountry: {
	maxlength: jQuery.format("delivery country can not exceed {0} characters in length."),
	validChars: "please supply valid characters only."		
	}	
	}
	});

	
	// extend the validation plugin to do remote username and email dupe checking
	jQuery.validator.addMethod('usernameCheck', function(username) {
	var postURL = "auth/register/usernameCheck";
	$.ajax({
	cache:false,
	async:false,
	type: "POST",
	data: "username=" + username,
	url: postURL,
	success: function(msg) {
	result = (msg==true) ? false : true;
	}
	});
	return result;
	}, '');
	
	jQuery.validator.addMethod('emailCheck', function(email) {
	var postURL = "auth/register/emailCheck";
	$.ajax({
	cache:false,
	async:false,
	type: "POST",
	data: "email=" + email,
	url: postURL,
	success: function(msg) {
	result = (msg==true) ? false : true;
	}
	});
	return result;
	}, '');
	
	// check for unwanted characters
	$.validator.addMethod('validChars', function (value) {
	var result = true;
	// unwanted characters
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < value.length; i++) {
	if (iChars.indexOf(value.charAt(i)) != -1) {
	return false;
	}
	}
	return result;
	}, '');

	
	
	
	
	
}
