function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//-->
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/******************************************
Function name : getMasterString
Return type : boolean
Comments : Function will return the main string
User instruction : getMasterString()
******************************************/
function getMasterString()
{
    return "Sorry, we can not complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n";
}


/******************************************
Function name : toggleOption
Return type : None
Comments : Function will toggle the select all checkbox option.
User instruction : toggleOption(spanChk)
******************************************/
function toggleOption(spanChk)
{
    var xState=spanChk.checked;
    var theBox=spanChk;

    elm=theBox.form.elements;
    for(i=0;i<elm.length;i++)
    {
        if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
        {
            if(xState == false)
                elm[i].checked = false;
            else
                elm[i].checked = true;
        }
    }
}

/******************************************
Function name :deSelectCheckbox
Return type :none
Comments : Function will deSelect the main check box
User instruction : deSelectCheckbox()
******************************************/

function deSelectCheckbox(formname)
{
    
	document.forms[1].selectAll.checked=false;
}

/******************************************
Function name : askConfirm
Return type : boolean
Comments : Function will return the true or false after asking for confirmation
User instruction : askConfirm(type)
******************************************/
function askConfirm(type)
{    
    
    var sen = "Are you sure you want to "+type+"?";
    if(confirm(sen))
        return true;
    else
        return false;
}

/******************************************
    Function name : setValidAction
    Return type : boolean
    comments : JavaScript to perform valid actin for the list.
 ******************************************/
function setValidAction(value,formname,filename,action)
{

        if(value == 'Delete')
        {
            message = "delete selected "+filename;        
        }
        var flag = validator(message,formname);            
        if(flag)
        {
            if(value == 'Delete')
            {
                formname.action = action+'?act=del';
            }
            formname.submit();
        }
        else
        {
            
            //formname.frmChangeAction.value='';    
            document.forms[1].selectAll.checked=false;                
            elm=document.forms[1].elements;
            //alert(elm.length); return false;
            for(i=0;i<elm.length;i++)
            {
                if(elm[i].type=="checkbox")
                {            
                    elm[i].checked = false;
                
                }
            }
            return false;
			
        }
}

/******************************************
Function name : validator
Return type : boolean
Comments : Function will return the true or error message after validating checkboxes
User instruction : validator(btnType)
******************************************/
var btnType;
function validator(btnType,formname)
{
    
    var obj = formname;
    var error="", flagCheck=0;
    
    var len = obj.elements.length; 
      
    var i=0;
     
    for(i=0;i<len;i++) 
    {
        if(obj.elements[i].type=='checkbox')
        {
            if(obj.elements[i].checked)
            {
                //if(btnType == 'Delete')
                    return askConfirm(btnType);
                //else
                    //return true;
            }
            else
                flagCheck = 1;
        }
    }
   
    if(flagCheck == 1)
        error += "\nPlease select at least one record.";
            
    return checkError(error);
}




/******************************************
Function name : checkError
Return type : boolean
comments : Function will return the true or false acording to form validation
User instruction : checkError(error)
******************************************/
function checkError(error)
{      
 
    var flag=false;
    var MasterString = getMasterString();
      //alert(error); return false;  
    if(error != "")
    {
        MasterString = MasterString + error;
        flag=true;
    }
    
    if(flag == true)
    {
        alert(MasterString);
        return false;
    }
    else
        return true;
}

function isNumberKey(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;

 return true;
}

/* check file extension */
var error = "";
extArray = new Array(".gif", ".jpg", ".png", ".jpeg");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) 
{
error = "";
}
else
{
error = "Please only upload files that end in types:  " 
+ (extArray.join("  ")) + "\nPlease select a new "
+ "file to upload and submit again.";
}
return error;
}
/* End check file extension */


