	function throwFieldError(fieldId,errorMsg) {
		eval("document.getElementById('" + fieldId + "Error').innerHTML= '" + errorMsg + "';");
		eval("document.getElementById('" + fieldId + "Error').style.display = 'block';");
		document.getElementById(fieldId).className = document.getElementById(fieldId).className + ' error';
	}
	
	function clearFieldError(fieldId) {
		eval("document.getElementById('" + fieldId + "Error').innerHTML= '';");
		eval("document.getElementById('" + fieldId + "Error').style.display = 'none';");
		document.getElementById(fieldId).className = (document.getElementById(fieldId).className).replace(' error','');
	}
	
	/* Error fields don't always have matching names as element ids */
	function throwFieldErrorById(fieldId, eFieldId, errorMsg) {
		eval("document.getElementById('" + eFieldId + "').innerHTML= '" + errorMsg + "';");
		eval("document.getElementById('" + eFieldId + "').style.display = 'block';");
		document.getElementById(fieldId).className = document.getElementById(fieldId).className + ' error';
	}	
	
	function clearFieldErrorById(fieldId, eFieldId) {
		eval("document.getElementById('" + eFieldId + "').innerHTML= '';");
		eval("document.getElementById('" + eFieldId + "').style.display = 'none';");
		document.getElementById(fieldId).className = (document.getElementById(fieldId).className).replace(' error','');
	}	
	
	function throwPromoFeedback(fieldId,msg) {
		eval("document.getElementById('" + fieldId + "Error').innerHTML= '" + msg + "';");
		eval("document.getElementById('" + fieldId + "Error').style.display = 'block';");
	}
	
	function clearPromoFeedback(fieldId) {
		eval("document.getElementById('" + fieldId + "Error').innerHTML= '';");
		eval("document.getElementById('" + fieldId + "Error').style.display = 'none';");
	}
	
	function clearForm(panelId) {
		var panelInputs = document.getElementById(panelId).getElementsByTagName('INPUT');
		var panelSelects = document.getElementById(panelId).getElementsByTagName('SELECT');
		
		for(var i=0; i<panelInputs.length; i++) {
			if(panelInputs[i].type == 'text' || panelInputs[i].type == 'password') {
				panelInputs[i].value = '';
				panelInputs[i].className = (panelInputs[i].className).replace(' error','');
				try {
					document.getElementById(panelInputs[i].id + 'Error').style.display = 'none';
				} catch (err) {
				}
			}
			
			if(panelInputs[i].type == 'checkbox') {
				panelInputs[i].checked = false;
				panelInputs[i].className = (panelInputs[i].className).replace(' error','');
				try {
					document.getElementById(panelInputs[i].id + 'Error').style.display = 'none';
				} catch (err) {
				}
			}
			
			if(panelInputs[i].type == 'radio') {
				eval('document.' + panelId + '.' + panelInputs[i].id + '[0].checked = true');
				panelInputs[i].className = (panelInputs[i].className).replace(' error','');
				try {
					document.getElementById(panelInputs[i].id + 'Error').style.display = 'none';
				} catch (err) {
				}
			}
		}
		
		for(var i=0; i<panelSelects.length; i++) {
			eval('document.' + panelId + '.' + panelSelects[i].id + '[0].selected = true');
			panelSelects[i].className = (panelSelects[i].className).replace(' error','');
			try {
				document.getElementById(panelSelects[i].id + 'Error').style.display = 'none';
			} catch (err) {
			}
		}
	}
	
	function clearForms() {
		var panels = 'clearMediaLogin,clearMediaSignUp1,clearMediaSignUp2Form,clearWireSignUp2Form,clearMediaCurrentSubscriberLoginForm,clearMediaCCInfo,songPurchaseConf';
		var clearPanels = panels.split(',');
		for(var i=0; i<clearPanels.length; i++) {
			clearForm(clearPanels[i]);
		}
	}

/* SIGNUP/PURCHASE POPUP FUNCTIONALITY START */
	
// To display Login 'i' Information message functionality
function loginInfoMsgFunction(){
	document.getElementById('loginInfoTextMsg').style.display = 'block';
}

