/*****************************************************************************************************
* Author Name 		: Safdar Javed
* Creation Date		: 06 jun-2007
* FileName 			: generalvalidation.js
* Called From 		: skeleton.html
* Description 		: this file contains function for fckeditor. 
* Components Used 	: none
* Tables Accessed 	: none
* Program Specs 	:
* UTP doc 			:
* Tested By 		:
****************************************************************************************************/

/*************************************************************************************************
*Function Header
*Function Name  : checkMessage
*Function Type  : call by value
*Functionality  : Check Valiidation for FCK EDITOR
*Input			: nothing
*Output			: alert message
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
function checkMessage(formName)
	{	
		if (!validateForm(document.compose,false,false,false,false))
			return false;
		else
		{
			var oEditor = FCKeditorAPI.GetInstance('content') ;
			// Get the editor contents in XHTML.
			if ( oEditor.GetXHTML( false ).length == 0 )
			{
				alert( 'Please enter contents.' ) ;
				return false ;
			}
		}
		compose.submit();
		return true;
	}


/*************************************************************************************************
*Function Header
*Function Name  : FCKeditor_OnComplete
*Function Type  : call by value
*Functionality  : Valiidation for FCK EDITOR
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
function FCKeditor_OnComplete( editorInstance )
	{
		// Attach to the event fired when the editor's HTML is set.
		editorInstance.Events.AttachEvent( 'OnAfterSetHTML', FCKeditor_OnAfterSetHTML ) ;
	}

/*************************************************************************************************
*Function Header
*Function Name  : FCKeditor_OnAfterSetHTML
*Function Type  : call by value
*Functionality  : Valiidation for FCK EDITOR
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
	function FCKeditor_OnAfterSetHTML( editorInstance )
	{
		// Get the actual color from the combo.
		var DynamicText = document.getElementById('DynamicText').value ;
		
		// Set the color of the editor instance.
		//editorInstance.EditorDocument.body.style.backgroundColor = sColor ;

		editorInstance.EditorDocument.body.innerHTML = editorInstance.EditorDocument.body.innerHTML+DynamicText ;
	}

/*************************************************************************************************
*Function Header
*Function Name  : SetDynamicText
*Function Type  : call by value
*Functionality  : General purpose function for FCKeditor
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
	function SetDynamicText()
	{
		// Get the editor instance that we want to interact with.
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		
		// Call the event function to set the color.
		FCKeditor_OnAfterSetHTML( oEditor ) ;
	}

/*******************FUNCTION FOR ADDING COMMENTS ON MUSIC DETAIL PAGE STARTS HERE****************** by pk gill*/	
/*************************************************************************************************
*Function Header
*Function Name  : HideContent
*Function Type  : call by value
*Functionality  : Hide textarea for adding comment
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
function HideContent(d,v) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
document.getElementById(v).value="";

}

/*************************************************************************************************
*Function Header
*Function Name  : ShowContent
*Function Type  : call by value
*Functionality  : show textarea for adding comment
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}

/*************************************************************************************************
*Function Header
*Function Name  : ReverseContentDisplay
*Function Type  : call by value
*Functionality  : call the above two function to show/hide textarea.
*Input			: nothing
*Output			: nothing
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
/*******************FUNCTION FOR ADDING COMMENTS ON MUSIC DETAIL PAGE ENDS HERE ******************/



/*************************************************************************************************
*Function Header
*Function Name  : funPasswordValidation
*Function Type  : call by value
*Functionality  : This function Validate the change password form.
*Input			: nothing
*Output			: alert the error message.
*Return Value   : nothing
*Note			: nothing
*********************************************************************************************/
function funPasswordValidation() {
	formName	=	document.frmChangePassword;
		if(StringTrim(formName.txtOldPassword.value) == ""){
					alert("Please enter old password.");
					formName.txtOldPassword.focus();
					formName.txtOldPassword.select();
					return false;
		}
		if(StringTrim(formName.txtNewPassword.value) == ""){
					alert("Please enter new password.");
					formName.txtNewPassword.focus();
					formName.txtNewPassword.select();
					return false;
		}	
		
	if(StringTrim(formName.txtNewPassword.value).length < 6){
				alert("Please enter a password of minimum 6 characters.");
				formName.txtNewPassword.focus();
				formName.txtNewPassword.select();			
				return false;
		}
		
		
		if(StringTrim(formName.txtConfirmPassword.value) == ""){
					alert("Please enter confirm password.");
					formName.txtConfirmPassword.focus();
					formName.txtConfirmPassword.select();
					return false;
		}
				if(StringTrim(formName.txtNewPassword.value) != StringTrim(formName.txtConfirmPassword.value))
		{
					alert('Password and confirm password donot match . Please try again.')
					formName.txtConfirmPassword.focus();
					formName.txtConfirmPassword.select();
					return false;
		}

}