function validateForm() 
{ 
    var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
    j=0;
    //    /^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)$/;
    //var regEmail = /^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/;
    var regEmail = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$";
    var regBlank = /[^\s]/;
    //var regSpace = /[\s]/;
    var regSpace = /^([a-zA-Z0-9-/_!#@]+)$/;
    //var regAlphaNum = /^([a-zA-Z0-9-/_ :;#!@\n\r.,$*&%?^~`=+(){}\[\]\"\'\\]+)$/;
    var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
     var regDate = /^([0-9_]+-[0-9][0-9]+-[0-9][0-9]+)$/; 
   var regChar = /^([a-zA-Z]+)$/;
    var MasterString = getMasterString(); 
    //alert (validateForm.arguments[1].name);
    //alert("sss--->"+document.forms[""+args[0]].elements[""+args[0]].value);
    for (i=1; i<(args.length-2); i+=3) 
    {    
        mesg=args[i+1];
        test=args[i+2]; 
        val=document.forms[""+args[0]].elements[""+args[i]];
        
            if (val) 
            {    
                nm=mesg; 
                noVal = val;
                val = val.value;
                
            if(test=='BLNK')
            {
             if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
             if (val<0) errors+='- '+nm+' must contain a number.\n';
             }            
             else if(test=='CHKURL' && val !="")
                {
                    p=val.indexOf('http://');
                    s=val.indexOf('.');
                    if (p<0 || p==(val.length-1))
                    {
                        errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
        
                    }
                    else if(s<p || s==(val.length-1))
                    {
                        errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
                    }

                }
             else
                {
            if(regBlank.test(val))
            {
                if(test.indexOf('isEqual')!=-1)
                {
                    result = trim(val);

                if(result.length==0){
                                        
                errors += '- '+nm+' is required.\n'; 
                }else{
                    
                    equal_obj_val = test.substring(8,test.indexOf(":"));
                    mesg_string =test.substring((test.indexOf(":")+1));

                    if(val != document.forms[""+args[0]].elements[""+equal_obj_val].value)
                    { 
                        errors+='- '+nm+' and '+mesg_string+' must be same.\n';
                    }
                }
                }
                else if(test.indexOf('isAlphaNum')!=-1)
                {
                result = trim(val);
                if(result.length==0){
                errors += '- '+nm+' is required.\n'; 
                }else{
                    if(!regAlphaNum.test(val))
                    {
                        errors += '- '+nm+' is not valid.\n';
                        //errors+='- '+nm+': Only Alpha Numeric and "_ , . - ! @ # () {} [] " coma,  single cots and Chars Allowed.\n';
                    }
                }
                
                }
                else if(test.indexOf('isSpace')!=-1)
                {
                result = trim(val);
                
                if(result.length==0)
                {
                    errors += '- '+nm+' is required.\n'; 
                }
                else
                {
                    if(!regSpace.test(val))
                    {
                        errors+='- '+nm+': Only Alpha Numeric and "_ - ! @ # " Allowed.\n';
                        //errors += '- '+nm+' is not valid.\n';
                    }
                }
                }
                else if (test.indexOf('isDate')!=-1) 
                { 
                    p=val.indexOf('-');
                   // alert(test.indexOf('isDate'));
                       var sliptdate    = val.split("-");
                    
                    /*******************Added by rupesh Date is not before current date and month*********************/
                    var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate(),TH=today.getHours();
                    TM+=1;            
                    if(TM<=9) 
                    {    
                        TM='0'+TM;
                    }
                    if(TD<=9)
                    {
                        TD='0'+TD;
                    }
                    /*******************Added by rupesh*********************/
                    
                    var sY=sliptdate[0];
                    var sM=sliptdate[1];
                    var sD=sliptdate[2];
                    
                    /*******************Added by rupesh*********************/
                    //alert(TM);
                    if(sY<TY ) {
                        
                        errors+='- '+nm+' should be greater than current date.\n';
                    }
                    else if(sM==TM && sD<TD && sY==TY) { 

                        errors+='- '+nm+' should be greater than current date.\n';
                        
                    }
                    else if(sM<TM && sY==TY) { 

                        errors+='- '+nm+' should be greater than current date.\n';
                        
                    }
                    
                    /*************************Added by rupesh********************/
                    else if (p != 4 || sY.length != 4 || sM.length != 2 || sD.length != 2 )
                    {
                        errors+='- '+nm+' must contain Valid Date YYYY-MM-DD.\n';
        
                    }
                    else if(!regDate.test(val))
                    {
                        errors+='- '+nm+'  must contain Valid Date YYYY-MM-DD.\n';
                    }
                    else if(sM>12 || sD>31 || sY<2006)
                    {
                        errors+='- '+nm+'  must contain Valid Date YYYY-MM-DD.\n';
                    }
                 }
                else if (test.indexOf('isEmail')!=-1) 
                { 
                    p=val.indexOf('@');
                    s=val.indexOf('.');
                    if (p<1 || p==(val.length-1))
                    {
                        errors+='- '+nm+' must contain an e-mail Address.\n';
        
                    }
                    //else if(s<p || s==(val.length-1))
                    else if(!regEmail.test(val))
                    {
                        errors+='- '+nm+' must contain a valid e-mail Address.\n';
                    }
                 }
                else if (test.indexOf('isUrl')!=-1) 
                { 
                    p=val.indexOf('http://');
                    s=val.indexOf('.');
                    if (p<0 || p==(val.length-1))
                    {
                        errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
        
                    }
                    else if(s<p || s==(val.length-1))
                    {
                        errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
                    }
                 }
                 else if(test.indexOf('isMp3')!=-1)
                 {
                    function reverse(val) 
                    {    
                        var length = val.length;
                        var letters = new Array(length);
                        var letters2 = new Array(length);
                        var backword = "";
                        for (i=0; i<=length-1; i++) 
                        {
                            letters[i] = val.substring(i, i+1);
                        }
                        f = 0
                        for (j=i-1; j>=0; j--) 
                        {
                            letters2[f] = letters[j];
                            f++;
                        }
                        for (h=0; h<=letters2.length-1; h++) 
                        {
                            backword +=letters2[h];
                        }
                         return backword;
                    }
                    var back = reverse(val);
                    var ValExt    = back.split(".");
                    var ValExt = reverse(ValExt[0]);
                    
                    if (ValExt == "mp3" || ValExt == "MP3") 
                    {
                        flag="yes";
                    } 
                    else 
                    {
                        flag="no";                        
                    } 
                    if(flag=="no")
                    {
                        errors+='- '+nm+' must be (mp3).\n';                        
                    }
                 
                 }
                 else if (test.indexOf('isChar')!=-1) 
                 { 
                    var first_char;
                    
                    if(val.match(regChar)==null)
                    {
                         errors+='- '+nm+' must contain a character.\n';
                    }
                 }
                 else if(test.indexOf('isCheckbox')!=-1)//Check is check box is not checked generate error
                {    
                    var valueCheckbox = noVal.checked;
                    if(!valueCheckbox)
                    {
                        errors+='- '+'You must accept Privacy Policy and Terms of Use.\n';
                    }
                }
				 else if (test!='R' || test=='Numbers') 
                 {
                 result = trim(val);
                    if(result.length==0){
                        
                        if(errors.indexOf('Phone') == -1)
                    errors += '- '+nm+' is required.\n'; 
                    }
                    
                    if (isNaN(val)) 
                    {
                     if(errors.indexOf('Phone') == -1)
                     errors+='- '+nm+' must contain a number.\n';
                    }
                    else
                    {
                    if(test=='Numbers' && !isNaN(val))
                    {
                    var i1;
                    var num1=0;
                        for (i1 = 0; i1 < val.length; i1++)
                        {   
                            // Check that current character is number.
                            var c = val.charAt(i1);
                            if (((c < "0") || (c > "9"))) num1=1;
                        }
                        if(num1==1)
                        {
                            if(errors.indexOf('Phone') == -1)
                            errors+='- '+nm+' can only contain numbers.\n';
                        }
                    }
                 }
                    if (test.indexOf('inRange') != -1) 
                    { num = parseFloat(val);
                        p=test.indexOf(':');
                        min=test.substring(8,p); 
                        max=test.substring(p+1);
                        
                        if (num<min || max<num) 
                            if(min==max)
                            {
                              if(min==1 && max==1 & num==0)
                                {
                            errors+='- '+nm+' should  be more than '+min+'.\n';
                                }
                                if(min!=1 && max!=1 && min==max)
                                {
                            errors+='- '+nm+' should not be more than '+min+'.\n';
                                }
                            }                
                            
                        else
                        {
                        errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
                        }
                    } 
                    if (val.indexOf('-') != -1) 
                    { 
                        errors='- '+nm+' must contain a number.\n';
                    } 
                    if (val.indexOf('+') != -1) 
                    { 
                        errors='- '+nm+' must contain a number.\n';
                    }
                    
                }else if (test.charAt(0)=='R')
                {
                result = trim(val);
                if(result.length==0){
                    
                errors += '- '+nm+' is required.\n'; 
                }
                } 
            }
            else if (test.charAt(0) == 'R' || test=='Numbers'){
                if(errors.indexOf('Phone') == -1 && test=='Numbers')
                {
                errors += '- '+nm+' is required.\n'; 
                }
                if (test.charAt(0) == 'R')
                {                    
                errors += '- '+nm+' is required.\n';     
                }
            }
        }
            }
        if(errors !="")
        {    if(j<=0)
            {
                focusitem = document.forms[""+args[0]].elements[""+args[i]];
                j++;
            }    
        }
    } 
    
  if (errors)
  {
    
    alert( MasterString+'\n' +errors);
    focusitem.focus();
    return false;
   }
   else
    return true;
  document.MM_returnValue = (errors == '');
}


function stripHTML(str){
      var re= /<\S[^><]*>(&nbsp;)*/g ;
      return str.replace(re, "") ;
}

function ltrim(str) { 
    for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
    return str.substring(k, str.length);
}

function rtrim(str) {
    for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
    return str.substring(0,j+1);
}


function trim(str) {
    return ltrim(rtrim(str));
}


function isWhitespace(charToCheck) {
    var whitespaceChars = " \t\n\r\f";
    return (whitespaceChars.indexOf(charToCheck) != -1);
}



/***********************************************
function name : checkEditCategory(formname)
Comment : this is used for check category field is empty or not
************************************************/
function checkEditCategory(formName)
{
    if(validateForm(formName,'frmCategoryName','Category Name','R'))
      {  
            return true;
      } 
      else 
      {
           return false;
      }
    
}

/***********************************************
function name : checkValidNewsLetter(formname)
Comment : this is used for check news letter form filed
************************************************/
function checkValidNewsLetter(formName)
{
    if(validateForm(formName,'frmTitle','Newsletter title','R'))
      {  
            return true;
      } 
      else 
      {
           return false;
      }
    
}

/***********************************************
function name : checkValidNewsLetterSend(formname)
Comment : this is used for check add/edit question form filed
************************************************/
function checkValidNewsLetterSend(formname)
{
	   var MasterString = getMasterString();
	   var errorString = '';
	   
	   total_option=document.frmNewsLetterSend.sendNewsUser.options.length;
	   boolCheck=document.frmNewsLetterSend.sendNewsLetterAll.checked;
	  
		   var j=0;
		   for(i=0;i<total_option;i++)
		   {
			  if(document.frmNewsLetterSend.sendNewsUser[i].value == '' && document.frmNewsLetterSend.sendNewsUser[i].selected)
			  {
				   j=0;
				   break;
			  }
			  else
			  {
				  j=j+1;
				  break;	
			  }
		   }
		   
		   for(i=0;i<total_option;i++)
		   {
			   if(!document.frmNewsLetterSend.sendNewsUser[i].selected)
			   {
					if(i == (total_option-1))
					{
				   	    boolChekMultiBox = true;	
					}

			   }
			   else
			   {
				   boolChekMultiBox = false;
				   break;
			   }

		   }
		   
	   if(document.getElementById('frmTitle').value == '') 
       {
              errorString += '- Newsletter title is required.\n';     
       }
       if(document.getElementById('frmSubject').value == '') 
       {
              errorString += '- Newsletter Subject is required.\n';     
       }
       
	   if(boolChekMultiBox && !document.frmNewsLetterSend.sendNewsLetterAll.checked)
	   {
		   errorString += '- Either select atleast one user from select box OR tick check box for send news letter to all user.\n';
	   }
	   if(j==0)
	   {
		   errorString += '- Either select atleast one user from select box OR tick check box for send news letter to all user.\n'; 
	   }
	   if(errorString == '')
       {
            return true;  
       }
       else
       {
            alert(MasterString+' \n '+errorString); 
            return false;   
        } 
}

/***********************************************
function name : checkValidQuestion(formname)
Comment : this is used for check add/edit question form filed
************************************************/
function checkValidQuestion(formName)
{

	    var MasterString = getMasterString();
        var errorString = '';
        var boolfocus = false;
        var elementID ;
		var contentQuestion   = FCKeditorAPI.GetInstance('frmQuestion').GetXHTML();
		var contentFrmOption1 = FCKeditorAPI.GetInstance('frmOption1').GetXHTML();
		var contentFrmOption2 = FCKeditorAPI.GetInstance('frmOption2').GetXHTML();
		var contentFrmOption3 = FCKeditorAPI.GetInstance('frmOption3').GetXHTML();
		var contentFrmOption4 = FCKeditorAPI.GetInstance('frmOption4').GetXHTML();
        
		// condition for checked radio button is checked or not 
		count=document.frmQuestionAdd.frmanswer.length;
		var boolRadio = false;
		//alert(document.getElementById('frmQuestion').value+'aaaaa');
        for(i=0;i<count;i++)
		{
				  if(document.frmQuestionAdd.frmanswer[i].checked)
				  {
					  boolRadio = true;
					  break;
				  }
				  else
				  {
					  boolRadio = false;
					  continue;
 
				  }
		}
        // end condition here 
       if(document.getElementById('frmQuestionCategory').value == '') 
       {
              errorString += '- Category is required.\n';     
              boolfocus = true; 
              elementID = 'frmQuestionCategory';     
       }
	   
	   if(contentQuestion == '') 
       {
              errorString += '- Question is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmQuestion';     
              }
       }
	   if(contentFrmOption1 == '') 
       {
              errorString += '- Option1 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption1';     
              }
       }
	   if(contentFrmOption2 == '') 
       {
              errorString += '- Option2 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption2';     
              }
       }
	   if(contentFrmOption3 == '') 
       {
              errorString += '- Option3 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption3';     
              }
       }
	   if(contentFrmOption4 == '') 
       {
              errorString += '- Option4 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption4';     
              }
       }
	   
	   
       /*if(document.getElementById('frmQuestion').value == '') 
       {
              errorString += '- Question is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmQuestion';     
              }
       }
	   if(document.getElementById('frmOption1').value == '') 
       {
              errorString += '- Option1 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption1';     
              }
       }
	   if(document.getElementById('frmOption2').value == '') 
       {
              errorString += '- Option2 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption2';     
              }
       }
	   if(document.getElementById('frmOption3').value == '') 
       {
              errorString += '- Option3 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption3';     
              }
       }
	   if(document.getElementById('frmOption4').value == '') 
       {
              errorString += '- Option4 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmOption4';     
              }
       }*/	
	   
	   if(!boolRadio)
	   { 	
			errorString += '- Please select one answer .\n';
	   }
			   
	   if(errorString == '')
       {
            return true;  
       }
       else
       {
            alert(MasterString+' \n '+errorString); 
            if(boolfocus)
            {
             document.getElementById(elementID).focus();
            }
            return false;   
        } 
	
}