// To display SignUp 'i' Information functionality
function signClearInfoMsgFunction(){
	document.getElementById('signClearInfoTextMsg').style.display = 'block';
	document.getElementById('signClearwireInfoTextMsg').style.display = 'none';
	document.getElementById('signCClearwireInfoTextMsg').style.display = 'none';
}
function signClearwireInfoMsgFunction(){
	document.getElementById('signClearInfoTextMsg').style.display = 'none';
	document.getElementById('signClearwireInfoTextMsg').style.display = 'block';
	document.getElementById('signCClearwireInfoTextMsg').style.display = 'none';
}
function signCClearwireInfoMsgFunction(){
	document.getElementById('signClearInfoTextMsg').style.display = 'none';
	document.getElementById('signClearwireInfoTextMsg').style.display = 'none';
	document.getElementById('signCClearwireInfoTextMsg').style.display = 'block';
}

// To display Initial Login 'i' Information functionality
function signLoginInfoMsgFunction(){
	if (document.clearMediaSignUp1.cbSignUpType[0].checked) {
		document.getElementById('signLoginInfoTextMsgClear').style.display = 'block';
		document.getElementById('signLoginInfoTextMsgClearwire').style.display = 'none';
	}
	if (document.clearMediaSignUp1.cbSignUpType[1].checked) {
		document.getElementById('signLoginInfoTextMsgClearwire').style.display = 'block';
		document.getElementById('signLoginInfoTextMsgClear').style.display = 'none';
	}
}

// To display What Is This CVV information
function billingCVVInfoMsgFunction() {
	document.getElementById('billingCVVInfoTextMsg').style.display = 'block';
}
	
function submitEnterkey(e, buttonId)
    {
		var key = e.which||e.keyCode;
        if(key == 13) {
			document.getElementById(buttonId).focus();
			//document.getElementById(buttonId).click();
			if(buttonId == 'firstLoginBtnId') {
				loginFunction();
			} else if(buttonId == 'clearMediaSignUp1NextBtnId') {
				signUpPre();
			} else if(buttonId == 'signUpNextBtnId') {
				seamlessClearmediaLogin();
				signUpSubmit(document.clearMediaSignUp2Form);
			} else if(buttonId == 'cwSignUp1NextBtnId') {
				signUpPre();
			} else if(buttonId == 'cwSignUpNextBtnId') {
				cwSignUpSubmit(document.clearWireSignUp2Form);				
			} else if(buttonId == 'SubscriberLoginNextBtnId') {
				existingUsernameValidation(document.clearMediaCurrentSubscriberLoginForm);
			} else if(buttonId == 'clearMediaBillingNextBtnId') {
				signUpBillingSubmit(document.clearMediaBilling);
			} else if(buttonId == 'clearMediaCCInfoNextBtnId') {
				addCCPurchaseValidation(document.getElementById('httpsAddCCLocation').value,document.clearMediaCCInfo);
			} else if(buttonId == 'songPurchaseConfPurchaseId') {
				finalPurchase();
			} else if(buttonId == 'playlistOKButton') {
				addSongToPlaylist();
			} else if(buttonId == 'newPlaylistTextAddBtnId') {
				//addPlayListValues();
				addPlaylist(); 
			} else if(buttonId == 'createNewPlaylistAddBtnId') {
				createNewPlaylist();
			} else if(buttonId == 'photobucketSubmitBtnId') {
				photoLoginFunction();
			} else if(buttonId == 'forgotPassSubmitBtnId') {
				getForgotPassEmail();
			} else if(buttonId == 'confirmDOBCheckId') {
				verifyDOBValidation(document.getElementById('confirmDOBForm'));
			} else if(buttonId == 'motherMNameCheckId') {
				verifySecurityAnswerValidation(document.getElementById('forgotPassQuestionForm'));
			} else if(buttonId == 'newPasswordCheckId') {
				newPasswordValidation(document.getElementById('newPasswordForm'));
			} else if(buttonId == 'emailAutoLinkFailId') {
				validateEmailAutoLinkFail(document.getElementById('emailAutoLinkFailForm'));
			}
			
      }
 	} 

