// Repeats the particular string to the specified number of times.
function strRepeat(cnt)
{
	var retStr = "";
	for(i=0;i<cnt;i++)
		retStr=retStr+",";
	return retStr;
}

// Core function to validate the forms. It reduces the time by just providing the validations for the specified field only. the other not required validations can be skipped.
function validateForm(myForm,cArray,cnt)
{
	var i=0;
	var values = "theControl,theMessage,theNumeric,theEmail,theURL,theConfirmPassword,thebadstuff,theinteger,thepercent,thesize,thedecimal,theimage,theempty,themin,themax,thecheckboxlength,thephoneno";
	var leftSide = new Array();
	var rightVals = new Array();
	leftSide = values.split(",");

	var strRepeats = strRepeat(cnt-1);

	for(i=0;i<leftSide.length;i++){
		if(cArray[leftSide[i]]){
			rightVals[i] = (cArray[leftSide[i]]);
		}else{
			rightVals[i] = strRepeats;
		}
		leftSide[i]=rightVals[i];
	}

	if(!theValidator(myForm,leftSide[0],leftSide[1],leftSide[2],leftSide[3],leftSide[4],leftSide[5],leftSide[6],leftSide[7],leftSide[8],leftSide[9],leftSide[10],leftSide[11],leftSide[12],leftSide[13],leftSide[14],leftSide[15],leftSide[16]))
		return false;

	return true;
}

function validate_FckEditor(instanceName)
{
	var oEditor = FCKeditorAPI.GetInstance(instanceName);
	var str =oEditor.EditorDocument.body.innerHTML;

	str = str.replace("&nbsp;", "");
     	str = str.replace("<BR>", "");
     	str = str.replace("<BR/>", "");
     	str = str.replace("<P>", "");
     	str = str.replace("</P>", "");
     	str = str.replace("<br>", "");
     	str = str.replace("<br/>", "");
     	str = str.replace("<p>", "");
     	str = str.replace("</p>", "");
	str = str.replace("<P", "");
	str = str.replace("_fckxhtmljob=", "");
	str = str.replace("\"", "");
	str = str.replace("\"", "");
	str = str.replace(">", "");
	if (!isNaN(str))
	{
		str = str.replace(str, "");
	}	

     	if(str == "")
     		return false;
     	else
     		return true;
}