function showQuestion(str)
{ 
	//doAjax('getQuestion.php','q='+str, 'showQuestionList' );
	//alert(str); return false;
	var pars 	= Form.serialize('questionListing');
	var myAjax =  new Ajax.Request('getQuestion.php?q='+str,{method:'post',cache:false,parameters: pars, onLoading: textSearchLoad, onComplete: showQuestionList} );
}
function textSearchLoad() 
{
    $('searchLoad').style.display = '';
}
function showQuestionList(originalRequest) 
{
   //alert(originalRequest.responseText);
   strQuestion = originalRequest.responseText;
   $('searchLoad').style.display = 'none';
   //alert(strQuestion); 
   if(strQuestion == 'complete')
   {
   		window.location.href='test_score.php?act=complete';
        //window.location.href='invite_friend.php?act=complete';
		//document.getElementById("quetionhere").innerHTML=originalRequest.responseText;
   }
   else if(strQuestion == 'vanish')
   {
	    window.location.href='test_score.php?act=vanish';
   }
   else
   {
	   //alert(originalRequest.responseText);
       document.getElementById("quetionhere").innerHTML=originalRequest.responseText;
       
   }
} 
//function showQuestionList (showlist) 
//{
//   document.getElementById("quetionhere").innerHTML=showlist;   
//} 
//function CheckQuestionAnsqwer(QuestAns)
//{
//	doAjax('getQuestion.php','qa='+QuestAns, 'showQuestionAnsStatus' );
//}
//function showQuestionAnsStatus(showStatus)
//{
//	alert(showStatus); 
//}