var browserName=navigator;
function onKeyPressEventKeyCode(e, elementIdToBeFocus){ 
	if (browserName.appName == "Netscape") {
	 var unicode=e.charCode? e.charCode : e.keyCode
	 if(unicode == 9) {
		 document.getElementById(elementIdToBeFocus).focus();
	 }
	}
    
}

function setFocusToClearMediaLoginForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearMediaLogin.elements[elementId].focus();	
	}
	 }catch(err){
 }
}

function setFocusToclearMediaSignUp1ForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		//document.clearMediaSignUp1.elements[elementId].focus();	
		document.getElementById(elementId).focus(); 
	}
	 }catch(err){
 }
}

function setFocusToclearMediaCurrentSubscriberLoginForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearMediaCurrentSubscriberLogin.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToclearMediaSignUp2ForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearMediaSignUp2.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToclearWireSignUp2ForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearWireSignUp2.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToclearMediaCCInfoForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearMediaCCInfo.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToclearMediaBillingForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.clearMediaBilling.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusTosongPurchaseConfForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.songPurchaseConf.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToforgotPassFormForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.forgotPassForm.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusTopassOptionsForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.passOptions.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusToConfirmDOBForIE(elementId) {
 try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}
function setFocusToforgotPassQuestionFormForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.forgotPassQuestionForm.elements[elementId].focus();	
	}
	 }catch(err){
 }
}
function setFocusTonewPasswordFormForIE(elementId) {
	try{
	if (browserName.appName == "Microsoft Internet Explorer") {
		document.newPasswordForm.elements[elementId].focus();	
	}
	 }catch(err){
 }
}


function setFocusToMotherMNameForIE(elementId) {
 try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}


function setFocusTochangelocationFormForIE(elementId) {
	try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}

function setFocusTophotobucketloginForIE(elementId) {
	try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}

function setFocusTocreatePlaylistPanelForIE(elementId) {
	try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}

function setFocusToplaylistPanelForIE(elementId) {
	try{
   if (browserName.appName == "Microsoft Internet Explorer") {
   document.getElementById(elementId).focus(); 
  }
 }catch(err){
 }
}

// Text field One Click Select Function - Start
var textSelected = 0;
function textFiledValueSelect(elementId) {
	var ele = document.getElementById(elementId);
	var textFieldValue = ele.value;
	if(textFieldValue.length > 1 && textFieldValue.length == ele.selectionEnd) {
		if(textSelected == 0)
			document.getElementById(elementId).select();
		textSelected = 1;
	}
}
// Text field One Click Select Function - End 


// Start - To Check and Validate "Email" Fields.
function checkEmailVaild() {
	document.getElementById('errorEmailUserError').innerHTML='';
	document.getElementById('emailObjError').innerHTML='';
	document.getElementById('errorEmailPasswordError').innerHTML='';
	var isError = 0;
	if (document.getElementById('errorEmailUser').value == 'wrong' || document.getElementById('errorEmailUser').value == ''){
		isError = 1;
		document.getElementById('errorEmailUserError').innerHTML='Please enter your email address.';
		document.getElementById('loginTextError').style.display = 'block';	
	}
	if (document.getElementById('emailObj').value == 'wrong' || document.getElementById('emailObj').value == ''){
		isError = 1;
		document.getElementById('emailObjError').innerHTML='Please select the email account type.';
		document.getElementById('loginTextError').style.display = 'block';	
	}
	if (document.getElementById('errorEmailPassword').value == 'wrong' || document.getElementById('errorEmailPassword').value == ''){
		isError = 1;
		document.getElementById('errorEmailPasswordError').innerHTML='Please enter your password.';
		document.getElementById('loginTextError').style.display = 'block';	
	}
	var emailLinkError = 0;
	if (emailLinkError == 0 && isError == 0) {
		document.getElementById('errorEmailValidError').innerHTML='We were unable to link your email.';
	} else {
		YAHOO.CLWRBuyProcess.clearMediaThankYou.show();
	}
	
}
	
	//YAHOO.util.Event.addListener(window, "load", clearForms);