/*
	TalkShoe Confidential Information
	Copyright (c) 2005 - 2009 
*/

function TermsApprove(checker) {
	var obj1=document.getElementById('userCreationForm:CreateUserBtn1');
	var obj2=document.getElementById('userCreationForm:CreateUserBtn2');
	var obj3=document.getElementById('userCreationForm:submitButtons');
	var obj4=document.getElementById('userCreationForm:submitButtonsReplaced');
	
	if(checker == true){
		/*obj1.disabled = false;
		obj2.disabled = false;*/
		obj3.style.display = "";
		obj4.style.display = "none";
	}else{
		/*obj1.disabled = true;
		obj2.disabled = true;*/
		obj3.style.display = "none";
		obj4.style.display = "";
	}
}

function CheckTerms(){
	var obj5=document.getElementById('userCreationForm:TermsChecker').checked;
	
	TermsApprove(obj5);
}

function checkPhone(whichCalled,FormName){
	var phone1=document.getElementById(FormName+':PhoneNumber1').value;
	var phone2=document.getElementById(FormName+':PhoneNumber2').value;
	var phone3=document.getElementById(FormName+':PhoneNumber3').value;
	var phoneMain;
	
	phoneMain=phone1+phone2+phone3;
	document.getElementById(FormName+':PhoneNumber').value=phoneMain;
}

function unStringPhone(FormName){
	var phone1;
	var phone2;
	var phone3;
	var phoneMain;
	
	phoneMain=document.getElementById(FormName+':PhoneNumber').value;

	if(phoneMain.length==11){
		phone1=phoneMain.substring(0,4);
		phone2=phoneMain.substring(4,7);
		phone3=phoneMain.substring(7,11);
	}else if(phoneMain.length==10){
		phone1=phoneMain.substring(0,3);
		phone2=phoneMain.substring(3,6);
		phone3=phoneMain.substring(6,10);
	}else{
		phone1="";
		phone2="";
		phone3="";
	}
	
	document.getElementById(FormName+':PhoneNumber1').value=phone1;
	document.getElementById(FormName+':PhoneNumber2').value=phone2;
	document.getElementById(FormName+':PhoneNumber3').value=phone3;
	
}

function nonNumberIllegal(obj){
	var nums="1234567890";
	o=obj;
	
	if(o.value.length==0) return;
	lchar = o.value.substr(o.value.length-1,1);
	if(nums.indexOf(lchar)==-1) o.value = o.value.substr(0,o.value.length-1);
}

/***********************************************
* Textarea Maxlength script- ? Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj,mlength){
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function validateUserCreate(){
	var emailAddress = document.getElementById('userCreationForm:EmailAddress');
	var userName = document.getElementById('userCreationForm:UserName');
	var phonePin = document.getElementById('userCreationForm:Pin');
	var age = document.getElementById('userCreationForm:Age');
	//var postalCode = document.getElementById('userCreationForm:Zip');
	
	if(illegalCharChecker(emailAddress)==false){
		return false;
	}else if(illegalCharChecker(userName)==false){
		return false;
	}else if(illegalCharChecker(phonePin)==false){
		return false;
	}else if(illegalCharCheckerRemove(age)==false){
		return false;
	}else{
		return true;
	}
		
}

function subscriptionFormFill(whichForm){
	var sEmail = document.getElementById('sEmail').value;
	var sMasterId = document.getElementById('sMasterId').value;
	var sKey = document.getElementById('sKey').value;
	var sHostId = document.getElementById('sHostId').value;
	
	var formName = whichForm+'Form';
		
	if(whichForm == 'UnSubscribeAll'){
		document.getElementById(formName+':sEmailUA').value = sEmail;
		document.getElementById(formName+':sKeyUA').value = sKey;
	}else if(whichForm == 'UnSubscribeTalkcast'){
		document.getElementById(formName+':sEmailUT').value = sEmail;
		document.getElementById(formName+':sKeyUT').value = sKey;
		document.getElementById(formName+':TalkcastIdUT').value = sMasterId;
	}else if(whichForm == 'UnSubscribeHost'){
		document.getElementById(formName+':sEmailUH').value = sEmail;
		document.getElementById(formName+':sKeyUH').value = sKey;
		document.getElementById(formName+':HostIdUH').value = sHostId;
	}else if(whichForm == 'ReSubscribeAll'){
		document.getElementById(formName+':sEmailRA').value = sEmail;
		document.getElementById(formName+':sKeyRA').value = sKey;
	}else if(whichForm == 'ReSubscribeTalkcast'){
		document.getElementById(formName+':sEmailRT').value = sEmail;
		document.getElementById(formName+':sKeyRT').value = sKey;
		document.getElementById(formName+':TalkcastIdRT').value = sMasterId;
	}else if(whichForm == 'ReSubscribeHost'){
		document.getElementById(formName+':sEmailRH').value = sEmail;
		document.getElementById(formName+':sKeyRH').value = sKey;
		document.getElementById(formName+':HostIdRH').value = sHostId;
	}
	
}

function subscriptionFormShow(whichField){
	var whichToShow = document.getElementById(whichField).value;
	if(whichToShow == 'unSubA'){
		document.getElementById('UnSubscribeAll').style.display="";
	}else if(whichToShow == 'unSubT'){
		document.getElementById('UnSubscribeTalkcast').style.display="";
	}else if(whichToShow == 'unSubH'){
		document.getElementById('UnSubscribeHost').style.display="";
	}else if(whichToShow == 'reSubA'){
		document.getElementById('ReSubscribeAll').style.display="";
	}else if(whichToShow == 'reSubT'){
		document.getElementById('ReSubscribeTalkcast').style.display="";
	}else if(whichToShow == 'reSubH'){
		document.getElementById('ReSubscribeHost').style.display="";
	}else{
		document.getElementById('UnSubscribeAll').style.display="none";
		document.getElementById('UnSubscribeTalkcast').style.display="none";
		document.getElementById('UnSubscribeHost').style.display="none";
		document.getElementById('ReSubscribeAll').style.display="none";
		document.getElementById('ReSubscribeTalkcast').style.display="none";
		document.getElementById('ReSubscribeHost').style.display="none";
	}
}