function isNumberKey(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 
 if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;

 return true;
}

function checkType(val)
{
    if(val == 'R')
    {
        document.getElementById('scoreRangeFrom').disabled = false;
        document.getElementById('scoreRangeTo').disabled = false;  
    }
    if(val == 'GT')
    {
        document.getElementById('scoreRangeFrom').disabled = false;
        document.getElementById('scoreRangeTo').disabled = true; 
    }
    
    if(val == 'LT')
    {
        document.getElementById('scoreRangeFrom').disabled = true;
        document.getElementById('scoreRangeTo').disabled = false; 
    }
}

function checkValidScoreRange(formname)
{
    var MasterString = getMasterString();
    var errorString = '';
    var boolfocus = false;
    var boolR     = false;
    var boolGT    = false;
    var boolLT    = false;
    var elementID ;
    
    if(document.getElementById('scoreRangeTypeR').checked)
    {
        boolR = true;
        
    }
    if(document.getElementById('scoreRangeTypeGT').checked)
    {
        boolGT = true;
        
    }
    if(document.getElementById('scoreRangeTypeLT').checked)
    {
        boolLT = true;
        
    }
    
    if(document.getElementById('scoreRangeTitle').value == '') 
    {
          errorString += '- Score range title is required.\n';     
          boolfocus = true; 
          elementID = 'scoreRangeTitle';     
    }
    

    
    if(boolR)
    {
    
        if(document.getElementById('scoreRangeFrom').value == '') 
        {
              errorString += '- Score range from is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'scoreRangeFrom';     
              }
        }
        if(document.getElementById('scoreRangeTo').value == '') 
        {
              errorString += '- Score range to is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'scoreRangeTo';     
              }
        }
        if(document.getElementById('scoreRangeFrom').value != '' && document.getElementById('scoreRangeTo').value != '') 
        {
              
              if(document.getElementById('scoreRangeFrom').value >= document.getElementById('scoreRangeTo').value )
              {
                  errorString += '- Score range from can not be greater than from score range to or equal.\n';     
                  if(!boolfocus )
                  {
                    boolfocus = true; 
                    elementID = 'scoreRangeFrom';     
                  }
              }    
        }
        
    }
    if(boolGT)
    {
         if(document.getElementById('scoreRangeFrom').value == '') 
        {
              errorString += '- Score range from is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'scoreRangeFrom';     
              }
        }
    }
    
    if(boolLT)
    {
         if(document.getElementById('scoreRangeTo').value == '') 
        {
              errorString += '- Score range To is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'scoreRangeTo';     
              }
        }
    }
    
    if(document.getElementById('scoreRangePercent').value == '') 
    {
          errorString += '- Score range percent is required.\n';     
          if(!boolfocus )
          {
            boolfocus = true; 
            elementID = 'scoreRangePercent';     
          }
    }
    else if(isNaN(document.getElementById('scoreRangePercent').value)) 
    {
          errorString += '- Score range percent can be numeric only.\n';     
          if(!boolfocus )
          {
            boolfocus = true; 
            elementID = 'scoreRangePercent';     
          }
    }
   
    if(errorString == '')
    {
       
       document.frmScoreRangeAdd.action = document.frmScoreRangeAdd.action;
       document.frmScoreRangeAdd.submit(); 
       return true; 
    }
   else
   {
        alert(MasterString+' \n '+errorString); 
        if(boolfocus)
        {
         document.getElementById(elementID).focus();
        }
        return false;   
    } 
   // return false;
     
        
}


