/******************************************
Module name : Js Function file
Parent module : None
Date created : 28 February 2008
Date last modified : 
Author :  Prashant Bhardwaj
Last modified by : 
Comments : The functions_js.js file contains various functions related to the web directory project.
******************************************/	

/*****************************
Function name : resetDate
Return type : none
Date created : 10 March 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to reset the date of a form
User instruction : resetDate()
************************************/
function resetDate()
{
	document.forms[0].frmDate.value = "From";
	document.forms[0].frmTodate.value = "To";
}

/*****************************
Function name : dateCompare
Return type : boolean
Date created : 19 March 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to validate the date compare form and to date.[ From date should be less than to date. ]
User instruction : dateCompare(formname)
************************************/
function dateCompare(formname)
{
	var sliptdate	= document.getElementById(formname).frmTodate.value.split("-");
   	var FromDate  = document.getElementById(formname).frmDate.value.split("-");
	/*********************** From Date *****************/
	var TY = FromDate[0];  //Year
	var TM = FromDate[1];  //Month
	var TD = FromDate[2];  //Date
	/******************* To Date *********************/
	var sY=sliptdate[0];  //Year
	var sM=sliptdate[1];  //Month
	var sD=sliptdate[2];  //Date
			
	if(document.getElementById(formname).frmDate.value != 'From' && document.getElementById(formname).frmTodate.value != 'To')
	{
		if(sY<TY ) 
		{
			alert("'To' date should be greater than 'From' date.");
			return false;	  
		}
		else if(sM==TM && sD<TD && sY==TY) 
		{ 
			alert("'To' date should be greater than 'From' date.");
			return false;
		}
		else if(sM<TM && sY==TY) 
		{ 
			alert("'To' date should be greater than 'From' date.");
			return false;
		}
	}
	
	if(validateForm(formname, 'frmSearchOrderPrice', 'Order Price', 'isNaN'))
	{	
		return true;
	} 
	else 
	{
    	return false;
	} 
	
}

/******************************************
Function name : showSearchBox
Return type : None
Date created : 28 February 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function is used to show hide the seacch box
User instruction : showSearchBox(varDocumentID, varShow)
******************************************/
function showSearchBox(varDocumentID, varShow)
{
	if(varShow == 'show')
	{
	 document.getElementById(varDocumentID).style.display = 'block';	
	}
	else
	{
	  document.getElementById(varDocumentID).style.display = 'none';
	}
	
}
/******************************************
Function name : checkUserName
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to login check using ajax.The ajax login check is a combination of functions all are using to check login system.
User instruction : checkUserName()
******************************************/
/* AJAX LOGIN CHECK CODE START FROM HERE */
function checkUserName() 
{
	
	var alphaNum = /^[0-9a-zA-Z_@.]+$/;
	var Usermail = document.getElementById('frm_login').frmAdminUserName.value;
	var charArray = new Array();
	var tString = "";
	for(i = 0; i < Usermail.length; i++) 
	{
		charArray[i] = Usermail.charAt(i);
	}

	for(i = 0; i < charArray.length; i++) 
	{
		if (charArray[i].match(alphaNum))
		{
			tString += charArray[i];
		}
	}	
	
	if (tString != "")
	{
		checkUserEmail(tString);
	}	
}
 
/******************************************
Function name : checkUserEmail
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to email check using ajax. 
User instruction : checkUserEmail(mailID)
******************************************/ 
function checkUserEmail(mailID)
{ 
	doAjax('ajax_act.php','type=signUp&userEmail='+mailID, 'showUserEmail', 'GET');
}

/******************************************
Function name : showUserEmail
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to display username using ajax. 
User instruction : showUserEmail(item)
******************************************/ 
function showUserEmail(item)
{	

  if(item)
	{
		document.getElementById('showUserName').style.display = 'none';
	}
	else
	{
		document.getElementById('showUserName').style.display = 'block';
	}
}

/******************************************
Function name : toggleOption
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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 : checkPhone
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function will return the true or false according to phone field validation
User instruction : checkPhone(phone)
******************************************/
function checkPhone(phone)
{
	var phoneRequired = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/
	if(!phoneRequired.test(phone))
		return false;
	return true;
}