function checkTypeCat(val)
{
    if(val == 'R')
    {
        document.getElementById('catScoreRangeFrom').disabled = false;
        document.getElementById('catScoreRangeTo').disabled = false;  
    }
    if(val == 'GT')
    {
        document.getElementById('catScoreRangeFrom').disabled = false;
        document.getElementById('catScoreRangeTo').disabled = true; 
    }
    
    if(val == 'LT')
    {
        document.getElementById('catScoreRangeFrom').disabled = true;
        document.getElementById('catScoreRangeTo').disabled = false; 
    }
}

function checkValidCatScoreRange(formname)
{
    var MasterString = getMasterString();
    var errorString = '';
    var boolfocus = false;
    var boolR     = false;
    var boolGT    = false;
    var boolLT    = false;
    var elementID ;
    if(document.getElementById('catScoreRangeTypeR').checked)
    {
        boolR = true;
        
    }
    if(document.getElementById('catScoreRangeTypeGT').checked)
    {
        boolGT = true;
        
    }
    if(document.getElementById('catScoreRangeTypeLT').checked)
    {
        boolLT = true;
        
    }
    
    if(boolR)
    {
    
        if(document.getElementById('catScoreRangeFrom').value == '') 
        {
              errorString += '- Category Score range from is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'catScoreRangeFrom';     
              }
        }
        if(document.getElementById('catScoreRangeTo').value == '') 
        {
              errorString += '- Category Score range to is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'catScoreRangeTo';     
              }
        }
        if(document.getElementById('catScoreRangeFrom').value != '' && document.getElementById('catScoreRangeTo').value != '') 
        {
              
              if(document.getElementById('catScoreRangeFrom').value >= document.getElementById('catScoreRangeTo').value )
              {
                  errorString += '- Category Score range from can not be greater than from category score range to or equal.\n';     
                  if(!boolfocus )
                  {
                    boolfocus = true; 
                    elementID = 'catScoreRangeFrom';     
                  }
              }    
        }
        
    }
    if(boolGT)
    {
         if(document.getElementById('catScoreRangeFrom').value == '') 
        {
              errorString += '- Category Score range from is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'catScoreRangeFrom';     
              }
        }
    }
    
    if(boolLT)
    {
         if(document.getElementById('catScoreRangeTo').value == '') 
        {
              errorString += '- Category Score range To is required.\n';     
              if(!boolfocus )
              {
                boolfocus = true; 
                elementID = 'catScoreRangeTo';     
              }
        }
    }
    
   
    if(errorString == '')
    {
       document.frmCatScoreRangeAdd.action = document.frmCatScoreRangeAdd.action;
       document.frmCatScoreRangeAdd.submit();
	   //document.getElementById('frmCateScoreRangeAdd').action='cat_score_range_act.php';
	   //document.getElementById('frmCateScoreRangeAdd').submit();
	  //document.frmCateScoreRangeAdd.action = 'cat_score_range_act.php';
	   return true; 
    }
   else
   {
        alert(MasterString+' \n '+errorString); 
        if(boolfocus)
        {
         document.getElementById(elementID).focus();
        }
        return false;   
    } 
   // return false;
     
        
}

function checkLoginUser()
{
     var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
     if(document.getElementById('userName').value == '') 
     {
         errorString += ' - User Name is required.\n';     
         boolfocus = true; 
         elementID = 'userName';     
     }
     if(document.getElementById('password').value == '') 
     {
         errorString += ' -  Password is required.\n';     
         if(!boolfocus) 
          elementID = 'password';     
     }
     if(errorString == '')
     {
        document.loginForm.action = 'test_login.php?login=y';
        //return oi_button_onclick();
		document.loginForm.submit();
        return true;  
     }
     else
     {
        alert(MasterString+' \n '+errorString); 
        if(boolfocus)
        {
         document.getElementById(elementID).focus();
        }
        return false;   
     }
}
function userRegistercheck()
{
	 var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  	 //var regSpace = /^([a-zA-Z0-9-/_#@!]+)$/;
     var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var regNumeric = /^([0-9]+)$/; 
     var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
	
		if(document.getElementById('userName').value == '')
		{
			errorString += '- User Name is required.\n';     
            boolfocus = true; 
            elementID = 'userName';
		}
		if(document.getElementById('password').value == '')
		{
			errorString += '-  Password is required.\n';     
            if(!boolfocus) 
              elementID = 'password'; 
			
		}
		else if(!regAlphaNum.test(document.getElementById('password').value))
		{
			errorString += '- Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
            if(!boolfocus) 
              elementID = 'password'; 
		}
		else if(document.getElementById('password').value.length<5 || document.getElementById('password').value.length>20)
		{
			errorString += '- Password length should be in between 5 to 20 character.\n';     
            if(!boolfocus) 
              elementID = 'password';
			
		}   
			
		if(document.getElementById('firstName').value == '')
		{
			errorString += '- First name is required.\n';     
            if(!boolfocus) 
              elementID = 'firstName';
		}
		if(document.getElementById('lastName').value == '')
		{
			errorString += '- Last name is required.\n';     
            if(!boolfocus) 
              elementID = 'lastName';
		}
		if(document.getElementById('email').value == '')
		{
			errorString += '- Email is required.\n';     
            if(!boolfocus) 
              elementID = 'email';
		}
		else if(!regEmail.test(document.getElementById('email').value))
		{
			errorString += '- Email should be in proper format.\n';     
            if(!boolfocus) 
              elementID = 'email';
		}
		
		if(document.getElementById('state').value == '')
		{
			errorString += '- State name is required.\n';     
            if(!boolfocus) 
              elementID = 'state';
		}
		if(document.getElementById('zipcode').value == '')
		{
			errorString += '- Zipcode name is required.\n';     
            if(!boolfocus) 
              elementID = 'zipcode';
			
		}
		//else if(!regNumeric.test(document.getElementById('zipcode').value))
//		{
//			alert('Only digites are allowed for zipcode.');
//			return false;
//		}
		if(document.getElementById('telephone').value == '')
		{
			errorString += '- Telephone is required.\n';     
            if(!boolfocus) 
              elementID = 'telephone';
		}
		if(errorString == '')
        {
          document.registerForm.action = 'test_register.php?register=register';
          return oi_button_onclick();
		  //document.registerForm.submit();
          //return true;  
        }
        else
        {
           alert(MasterString+' \n '+errorString); 
          if(boolfocus)
          {
            document.getElementById(elementID).focus();
          }
          return false;   
        }
}

function checkForgot()
{
     var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
    
    if(document.getElementById('userName').value == '')
    {
        errorString += '- User Name is required.\n';     
        if(!boolfocus) 
          elementID = 'userName';
    }
    if(errorString == '')
    {
      document.forgotForm.action = 'forgot_password.php?forgot=forgot';
      document.forgotForm.submit();
      return true;  
    }
    else
    {
       alert(MasterString+' \n '+errorString); 
      if(boolfocus)
      {
        document.getElementById(elementID).focus();
      }
      return false;   
    }
}

function checkInviteEmail(formname)
{
    var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    var MasterString = getMasterString();
    var error ='';
    
   if((document.getElementById('inviteEmail1').value == '' && document.getElementById('inviteName1').value == '' ) && (document.getElementById('inviteEmail2').value == '' && document.getElementById('inviteName2').value == '' ) && (document.getElementById('inviteEmail3').value == '' && document.getElementById('inviteName3').value == '' ))
   {
        error += 'Please fill atleast one name and email for invite your friend.\n';    
   } 
   else
   { 
    if(document.getElementById('inviteEmail1').value != '')
    {
        if(document.getElementById('inviteName1').value == '')
        {
            error += 'Name1 is required.\n';
        }
        if(!regEmail.test(document.getElementById('inviteEmail1').value))
        {
            error += 'Email1 is not valid.\n';
        }
    }
    if(document.getElementById('inviteName1').value != '')
    {
        if(document.getElementById('inviteEmail1').value == '')
        {
            error += 'Email1 is required.\n';
        }
    }
    
    if(document.getElementById('inviteEmail2').value != '')
    {
        if(document.getElementById('inviteName2').value == '')
        {
            error += 'Name2 is required.\n';
        }
        if(!regEmail.test(document.getElementById('inviteEmail2').value))
        {
            error += 'Email2 is not valid.\n';
        }
    }
    if(document.getElementById('inviteName2').value != '')
    {
        if(document.getElementById('inviteEmail2').value == '')
        {
            error += 'Email2 is required.\n';
        }
    }
    
    if(document.getElementById('inviteEmail3').value != '')
    {
        if(document.getElementById('inviteName3').value == '')
        {
            error += 'Name3 is required.\n';
        }
        if(!regEmail.test(document.getElementById('inviteEmail3').value))
        {
            error += 'Email3 is not valid.\n';
        }
    }
    if(document.getElementById('inviteName3').value != '')
    {
        if(document.getElementById('inviteEmail3').value == '')
        {
            error += 'Email3 is required.\n';
        }
    }
   }  
    //for(i=1;i<=10;i++)
//    {
//        strEmail = 'inviteEmail'+i;
//        if(document.getElementById(strEmail).value)
//        {
//            if(!regEmail.test(document.getElementById(strEmail).value))
//            {
//                error += 'Email '+i+' is not valid.\n';
//            }
//        }    
//    }
    if(error != '')
    {
        alert(MasterString+' \n '+error);
        return false;
    }
    else
    {
        return true;
    }    
}

function userProfileCheck()
{
	 var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var regNumeric = /^([0-9]+)$/; 
     var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
	 var error = "";
     extArray = new Array(".gif", ".jpg", ".png", ".jpeg");
	 
	   if(document.getElementById('state').value == '')
		{
			errorString += '- State name is required.\n';     
			if(!boolfocus) 
			  elementID = 'state';
		}
		if(document.getElementById('zipcode').value == '')
		{
			errorString += '- Zipcode is required.\n';     
			if(!boolfocus) 
			  elementID = 'zipcode';
			
		}
		
		if(document.getElementById('telephone').value == '')
		{
			errorString += '- Telephone is required.\n';     
			if(!boolfocus) 
			  elementID = 'telephone';
		}
		
		if(document.getElementById('frmProductImage').value != '')
		{
			
			
			file = document.getElementById('frmProductImage').value;
			img_error = LimitAttach("registerForm", file);
			if(img_error != '') 
			{
  			   errorString += img_error;     
			 
			}
		}
		
		if(errorString == '')
		{
		  document.registerForm.action = 'edit_profile.php?profile=profile';
		  document.registerForm.submit();
		  return true;  
		}
		else
		{
		   alert(MasterString+' \n '+errorString); 
		  if(boolfocus)
		  {
			document.getElementById(elementID).focus();
		  }
		  return false;   
		}
}