/******************************************
Function name : getMasterString
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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 : checkError
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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();
	
	if(error != "")
	{
		MasterString = MasterString + error;
		flag=true;
	}
	
	if(flag == true)
	{
		alert(MasterString);
		return false;
	}
	else
		return true;
}

/******************************************
Function name : askConfirm
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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 : validator
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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 += "\n - Please select at least one record.";
			
	return checkError(error);
}
/*****************************
Function name : validateCategoryForm
Return type : boolean
Date created : 27 June 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate the category form
User instruction : validateCategoryForm(formname)
************************************/
function validateCategoryForm(formname)
{
	if(validateForm(formname, 'frmCategoryName', 'Category Name', 'R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	}	
}

/*****************************
Function name : validateProducts
Return type : none
Date created : 30 June 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to validate the sub user form
User instruction : validateProducts(formname)
************************************/
function validateProducts(formname)
{
	var val = document.getElementById('frmImageHidden1').value;	
	if(val == 0)
	{
		if(validateForm(formname, 'frmCategoryID', 'Category', 'R', 'frmProductName', 'Product Name', 'R', 'frmProductImage', 'Product Image', 'R'))
		{  
			return true;
		} 
		else 
		{
			return false;
		}
	}
	else
	{
		if(validateForm(formname, 'frmCategoryID', 'Category', 'R', 'frmProductName', 'Product Name', 'R'))
		{  
			return true;
		} 
		else 
		{
			return false;
		}	
	}
}


/******************************************
Function name : setDecimalValue
Return type : None
Date created : 3 March 2008
Date last modified : 4 March 2008
Author : Prashant Bhardwaj
Last modified by : Prashant Bhardwaj
Comments: Function is used to set decimal values if the value does not contain decimal values it will add .00 the existing value.
User instruction : setDecimalValue(fieldID)
******************************************/
function setDecimalValue(fieldID)
{
     var val = document.getElementById(fieldID).value;
	 if(val != '' )
	 {
		 if(!isNaN(val))
		 {
				 if(val.indexOf(".")<0)
				 {
					  document.getElementById(fieldID).value=val+'.00';
				 }
				else
				{
					var Rate = val.split(".");
					 var Decimal = Rate[1];
					 if(Decimal.length >= 2)
					 {
						document.getElementById(fieldID).value=val;
					 }
					else
					 {
						document.getElementById(fieldID).value=val+'0';
					  }
				}
		 }
	 }
}





/*****************************
Function name : SelectAllList & DeselectAllList
Return type : boolean
Date created : 4 March 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : This function is used to select or deselect all records from multiple select box
User instruction : SelectAllList(formname)
************************************/
function SelectAllList(CONTROL)
{
	for(var i = 0;i < CONTROL.length;i++)
 	{
  		CONTROL.options[i].selected = true;
 	}
}
 
function DeselectAllList(CONTROL)
{
	for(var i = 0;i < CONTROL.length;i++)
 	{
  		CONTROL.options[i].selected = false;
 	}
}


/******************************************
Function name : validateForm
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function will validate the required form
User instruction : validateForm()
******************************************/
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-zA-Z]+(([\.\-_])[0-9a-zA-Z]+)*@[0-9a-zA-Z]+(([\.\-])[0-9a-z-A-Z]+)*\.[a-zA-Z]{2,4}$/;
	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 regNumeric = /^([0-9]+)$/; 
	// var regDecimal = /^([0-9]+|(\.?)[0-9]+)$/;
	var regDecimal = /^([0-9]+\.?[0-9]+)$/;
	
	//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('isNumeric')!= -1)
				{
						if(!regNumeric.test(val))
						{
							errors += '- '+nm+' must contain a numeric value.\n';
							
						}
				}
				else if(test.indexOf('isDecimal') != -1)
				{
					
					if(!regDecimal.test(val))
					{
						errors += '- '+nm+' must contain a number.\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('isBackDate')!=-1) 
				 { 
					p=val.indexOf('-');
			       // alert(test.indexOf('isDate'));
			       	var sliptdate	= val.split("-");
					
					/*******************Added by Gulshan Date is not after 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 Gulshan*********************/
					var sY=sliptdate[0];
					var sM=sliptdate[1];
					var sD=sliptdate[2];
					/*******************Added by Gulshan*********************/
					if(sY>TY ) {
						
						errors+='- '+nm+' should be lesser than current date.\n';
					}
					else if(sM==TM && sD>TD && sY==TY) { 

						errors+='- '+nm+' should be lesser than current date.\n';
						
					}
					else if(sM>TM && sY==TY) 
					{ 
						errors+='- '+nm+' should be lesser 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))
					{
						//alert("pp");
						errors+='- '+nm+'  must contain Valid Date YYYY-MM-DD.\n';
					}
					/*else if(sM>12 || sD>31 || sY<2006)
					{
						alert("ppq2qqqq");
						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 a valid 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) 
				{ 
					val = 'http://'+val;
					p=val.indexOf('http://');
					//p=val.indexOf('www.');
					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+='- '+' Accept terms and Policy.\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 current2 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)
  {
	var MasterString = getMasterString();
	alert(MasterString+'\n'+errors);
	focusitem.focus();
	return false;
   }
   else
	return true;

  document.MM_returnValue = (errors == '');
}

/******************************************
Function name : stripHTML
Return type : string
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function will return the main string after removing HTML tags
User instruction : stripHTML(str)
******************************************/
function stripHTML(str){
      var re= /<\S[^><]*>(&nbsp;)*/g ;
      return str.replace(re, "") ;
}
/******************************************
Function name : ltrim
Return type : string
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function will return the main string after removing white spaces from the left
User instruction : ltrim(str)
******************************************/
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
/******************************************
Function name : rtrim
Return type : string
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function will return the main string after removing white spaces from the right
User instruction : rtrim(str)
******************************************/
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
/******************************************
Function name : trim
Return type : string
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function will return the main string after removing white spaces from the right and left of the main string
User instruction : trim(str)
******************************************/
function trim(str) {
	return ltrim(rtrim(str));
}
/******************************************
Function name : isWhitespace
Return type : integer
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : Function will return the index of white space encounter in the string.
User instruction : isWhitespace(charToCheck)
******************************************/
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

/*****************************
Function name : validateAdminForm
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This is used to check admin login authentications.
User instruction : validateAdminForm(charToCheck)
************************************/
function validateAdminLogin(formname)
{
	if(validateForm(formname,'frmAdminUserName','Username','R', 'frmAdminPassword','Password','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateAdminForgotPassword
Return type : none
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to validate forgot password form.
User instruction : validateAdminForgotPassword(formname)
************************************/
function validateForgotPassword(formname)
{
	if(validateForm(formname,'frmUserName','Username (E-mail) ','RisEmail','frmSecurityCode','Verification code','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}
/*****************************
Function name : deSelectCheckbox
Return type : none
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to deselect check box
User instruction : deSelectCheckbox(formname)
************************************/
function deSelectCheckbox(formname)
{
	document.getElementById('Main').checked = false;
}


/******************************************
Function name : setvalidAction
Return type : boolean
Date created : 19th November 2007
Date last modified : 19th November 2007
Author : sandeep kumar
Last modified by : sandeep kumar 
Comments : Function will ask for confirmation of updating records
User instruction : setValidAction(value, formname,listname)
******************************************/
function  setValidAction(value, formname,listname)
{
	if(value == 'Delete' || value.indexOf ('Delete')>-1)
	{
		message = "delete selected "+listname;		
	}
	else
	{
		message = "change status of selected "+listname;
	}
	var flag = validator(message,formname);			
	if(flag)
	{			
		formname.submit();
	}
	else
	{
		formname.frmChangeAction.value='';	
		document.getElementById('Main').checked = false;
		if(listname == 'Page(s)' || listname == 'User(s)' ||  listname == 'Order(s)' ||  listname == 'Article(s)' ||  listname == 'Link(s)' ||  listname == 'Bookmaker(s)' ||  listname == 'Offer(s)' ||  listname == 'Subscription(s)' ||  listname == 'Selection(s)' ||  listname == 'League(s)')
		{
			document.forms[1].Main.checked=false;	
			elm=document.forms[1].elements;
			
		}
		else
		{
			document.forms[0].Main.checked=false;	
			elm=document.forms[0].elements;	
		}
		
		for(i=0;i<elm.length;i++)
		{
			//alert(elm[i].type);
			if(elm[i].type == "checkbox" )
			{			
				elm[i].checked = false;
			}
			
		}
		return false;
	}
}


/*****************************
Function name : checkSearchDate
Return type : none
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to put check on serach date.
User instruction : checkSearchDate(obj)
************************************/
function checkSearchDate(obj)
{
	var error = "";
	if((obj.frmFromDate.value > obj.frmToDate.value) && obj.frmFromDate.value!='From' && obj.frmToDate.value!='To' )
	{
		//alert("vineet");die;
		error += "\n- 'To' date will be set after 'From' date.";
	}
	
	if(error != "")
	{
		checkError(error);
		return false;
	}
	else
		return true;
}

/*****************************
Function name : changePageing
Return type : string
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function take to selected page
User instruction : changePageing(argStr)
************************************/
function changePaging(argStr, argPageNum)
{
  var QueryStr = argStr+argPageNum;
  location.href = QueryStr;
}

/*****************************
Function name : checkCapsLock
Return type : none
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This function is used to display alert message when caps lock is on.
User instruction : checkCapsLock( e , FieldID) 
************************************/
function checkCapsLock(e , FieldID) 
{
	var myKeyCode=0;
	var myShiftKey=false;
	var myMsg='Caps Lock is ON.\n\nTo prevent entering your password incorrectly,\nYou should press Caps Lock to turn it OFF.';

	// Internet Explorer 4+
	if ( document.all ) {
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;

	// Netscape 4
	} else if ( document.layers ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	// Netscape 6
	} else if ( document.getElementById ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	}
	
	if(document.getElementById(FieldID).value.length==0) {

		// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
		if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
			alert( myMsg );
			//return;
	
		// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
		} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
			alert( myMsg );
		//	return;
		}
		return false;
	}
}


/******************************************
Function name : getMasterString
Return type : boolean
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
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 : getPageDetails
Return type : string
Date created : 31th July 2008
Date last modified : 31th July 2008
Author : Prashant Bhardwaj
Last modified by : 
Comments : All the dynamic pages from CMS.
User instruction : getPageDetails(item)
************************************/
function getPageDetails(argMainID)
{
	if(argMainID != '')
	{
		doAjax('ajax_action.php', 'type=getPageDetails&pageID='+argMainID, 'showPagesInfo', 'GET');		
	}
	else
	{
		document.getElementById('categoryDivFrame').innerHTML = 'Please select "Article Intro" to populate this.';	
	}
}
/*****************************
Function name : getKnowledgePageDetails
Return type : string
Date created : 31th July 2008
Date last modified : 31th July 2008
Author : Prashant Bhardwaj
Last modified by : 
Comments : All the dynamic pages from CMS.
User instruction : getKnowledgePageDetails(item)
************************************/
function getKnowledgePageDetails(argMainID)
{
	if(argMainID != '')
	{
		doAjax('ajax_action.php', 'type=getKnowledgePageDetails', 'showPagesInfo', 'GET');		
	}

}

 /*****************************
Function name : showPagesInfo
Return type : string
Date created : 31th July 2008
Date last modified : 31th July 2008
Author : Prashant Bhardwaj
Last modified by : 
Comments : All the dynamic pages from CMS.
User instruction : showPagesInfo(item)
************************************/
function showPagesInfo(item)
{
	if(item)
	{	
		document.getElementById('pagesDetail').innerHTML = item;
	}
}
/*****************************
Function name : validateChangePassword
Return type : boolean
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This is used to validate admin password and confirm passwords.
User instruction : validateChangePassword(formname)
************************************/
function validateChangePassword(formname)
{
	if(validateForm(document.getElementById(formname).id,'frmCurrentPassword', 'Current Password', 'RisSpace', 'frmNewPassword', 'New Password','RisSpace','frmNewConfirmPassword', 'Confirm New Password', 'RisEqualfrmNewPassword:New Password'))
	{			
		var flag=confirm('Are you sure you want to change password?')
		if(flag)
		{
			return true;
		}
		else
		{
			return false;		
		}
	} 
	else 
	{
		return false;
	} 
}
/*****************************
Function name : validateUserLogin
Return type : boolean
Date created : 31 July 2008
Date last modified : 31 July 2008
Author : Moneesh Koundal
Last modified by : 
Comments : This function is used to validate Username and Password
User instruction : validateUserLogin(formname)
************************************/
function validateUserLogin(formname)
{
	if(validateForm(formname,'frmUserEmailName','Username (Email Address)','RisEmail', 'frmUserPassword','Password','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateLogin
Return type : boolean
Date created : 4th Aug 2008
Date last modified : 4th Aug 2008
Author : Moneesh Koundal
Last modified by : 
Comments : This function is used to validate Username and Password
User instruction : validateLogin(formname)
************************************/
function validateLogin()
{
  
   var error= 'Sorry, we can not complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n' ;
   var regEmail = /^[0-9a-zA-Z]+(([\.\-_])[0-9a-zA-Z]+)*@[0-9a-zA-Z]+(([\.\-])[0-9a-z-A-Z]+)*\.[a-zA-Z]{2,4}$/;
   
		var email =document.getElementById('frmUserEmailName').value;
                 
				   var errors = '';
				  
				   	if(email == 'Email ID')
					{
						errors+='- Email ID is required.\n';
					}
			       else if(!regEmail.test(email))
					{
						errors+='- Email ID  must contain a valid e-mail Address.\n';
					}
					
					var password = document.getElementById('frmUserPassword').value;
					
					//secondName = trim(secondName);
					if(password == 'password')
					{
						errors+='- Password is required.\n';
					}
					
		if(errors.length)
		{
		alert(error+errors);
		return false;
		}
		else
		{
		return true;
		}
	}
	
	
	/*****************************
Function name : validateContactUs
Return type : boolean
Date created : 5 Aug 2008
Date last modified : 5 Aug 2008
Author : Moneesh Koundal
Last modified by : 
Comments : This function is used to validate Contact Us form
User instruction : validateContactUs(formname)
************************************/
function validateContactUs(formname)
{
	if(validateForm(formname,'frmUserName','Your Name','R', 'frmEmail','Your email','RisEmail','frmSubject','Subject','R','frmMessage','Message','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}
/**************************************************************************
Function name : displayEditPersonalDetails
Return type : boolean
Date created : 19th June 2008
Date last modified : 19th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : This function is used to show validate newsletter send form..
User instruction : displayEditPersonalDetails(formname)
***************************************************************************/
function displayEditPersonalDetails(tabAction)
{
	
	var fullTabID = 'editDiv';
	var fullDetailTabID = 'detailDiv';
	if(tabAction == 'open')
	{
		document.getElementById(fullTabID).style.display = 'block';
		document.getElementById(fullDetailTabID).style.display = 'none';
	}
	else
	{
		document.getElementById(fullTabID).style.display = 'none';
		document.getElementById(fullDetailTabID).style.display = 'block';
	}
}

/*****************************
Function name : validatePersonalDetails
Return type : boolean
Date created : 31 July 2008
Date last modified : 31 July 2008
Author : Moneesh Koundal
Last modified by : 
Comments : This function is used to validate Username and Password
User instruction : validatePersonalDetails(formname)
************************************/
function validatePersonalDetails(formname, date)
{
	if(validateForm(formname, 'frmFirstName', 'First Name', 'R', 'frmLastName', 'Last Name', 'R', 'frmUserAddress', 'Address', 'R', 'frmUserZipCode', 'Postcode/ZIP Code', 'R', 'frmCountryCode', 'Country', 'R', 'frmUserBirthDate', 'Day for Date of Birth', 'R', 'frmUserBirthMonth', 'Month for Date of Birth', 'R', 'frmUserBirthYear', 'Year for Date of Birth', 'R', 'frmUserMobile', 'Mobile', 'R'))
	/*if(validateForm(formname, 'frmFirstName', 'First Name', 'R', 'frmLastName', 'Last Name', 'R', 'frmCountryCode', 'Country', 'R', 'frmUserZipCode', 'Postcode/ZIP Code', 'R', 'frmUserDateOfBirth', 'Date of Birth', 'RisBackDate', 'frmUserMobile', 'Mobile', 'R'))*/
	{
		if(document.getElementById(formname).frmUserBirthDate.value != '' && document.getElementById(formname).frmUserBirthYear.value != '' && document.getElementById(formname).frmUserBirthYear.value != '')
		{
			var sliptdate	= date.split("-");
			var current_year=sliptdate[0];
			var current_month=sliptdate[1];
			var current_day=sliptdate[2];
			var zyear = (current_year - document.getElementById(formname).frmUserBirthYear.value);
			var zday = (current_day - document.getElementById(formname).frmUserBirthDate.value);
			var zmonth = (current_month - document.getElementById(formname).frmUserBirthMonth.value)
			
			if(zyear == 18 && zmonth < 0)
			{
				alert('You should be older than 18 years.');
				return false;
			}
			else if ((zyear < 18))
			{
				alert('You should be older than 18 years.');
				return false;
			}
			else
			{
				return true;	
			}
		}
	} 
	else 
	{
		return false;
	}
	
}

/*****************************
Function name : validateRegistrationForm
Return type : boolean
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This is used to validate admin password and confirm passwords.
User instruction : validateRegistrationForm(formname)
************************************/
function validateRegistrationForm(formname,date)
{
	//alert(date);
	var i = 0;
	var j = 0;
	
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!-]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;
	var regChar = /^([a-zA-Z]+)$/;
	var regNumeric = /^([0-9]+)$/; 
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var regNumeric = /^([0-9]+)$/; 
	var varElementID;
	 var regDate = /^([0-9_]+-[0-9][0-9]+-[0-9][0-9]+)$/; 
   
    bolTermChecked = document.getElementById(formname).frmTermsAndCondition.checked;

	if(document.getElementById(formname).frmUserFirstName.value == '') 
	{
		errorString += '- First Name is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserFirstName';	 
		}
	}
	if(document.getElementById(formname).frmUserLastName.value == '') 
	{
		errorString += '- Last Name is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserLastName';	 
		}
	}
	
	if(document.getElementById(formname).frmUserBirthDate.value == '') 
	{
		errorString += '- Day for Date of Birth is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserBirthDate';	 
		}
	}
	if(document.getElementById(formname).frmUserBirthMonth.value == '') 
	{
		errorString += '- Month for Date of Birth is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserBirthMonth';	 
		}
	}
	if(document.getElementById(formname).frmUserBirthYear.value == '') 
	{
		errorString += '- Year for Date of Birth is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserBirthYear';	 
		}
	}
	if(document.getElementById(formname).frmUserBirthDate.value != '' && document.getElementById(formname).frmUserBirthYear.value != '' && document.getElementById(formname).frmUserBirthYear.value != '')
	{
		var sliptdate	= date.split("-");
		var current_year=sliptdate[0];
		var current_month=sliptdate[1];
		var current_day=sliptdate[2];
		var zyear = (current_year - document.getElementById(formname).frmUserBirthYear.value);
		var zday = (current_day - document.getElementById(formname).frmUserBirthDate.value);
		var zmonth = (current_month - document.getElementById(formname).frmUserBirthMonth.value)
		
		if(zyear == 18 && zmonth < 0)
		{
			errorString += '- You should be older than 18 years.\n';	 
			if(!bolfocus )
			{
				bolfocus = true; 
				varElementID = 'frmUserBirthYear';	 
			}
		}
		else if ((zyear < 18))
 		{
			errorString += '- You should be older than 18 years.\n';	 
			if(!bolfocus )
			{
				bolfocus = true; 
				varElementID = 'frmUserBirthYear';	 
			}
		}
	}
	if(document.getElementById(formname).frmUserEmailAddress.value == "") 
	{
		errorString += '- Username (Email Address) is required.\n';	 
		bolfocus = true; 
		varElementID = 'frmUserEmailAddress';	 
	}
	else if(!regEmail.test(document.getElementById(formname).frmUserEmailAddress.value))
	{
		errorString += '- Username (Email Address) must contain a valid e-mail Address.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserEmailAddress';	 
		} 
	} 
	if(document.getElementById(formname).frmUserPassword.value == '') 
	{
		errorString += '- Password is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}
	}
	else if(!regSpace.test(document.getElementById(formname).frmUserPassword.value))
	{
		errorString += '- Password is not valid.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}  
	}
	   
	if(document.getElementById(formname).frmUserConfirmPassword.value == '') 
	{
		errorString += '- Confirm Password is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserConfirmPassword';	 
		}
	}
	else if(!regSpace.test(document.getElementById(formname).frmUserConfirmPassword.value))
	{
		errorString += '- Confirm Password is not valid.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserConfirmPassword';	 
		}  
	}
	   
	if(document.getElementById(formname).frmUserPassword.value != document.getElementById(formname).frmUserConfirmPassword.value)
	{
		errorString += '- Password and Confirm Password must be same.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserPassword';	 
		}
	}
	if(document.getElementById(formname).frmUserAddress.value == '') 
	{
		errorString += '- Address is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserAddress';	 
		}
	}
	if(document.getElementById(formname).frmUserZipCode.value == '') 
	{
		errorString += '- Postcode/ZIP Code is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmUserZipCode';	 
		}
	}
	if(document.getElementById(formname).frmfkCountryCode.value == '') 
	{
		errorString += '- Country is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID = 'frmfkCountryCode';	 
		}
	}
	
	
	    
	if(document.getElementById(formname).frmUserHearAboutUs.value == '') 
	{
		errorString += '- How did you hear about us? is required.\n';	 
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmUserHearAboutUs';	 
		}
	}
	else
	{
		if(document.getElementById(formname).frmUserHearAboutUs.value == 'Other')
		{
			if(document.getElementById(formname).frmUserOtherHearAboutUs.value == '') 
			{
				errorString += '- Other value for How did you hear about us? is required.\n';	 
				if(!bolfocus )
				{
					bolfocus = true; 
					varElementID= 'frmUserOtherHearAboutUs';	 
				}
			}	
		}
	}
	
	if(!bolTermChecked)
	{
		errorString += '- Please accept Terms and Conditions.\n';
		if(!bolfocus )
		{
			bolfocus = true; 
			varElementID= 'frmTermsAndCondition';	 
		}
	}
	   
	if(errorString == '')
	{
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			//varElementID= 'frmfkPlanID';
			//document.getElementById(varElementID).focus();
		}
		return false;
	}
	
	
}
/**************************************************************************
Function name : setOtherText
Return type : boolean
Date created : 4 August 2008
Date last modified : 
Author : Prashant
Last modified by : 
Comments : This function is used to show other for hear about us.
User instruction : setOtherText(formname)
***************************************************************************/
function setOtherText()
{
	var MainValue = document.getElementById('frmUserHearAboutUs').value;	
	if(MainValue == 'Other')
	{
		document.getElementById('frmDivOtherText').style.display = 'block';
	}
	else
	{
		document.getElementById('frmDivOtherText').style.display = 'none';
	}
}