function userPlaqueCheck()
{
	 var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var regNumeric = /^([0-9]+)$/; 
     var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
	 var error = "";
     //alert('sssss'); return false;
	   if(document.getElementById('plaqueFirstName').value == '')
		{
			errorString += '- First name is required.\n';     
			if(!boolfocus) 
			  elementID = 'palqueFirstName';
		}
		
		if(document.getElementById('plaqueLastName').value == '')
		{
			errorString += '- Last name is required.\n';     
			if(!boolfocus) 
			  elementID = 'palqueLastName';
		}
	   
	   if(document.getElementById('plaqueAddress').value == '')
		{
			errorString += '- Address is required.\n';     
			if(!boolfocus) 
			  elementID = 'plaqueAddress';
			
		}
	   
	   if(document.getElementById('plaqueCity').value == '')
		{
			errorString += '- City is required.\n';     
			if(!boolfocus) 
			  elementID = 'plaqueCity';
		}
	   
	   if(document.getElementById('plaqueState').value == '')
		{
			errorString += '- State name is required.\n';     
			if(!boolfocus) 
			  elementID = 'plaqueState';
		}
		if(document.getElementById('plaqueZipCode').value == '')
		{
			errorString += '- Zipcode is required.\n';     
			if(!boolfocus) 
			  elementID = 'plaqueZipCode';
			
		}
		
		
		if(errorString == '')
		{
		  document.plaqueUserForm.action = 'plaque_user_details.php?plaque=plaque';
		  document.plaqueUserForm.submit();
		  return true;  
		}
		else
		{
		   alert(MasterString+' \n '+errorString); 
		  if(boolfocus)
		  {
			document.getElementById(elementID).focus();
		  }
		  return false;   
		}
}