/*****************************
Function name : validateRegistration2Form
Return type : boolean
Date created : 28 february 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :
Comments : This is used to validate admin password and confirm passwords.
User instruction : validateRegistration2Form(formname)
************************************/
function validateRegistration2Form(formname)
{
	var i = 0;
	var j = 0;
	
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	var regSpace = /^([a-zA-Z0-9_#@!-]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9_#@]+)$/;
	var regChar = /^([a-zA-Z]+)$/;
	var regNumeric = /^([0-9]+)$/; 
	var MasterString = getMasterString();
	var errorString = '';
	var bolfocus = false;
	var regNumeric = /^([0-9]+)$/; 
	var varElementID;
   
   	myOption = -1;
	for (i=document.getElementById(formname).frmSelectedSubscription.length-1; i > -1; i--) 
	{
		if (document.getElementById(formname).frmSelectedSubscription[i].checked) 
		{
			myOption = i;
		}
	}
	if (myOption == -1) 
	{
		errorString += '- Subscription is required.\n';	
	}
	
	if(errorString == '')
	{
		return true;  
	}
	else
	{
		alert(MasterString+'\n'+errorString);  
		if(bolfocus)
		{
			//varElementID= 'frmfkPlanID';
			//document.getElementById(varElementID).focus();
		}
		return false;
	}
}

function showContent(valID)
	{
		if(valID=='Click1')
		{			
			document.getElementById('Click1').className="current2";
			document.getElementById('Click2').className="";
			document.getElementById('Click3').className="";
			document.getElementById('Click4').className="";
			document.getElementById('Click5').className="";
			document.getElementById('Click6').className="";
			

			
		}
		
		if(valID=='Click2')
		{
			
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="current2";
			document.getElementById('Click3').className="";
			document.getElementById('Click4').className="";
			document.getElementById('Click5').className="";	
			document.getElementById('Click6').className="";

			
			
		}
		
		if(valID=='Click3')
		{			
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="";
			document.getElementById('Click3').className="current2";
			document.getElementById('Click4').className="";
			document.getElementById('Click5').className="";
			document.getElementById('Click6').className="";
			

		}
		if(valID=='Click4')
		{			
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="";
			document.getElementById('Click3').className="";
			document.getElementById('Click4').className="current2";
			document.getElementById('Click5').className="";
			document.getElementById('Click6').className="";
			

		}
		
		if(valID=='Click5')
		{			
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="";
			document.getElementById('Click3').className="";
			document.getElementById('Click4').className="";
			document.getElementById('Click5').className="current2";	
			document.getElementById('Click6').className="";

		}
		
		if(valID=='Click6')
		{		
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="";
			document.getElementById('Click3').className="";
			document.getElementById('Click4').className="";
			document.getElementById('Click5').className="";
			document.getElementById('Click6').className="current2";

		}
		
	}
	
function showContent1(valID)
	{
		if(valID=='Click1')
		{			
			document.getElementById('Click1').className="current2";
			document.getElementById('Click2').className="";
			document.getElementById('sc1').style.display = "block";
			document.getElementById('sc2').style.display = "none";
		}
		
		if(valID=='Click2')
		{
			document.getElementById('Click1').className="";
			document.getElementById('Click2').className="current2";
			document.getElementById('sc1').style.display = "none";
			document.getElementById('sc2').style.display = "block";
		}
	}
/******************************************
Function name : setCountryCode
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to email check using ajax. 
User instruction : setCountryCode(mailID)
******************************************/ 
function setCountryCode()
{ 
	if(document.getElementById('frmCountryCode').value != '') 
	{
		var val= document.getElementById('frmCountryCode').value;	
		
		doAjax('ajax_action.php','type=getCountryCode&countryID='+val, 'showCountryCode', 'GET');
	}
}
/******************************************
Function name : setRegistrationCountryCode
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to email check using ajax. 
User instruction : setRegistrationCountryCode(mailID)
******************************************/ 
function setRegistrationCountryCode()
{ 
	if(document.getElementById('frmfkCountryCode').value != '') 
	{
		var val= document.getElementById('frmfkCountryCode').value;	
		
		doAjax('ajax_action.php','type=getCountryCode&countryID='+val, 'showCountryCode', 'GET');
	}
}

/******************************************
Function name : showCountryCode
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to display username using ajax. 
User instruction : showCountryCode(item)
******************************************/ 
function showCountryCode(item)
{	
	//alert(item);
	document.getElementById('showCountryCodeDiv').innerHTML = item;
	
}	

/******************************************
Function name : showCountryCode
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to display username using ajax. 
User instruction : showCountryCode(item)
******************************************/ 
function validateOffer(formname)
{	
	/*if(validateForm(formname, 'frmOfferId', 'Offer ID', 'R', 'frmPaymentType', 'Payment Type', 'R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} */
	
}	
/******************************************
Function name : setDateDiv
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to display username using ajax. 
User instruction : setDateDiv(item)
******************************************/
function setDateDiv()
{
	var val= document.getElementById('frmSearchStatistics').value;	
	if(val!='')
	{			
		document.getElementById('frmMainDateDiv').style.display = "none";
		document.getElementById('frmMainNumberDiv').style.display = "none";
		
	}
	else
	{
		document.getElementById('frmMainDateDiv').style.display = "block";	
		document.getElementById('frmMainNumberDiv').style.display = "block";
	}
}
/******************************************
Function name : validateHistorySearch
Return type : None
Date created : 28 February 2008
Date last modified : 
Author : Prashant Bhardwaj
Last modified by : 
Comments : Function is used to display username using ajax. 
User instruction : validateHistorySearch(item)
******************************************/
function validateHistorySearch(formname)
{	
	var sliptdate	= document.getElementById(formname).frmTodate.value.split("-");
   	var FromDate  = document.getElementById(formname).frmDate.value.split("-");
	/*********************** From Date *****************/
	var TY = FromDate[0];  //Year
	var TM = FromDate[1];  //Month
	var TD = FromDate[2];  //Date
	/******************* To Date *********************/
	var sY=sliptdate[0];  //Year
	var sM=sliptdate[1];  //Month
	var sD=sliptdate[2];  //Date
			
	if(document.getElementById(formname).frmDate.value != 'From' && document.getElementById(formname).frmTodate.value != 'To')
	{
		if(sY<TY ) 
		{
			alert("'To' date should be greater than 'From' date.");
			return false;	  
		}
		else if(sM==TM && sD<TD && sY==TY) 
		{ 
			alert("'To' date should be greater than 'From' date.");
			return false;
		}
		else if(sM<TM && sY==TY) 
		{ 
			alert("'To' date should be greater than 'From' date.");
			return false;
		}
	}
	
	var mainTextValue	= document.getElementById(formname).frmSearchSelectionNumber.value;
	if(mainTextValue != 'Enter Number of selection')
	{
		if(validateForm(formname, 'frmSearchSelectionNumber', 'Last Selections', 'isNumber'))
		{	
			return true;
		} 
		else 
		{
			return false;
		} 
	}
}


	