function checkUserPass()
{
 	 //var regSpace = /^[a-zA-Z0-9\-\_\#\@]+$/u; ///^([a-zA-Z0-9-/_!#@]+)$/;
	 var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
		if(document.getElementById('oldPassword').value == '')
		{
			errorString += '- Old Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword'; 
			
		}
		else if(!regAlphaNum.test(document.getElementById('oldPassword').value))
		{
			errorString += '- Old Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword'; 
		}
		else if(document.getElementById('oldPassword').value.length<5 || document.getElementById('oldPassword').value.length>20)
		{
			errorString += '-Old Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword';
			
		}
		
		if(document.getElementById('newPassword').value == '')
		{
			errorString += '- New Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword'; 
			
		}
		else if(!regAlphaNum.test(document.getElementById('newPassword').value))
		{
			errorString += '- New Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword'; 
		}
		else if(document.getElementById('newPassword').value.length<5 || document.getElementById('newPassword').value.length>20)
		{
			errorString += '-New Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword';
			
		}
		
		if(document.getElementById('confirmPassword').value == '')
		{
			errorString += '- Confirm Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		else if(!regAlphaNum.test(document.getElementById('confirmPassword').value))
		{
			  errorString += '- Confirm Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword'; 
		}
		else if(document.getElementById('confirmPassword').value.length<5)
		{
			errorString += '-Confirm Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		if((document.getElementById('newPassword').value) != (document.getElementById('confirmPassword').value))
		{
			errorString += '-Confirm Password and new password does not match.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		
		if(errorString == '')
		{
		  document.changePasswordForm.action = 'change_password.php?pass=pass';
		  document.changePasswordForm.submit();
		  return true;  
		}
		else
		{
		   alert(MasterString+' \n '+errorString); 
		  if(boolfocus)
		  {
			document.getElementById(elementID).focus();
		  }
		  return false;   
		}
		
}
function checkAdminPass()
{
 	 //var regSpace = /^[a-zA-Z0-9\-\_\#\@]+$/u; ///^([a-zA-Z0-9-/_!#@]+)$/;
	 var regAlphaNum = /^([a-zA-Z0-9_#@!]+)$/;
	 var MasterString = getMasterString();
     var errorString = '';
     var boolfocus = false;
     var elementID ;
	 //alert(document.getElementById('oldPassword').value.length<=5); return false;
		if(document.getElementById('oldPassword').value == '')
		{
			errorString += '- Old Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword'; 
			
		}
		else if(!regAlphaNum.test(document.getElementById('oldPassword').value))
		{
			errorString += '- Old Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword'; 
		}
		else if(document.getElementById('oldPassword').value.length<4 || document.getElementById('oldPassword').value.length>20)
		{
			errorString += '-Old Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'oldPassword';
			
		}
		
		if(document.getElementById('newPassword').value == '')
		{
			errorString += '- New Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword'; 
			
		}
		else if(!regAlphaNum.test(document.getElementById('newPassword').value))
		{
			errorString += '- New Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword'; 
		}
		else if(document.getElementById('newPassword').value.length<4 || document.getElementById('newPassword').value.length>20)
		{
			errorString += '-New Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'newPassword';
			
		}
		
		if(document.getElementById('confirmPassword').value == '')
		{
			errorString += '- Confirm Password is required.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		else if(!regAlphaNum.test(document.getElementById('confirmPassword').value))
		{
			  errorString += '- Confirm Password is not valid. Only alpha numeric characters @,# and _ are allowed.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword'; 
		}
		else if(document.getElementById('confirmPassword').value.length<4 || document.getElementById('confirmPassword').value.length>20)
		{
			errorString += '-Confirm Password length should be in between 5 to 20 character.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		
		if((document.getElementById('newPassword').value) != (document.getElementById('confirmPassword').value))
		{
			errorString += '-Confirm Password and new password does not match.\n';     
			if(!boolfocus) 
			  elementID = 'confirmPassword';
		}
		if(errorString == '')
		{
		  document.frmChnagePassWord.action = 'setting_act.php?pass=pass';
		  document.frmChnagePassWord.submit();
		  return true;  
		}
		else
		{
		   alert(MasterString+' \n '+errorString); 
		  if(boolfocus)
		  {
			document.getElementById(elementID).focus();
		  }
		  return false;   
		}
		
}
function checkTerms()
{
	if(document.getElementById('RulesAndRegulation').checked)
	{
		//document.getElementById('btnDisplay').style.display = 'block';
		document.getElementById('btnDisplay').innerHTML = '<input type="image" name="accept" src="images/accept.gif"  style="width:130px;height: 44px;border: 0px;" />';  
	}
	if(document.getElementById('RulesAndRegulation1').checked)
	{
  	   //document.getElementById('btnDisplay').style.display = 'none';
	   document.getElementById('btnDisplay').innerHTML = '<a href="index.php"><img src="images/btn_cancel.gif"/>';  
	}
	
}

function searchMonthRank()
{
	var MasterString = getMasterString();
	if(document.getElementById('monthUserName').value == '')
	{
		alert(MasterString+' \n '+' search field can not be blank');
		return false
	}
	else
	{ 
		return true;
	}
}
function searchAnnualRank()
{
	var MasterString = getMasterString();
	if(document.getElementById('annualUserName').value == '')
	{
		alert(MasterString+' \n '+' search field can not be blank');
		return false
	}
	else
	{ 
		return true;
	}
}


/***********************************************
function name : checkUserValidQuestion(formname)
Comment : this is used for check add question form field from user upload question form to to front end
************************************************/
function checkUserValidQuestion(frmName)
{
		var MasterString = getMasterString();
        var errorString = '';
        var boolfocus = false;
        var elementID ;
		
		var contentUserQuestion   = FCKeditorAPI.GetInstance('frmUserQuestion').GetXHTML();
		var contentUserFrmOption1 = FCKeditorAPI.GetInstance('frmUserOption1').GetXHTML();
		var contentUserFrmOption2 = FCKeditorAPI.GetInstance('frmUserOption2').GetXHTML();
		var contentUserFrmOption3 = FCKeditorAPI.GetInstance('frmUserOption3').GetXHTML();
		var contentUserFrmOption4 = FCKeditorAPI.GetInstance('frmUserOption4').GetXHTML();
        // condition for checked radio button is checked or not 
		//alert(frmName); 
		count = document.frmUserUploadQuestion.frmUseranswer.length;
		//alert( document.frmUserUploadQuestion.frmUseranswer.length );
		//alert(count); return false;
		//alert('ssss'); return false;
		var boolRadio = false;
		
        for(i=0;i<count;i++)
		{
				  //alert( document.frmUserUploadQuestion.frmUseranswer[i].checked );
				  if(document.frmUserUploadQuestion.frmUseranswer[i].checked)
				  {
					  boolRadio = true;
					  break;
				  }
				  else
				  {
					  boolRadio = false;
					  continue;
 
				  }
				  //alert( boolRadio );
		}
        // end condition here 
       if(document.getElementById('frmUserQuestionCategory').value == '') 
       {
              errorString += '- Category is required.\n';     
              boolfocus = true; 
              elementID = 'frmUserQuestionCategory';     
       }
	   
	   if(contentUserQuestion == '') 
       {
              errorString += '- Question is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmUserQuestion';     
              }
       }
	   if(contentUserFrmOption1 == '') 
       {
              errorString += '- Option1 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmUserOption1';     
              }
       }
	   if(contentUserFrmOption2 == '') 
       {
              errorString += '- Option2 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmUserOption2';     
              }
       }
	   if(contentUserFrmOption3 == '') 
       {
              errorString += '- Option3 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmUserOption3';     
              }
       }
	   if(contentUserFrmOption4 == '') 
       {
              errorString += '- Option4 is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmUserOption4';     
              }
       }
	   
       if(!boolRadio)
	   { 	
			errorString += '- Please select one answer .\n';
	   }
	   if(!document.getElementById('copyRight').checked)
       {
            errorString += '- Please accept copy right disclaimer.\n';
       }
       if(!document.getElementById('instruction').checked)
       {
            errorString += '- Please accept instruction.\n';
       }
       if(document.getElementById('reasonCorrectAns').value == '') 
       {
              errorString += '- Reason is required.\n';     
              boolfocus = true; 
              elementID = 'reasonCorrectAns';     
       }
       		   
	   if(errorString == '')
       {
            document.frmUserUploadQuestion.action = 'question_act.php';
			document.frmUserUploadQuestion.submit();
       }
       else
       {
            alert(MasterString+' \n '+errorString); 
            if(boolfocus)
            {
             document.getElementById(elementID).focus();
            }
            return false;   
        } 
	
}


function confirmUserDelQuestion(qID)
{
	if(confirm('Are you sure? You want to delete user question.'))
	{
		window.location.href="question_act.php?act=delete&quest_id="+qID;
	}
	else
	{
		return false;
	}
} 
/***********************************************
function name : checkBoxValid(formname)
Comment : this is used for check add Box data.
************************************************/
function checkBoxValid(frmName)
{
        var MasterString = getMasterString();
        var errorString = '';
        var boolfocus = false;
        var elementID ;
        
        var boxDescription   = FCKeditorAPI.GetInstance('frmBoxDescription').GetXHTML();
        
        if(document.getElementById('frmBoxTitle').value == '') 
       {
              errorString += '- Box Title is required.\n';     
              boolfocus = true; 
              elementID = 'frmBoxTitle';     
       }
       
       if(boxDescription == '') 
       {
              errorString += '- Box Description is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmBoxDescription';     
              }
       }
        if(errorString == '')
       {
            document.frmlandingpage.action = 'page_landing_act.php';
            document.frmlandingpage.submit();
       }
       else
       {
            alert(MasterString+' \n '+errorString); 
            if(boolfocus)
            {
             document.getElementById(elementID).focus();
            }
            return false;   
        } 
        
}        
/***********************************************
function name : checkmetatagValid(formname)
Comment : this is used for check add Box data.
************************************************/
function checkMetaTagValid(frmName)
{
        var MasterString = getMasterString();
        var errorString = '';
        var boolfocus = false;
        var elementID ;
    
    if(document.getElementById('frmPage').value == '') 
       {
              errorString += '- Page Name is required.\n';     
              boolfocus = true; 
              elementID = 'frmPage';     
       }
		if(document.getElementById('frmTitle').value == '') 
       {
              errorString += '- Title is required.\n';     
			  if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmTitle';   
              }
                 
       }
	   if(document.getElementById('frmDescription').value == '') 
       {
              errorString += '- Description is required.\n';     
			 if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmDescription';     
              }		
			 
       }
	    if(document.getElementById('frmKeyword').value == '') 
       {
              errorString += '- Keywords is required.\n';     
              if(!boolfocus )
              {
              boolfocus = true; 
              elementID = 'frmKeyword';     
              }
			  
       }
       
        if(errorString == '')
       {
            document.frmlandingpage.action = 'page_landing_act.php';
            document.frmlandingpage.submit();
       }
       else
       {
            alert(MasterString+' \n '+errorString); 
            if(boolfocus)
            {
             document.getElementById(elementID).focus();
            }
            return false;   
        } 
        
}        