/*************************
Module name : Js Function file
Parent module : None
Date created : 10th September 2008
Date last modified : 24th October 2007
Author :  Gulshan Verma
Last modified by : Gulshan Verma
Comments : The functions_js.js file contains various functions related to the web directory project.
******************************************/	




/**********************************COMMMOM ADMIN FUNCTION IS NEEDED FOR THE ADMIN LOGIN & LOGOUT & SETTINMG OF THE ADMIN ****************/
/*****************************
Function name : checkCapsLock
Return type : none
Date created : 20 june 2008
Date last modified : 20 june 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : checkUserName
Return type : None
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 checkUserEmail(mailID)
{ 
	doAjax('ajax_act.php','type=signUp&userEmail='+mailID,'showUserEmail','GET',3);
}
function showUserEmail(item)
{
	if(item == true)
	{
		document.getElementById('showUserName').style.display = 'none';	
	}
	else
	{
		document.getElementById('showUserName').style.display = 'inline';
	}

}
/*****************************
Function name : validateAdminForm
Return type : integer
Date created : 20 june 2008
Date last modified : 20 june 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : validator
Return type : boolean
Date created : 
Date last modified : 
Author : 
Last modified by : 
Comments : Function will return the true or error message after validating checkboxes
User instruction : validator(btnType)
******************************************/
function validateForm() 
{ 
	var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
	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 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,20}\.?[0-9]{1,2})$/;
	
	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(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';
						}
					}
				
				}
				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+' is not valid.\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(!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('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.charAt(0)=='R')
				{
					result = trim(val);
					if(result.length==0){
						
					errors += '- '+nm+' is required.\n'; 
					}
				} 
			
		}
		else if (test.charAt(0)=='R')
		{
			result = trim(val);
				if(result.length==0){
					
				errors += '- '+nm+' is required.\n'; 
				}
		}
		
		 if (test.indexOf('isDate')!=-1) 
				{ 
					//alert("vineet");
					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>1)
				   {     
						
						if(sY<TY )
						{
						    errors+='- '+nm+' should be greater or equal than current date.\n';
						}
						else if(sM==TM && sD<TD && sY==TY) 
						{ 
	
							errors+='- '+nm+' should be greater or equal than current date.\n';
							
						}
						else if(sM<TM && sY==TY) 
						{ 
	
							errors+='- '+nm+' should be greater or equal than current date.\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 :validateEditMainProductForm
Return type : boolean
Date created :27th Nov 2008 
Date last modified : 27th Nov 2008
Author : Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : Function will return the true or error message after validating main product form.
User instruction : validateEditMainProductForm(formname)
******************************************/

function validateEditMainProductForm(formname)
{

	if(validateForm(formname, 'frmProductName', 'Name', 'R', 'frmProductDescription', 'Description', 'R', 'frmProductPrice', 'Price', 'R', 'frmProductSize', 'Size', 'R', 'frmProductImage', 'Image', 'R'))
	
	/*if(validateForm(formname, 'frmfkCategoryID', 'Category', 'R','frmProductName', 'Name', 'R', 'frmProductDescription', 'Description', 'R', 'frmProductMaterial', 'Material', 'R', 'frmProductDecoration', 'Decoration', 'R', 'frmProductLocation', 'Decoration', 'R', 'frmProductQuantity', 'Quantity', 'RisNumeric', 'frmProductMinOrderedQuantity', 'Min Ordered Qty', 'RisNumeric', 'frmProductDelivery', 'Guranteed Delivery', 'R', 'frmProductComments', 'Comments', 'R', 'frmProductFrontImage', 'Front Image', 'R', 'frmProductBackImage', 'Back Image', 'R'))*/
	{ 
		
		//	var MemberProfessionPackageCount = document.getElementById(formname).frmTotalCount.value;
		//	alert(MemberProfessionPackageCount);
			
			var total = document.getElementById(formname).MemberProfessionPackageCount.value;

//			alert(document.getElementById(formname).MemberProfessionPackageCount.frmProductColor.length);
			
			var j = 0;
			if(total >= 0)
			{

				for(i=0; i<=total; i++)
				{
					if(document.getElementById('frmProductColor['+i+']'))
					{
						j=j+1;

					if(validateForm(formname, 'frmProductColor['+i+']', 'Attribute'+j+'- Color', 'R', 'frmProductSize['+i+']', 'Attribute'+j+'- Size', 'R', 'frmProductPrice['+i+']', 'Attribute'+j+'- Price', 'RisDecimal'))
						{
							
							var status = 1;
							
						}
						else
						{
						
							var status = 0;
							break;
						}
						
					}
					else
					{
						var status = 1;
					}
				}
			}
			else
			{
				var status = 1;
			}
	

	} 
 	else 
 	{
 		var status = 0;
 	} 
 	if(status == 0)
 	{
 		return false;; 
 	}
 	else
 	{
  		return true; 
 	} 
}

/*****************************
Function name : validateMainProductForm
Return type : none
Date created : 27th Nov 2008
Date last modified :27th Nov 2008
Author :Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : This function is used to validate the sub user form
User instruction : validateMainProductForm(formname)
************************************/
function validateMainProductForm(formname)
{

	var val1 = document.getElementById('frmImageHidden1').value; 
	var val2 = document.getElementById('frmImageHidden2').value; 
	var val3 = document.getElementById('frmImageHidden3').value; 

 	if(val1 == 0 && val3 == 0 && val3 == 0)
 	{
  		if(validateForm(formname, 'frmProductPageTitle', 'Page Title', 'R', 'frmProductPageURL', 'Page URL', 'R', 'frmProductName', 'Name', 'R', 'frmProductDescription', 'Description', 'R', 'frmProductPrice', 'Price', 'R', 'frmProductFrontImage', 'Front Image', 'R', 'frmProductBackImage', 'Back Image', 'R', 'frmProductSideImage', 'Side Image', 'R', 'frmProductWeight', 'Weight(lbs)', 'R','frmProductMetaKeyword', 'Meta Keywords', 'R', 'frmProductMetaDescription', 'Meta Description', 'R'))
  		{ 
   			return true;
  		} 
  		else 
  		{
   			return false;
  		} 
 	}
 	else
 	{
  		if(validateForm(formname, 'frmProductPageTitle', 'Page Title', 'R', 'frmProductPageURL', 'Page URL', 'R','frmProductName', 'Name', 'R', 'frmProductDescription', 'Description', 'R','frmProductPrice', 'Price', 'R', 'frmProductWeight', 'Weight(lbs)', 'R','frmProductMetaKeyword', 'Meta Keywords', 'R', 'frmProductMetaDescription', 'Meta Description', 'R'))
  		{ 
   			return true;
  		} 
  		else 
  		{
   			return false;
  		} 
 	}

	
}


/*****************************
Function name : validateEmailChange
Return type : boolean
Date created : 20 june 2008
Date last modified : 21 june 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : This function is used to validate admin notification email id.
User instruction : validateEmailChange(charToCheck)
************************************/
function validateEmailChange(formname)
{
	if(validateForm(formname, 'frmAdminEmail','Email','RisEmail'))
	{			
		var flag=confirm('Are you sure you want to change notification E-mail?')
		if(flag)
		return true;
		else
		return false;		
	} 
	else 
	{
		return false;
	} 
}
/*****************************
Function name : validateChangePassword
Return type : boolean
Date created : 10th September 2008
Date last modified : 
Author : Gulshan Verma
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,'frmAdminOldPassword', 'Current Password', 'RisSpace', 'frmAdminNewPassword', 'New Password','RisSpace','frmAdminConfirmPassword', 'Confirm New Password', 'RisEqualfrmAdminNewPassword:New Password'))
	{			
		var flag=confirm('Are you sure you want to change password?')
		if(flag)
		{
			return true;
		}
		else
		{
			document.getElementById('frmAdminOldPassword').value='';
			document.getElementById('frmAdminNewPassword').value='';
			document.getElementById('frmAdminConfirmPassword').value='';
			document.getElementById('frmAdminOldPassword').focus();		
			return false;		
		}
	} 
	else 
	{
		document.getElementById('frmAdminOldPassword').value='';
		document.getElementById('frmAdminNewPassword').value='';
		document.getElementById('frmAdminConfirmPassword').value='';
		document.getElementById('frmAdminOldPassword').focus();		
		return false;
	} 

}
/*****************************
Function name : validateAdminForgotPassword
Return type : none
Date created : 10th September 2008
Date last modified : 
Author : Gulshan Verma
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 ','RisEmail','frmSecurityCode','Verification code','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/******************************************
Function name : ltrim
Return type : string
Date created : 
Date last modified : 
Author : 
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 : 
Date last modified : 
Author : 
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 : 
Date last modified :
Author : 
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 : 
Date last modified : 
Author : 
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 : checkError
Return type : boolean
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : getMasterString
Return type : boolean
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : toggleOption
Return type : None
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will deselect the main checkbox
User instruction : deSelectCheckbox(spanChk)
******************************************/
function deSelectCheckbox(formname)
{
	var id = document.getElementById('Main').checked = false;
}

/******************************************
Function name : setvalidAction
Return type : boolean
Date created : 10th September 2008
Date last modified : 26th November 2008
Author : Gulshan Verma
Last modified by : Pankaj Pandey
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)
	{
		//alert(formname.action);	
		formname.submit();
	}
	else
	{
		formname.frmChangeAction.value='';	
		document.getElementById('Main').checked = false;
		if(listname == 'Message(s)'  || listname == 'Testimonial(s)' || listname == 'Coupon(s)'|| listname == 'Product(s)'|| listname =='User(s)'|| listname == 'Order(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 : validateEmail
Return type : integer
Date created : 26th Nov 2008
Date last modified :  26th Nov 2008
Author : Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : This function is used to validate Subscriber notification email id.
User instruction : validateEmailID(charToCheck)
********************************/
function makeFeatured(testiID)
{
	var flag = confirm('Are You Sure You Want To Make This Testimonial Featured !!');
	if(flag)
	{
		location.href='testimonial_action.php?tid='+testiID;	
	}
	else
	{
		location.href='testimonial_list_uil.php';
	}
}

/******************************************
Function name : validator
Return type : boolean
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : askConfirm
Return type : boolean
Date created : 10th September 2008
Date last modified : 10th September 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
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 : showSearchBox
Return type : None
Date created : 20th October 2007
Date last modified : 20th October 2007
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function is used to show hide the seacch box
User instruction : showSearchBox()
******************************************/
function showSearchBox(varDocumentID, varShow)
{
 if(varShow == 'show')
 {
  document.getElementById(varDocumentID).style.display = 'block'; 
 }
 else
 {
   document.getElementById(varDocumentID).style.display = 'none';
 }
 
}
  /*****************************
Function name : resetDate
Return type : none
Date created : 10 March 2007
Date last modified : 
Author : Prashant Bhardwaj
Last modified by :Moneesh Koundal
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 : Gulshan Verma
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 : dateCompareForProduct
Return type : boolean
Date created : 19 March 2007
Date last modified : 
Author : Gulshan Verma
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 : dateCompareForProduct(formname)
************************************/
function dateCompareForProduct(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'))
	{
		if(document.getElementById(formname).frmFromPrice.value != 'From' && document.getElementById(formname).frmToPrice.value != 'To')
		{
			var fromPrice = parseInt(document.getElementById(formname).frmFromPrice.value);
			var toPrice = parseInt(document.getElementById(formname).frmToPrice.value);
			if(toPrice < fromPrice)
			{
				alert("To Price should be greater than From Price.");	
				return false;
			}
			else
			{
				return true;	
			}
		}
	} 
	else 
	{
    	return false;
	} 
	
}

/******************************END ADMIN SECTION JS FUNCTION********************************************************/
/*****************************
Function name : validateCMSForm
Return type : bollean
Date created : 28th February 2008
Date last modified : 28th February 2008
Author : Sandeep Kumar
Last modified by : Sandeep Kumar
Comments : This function is used to validate the CMS form.
User instruction : validateCMSForm(formname)
************************************/
function validateCMSForm(formname)
{
	if(validateForm(formname,'frmPageTitle','Page Title','R','frmPageUrl','User Friendly Url','R','frmPageKeywords','Meta Keywords','R','frmPageDescription','Meta Description','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

function validatePartnerForm(formname)
{
	if(validateForm(formname,'frmPartnersTitle', 'Title','R'))
	{	
		return true;
	}
	else
	{
		return false;
	}
}


function validatePartnerUrl(formname)
{
	if(validateForm(formname,'frmPageUrl', 'User Friendly Url', 'R', 'frmPageKeywords', 'Keyword', 'R', 'frmPageDescription', 'Description', 'R' ))
	{	
		return true;
	}
	else
	{
		return false;
	}
}

function validateTestimonialForm(formname)
{
	if(validateForm(formname,'frmTestimonialTitle', 'Title', 'R', 'frmTestimonialContent', 'Content', 'R', 'frmTestimonialAuthor', 'Author', 'R' ))
	{	
		return true;
	}
	else
	{
		return false;
	}
}

/*****************************
Function name : validatePromotionalOffer
Return type : integer
Date created : 26th Nov 2008
Date last modified : 26th Nov 2008
Author :Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : This is used to check Offer form.
User instruction : validatePromotionalOffer(charToCheck)
************************************/
function validatePromotionalOffer(formname)
{

	if(validateForm(formname, 'frmDate', 'Coupon Start Date', 'RisDate', 'frmTodate', 'Coupon Expiry Date', 'R', 'frmOfferLowerRange','Lower Range','RisNumeric', 'frmOfferUpperRange', 'Upper Range', 'RisNumeric','frmOfferDiscount', 'Coupon Discount', 'RisDecimal'))
	{	
		
		   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
			
			/*******************Added by rupesh*********************/
			
			var lowerRange = parseInt(document.getElementById('frmOfferLowerRange').value);
			var upperRange = parseInt(document.getElementById('frmOfferUpperRange').value);			
			var offerDiscount = parseInt(document.getElementById('frmOfferDiscount').value);			
		  
          if(sY<TY ) 
			{
				
				alert("'Expiry' date should be greater than 'Start' date.");
				return false;	  
			}
			else if(sM==TM && sD<TD && sY==TY) 
			{ 

				alert("'Expiry' date should be greater than 'Start' date.");
				return false;
				
			}
		   else if(sM<TM && sY==TY) 
		    { 
                alert("'Expiry' date should be greater than 'Start' date.");
				return false;
			}
			if(lowerRange>upperRange)
			{
				alert('Lower range should be less than Upper range.');
				return false;
			}
			if(!document.getElementById('frmDiscountType').checked)
			{
				if(offerDiscount>100)
				{
					alert('Coupan discount should not greater than 100.');
					return false;
				}
			}	     
			return true;
	} 
	else 
	{
		return false;
	} 
}
/***********************ORDER SECTION JS START****************************************************************/
/*****************************
Function name : changePaymentStatus
Return type : integer
Date created : 01 Dec 2008
Date last modified : 01 Dec 2008
Author : Parmjeet Singh
Last modified by : Parmjeet Singh
Comments : This function is used to validate the User.
User instruction : changePaymentStatus(payment,recordID)
************************************/
function changePaymentStatus(payment,recordID)
 {
   
   if(payment == "Paid")
   {
	var flag=confirm('Are you sure you want to change payment status?')
	 if(flag) 
	  {
	    
		document.forms[1].action='order_action.php?RecordID='+recordID;
		document.forms[1].submit();
	    return true;  
	  }
	 else
	  {
		var PaymentStatus = 'frmPaymentStatus'+recordID;
      
		document.getElementById(PaymentStatus).value='Unpaid';
	  
		return false;    
      }
	}
  }
/*****************************
Function name : changeOrderStatus
Return type : integer
Date created : 01 Dec 2008
Date last modified : 01 Dec 2008
Author : Parmjeet Singh
Last modified by : Parmjeet Singh
comments : this function will change the order status
User instruction : changeOrderStatus(OrderStatus,recordID)
************************************/
function changeOrderStatus(OrderStatus,recordID)
{
	
  if(OrderStatus != "Pending")
   {
	 var flag=confirm('Are you sure you want to change order status?')
	 if(flag) 
	  {
	    
		document.forms[1].action='order_action.php?OrderStatus='+OrderStatus+'&RecordID='+recordID;
		document.forms[1].submit();
	    return true;  
	  }
	 else
	  {
		var OrderStatus = 'frmOrderStatus'+recordID;
		
		document.getElementById(OrderStatus).value='Pending';
	    return false;    
      }
	}
  }
/******************************************
Function name : showPriceField
Return type : boolean
Date created : 01 Dec 2008
Date last modified : 01 Dec 2008
Author : Parmjeet Singh
Last modified by : Parmjeet Singh
User instruction : changeOrderStatus(OrderStatus,recordID)
******************************************/
function showPriceField(FieldValue)
{
	if(FieldValue=='')
	{
		document.getElementById('frmPrice').disabled=true;
	}
	else
	{
		document.getElementById('frmPrice').disabled=false;
	}
	
}

/**********************ORDER SECTION JS END*******************************************************/
/******************************************
Function name : validateUser
Return type : boolean
Date created : 12th Dec 2008
Date last modified : 12th Dec 2008
Author : Pankaj Pandey
Last modified by :  Pankaj Pandey
Comments : Function will validate user 
User instruction : validateUser(formname)
******************************************/
function validateUser(formname)
{ 
	if(validateForm(formname,'frmUserFirstName', 'First Name', 'R', 'frmUserLastName', 'Last Name', 'R','frmUserUserName','Email (Username)','RisEmail','frmUserAlternativeEmail','Alternate Email','isEmail','frmUserPassword','Password','RisSpace','frmUserConfirmPassword','Confirm Password','RisEqualfrmUserPassword:Password', 'frmUserCountry','Country','R','frmUserState','State','R','frmUserCity','City','R','frmUserStreet','Street','R','frmUserAddressOne','Address 1', 'R','frmUserAge','Age','R','frmPolicy','','RisCheckbox'))
	{	
		return true;
	}
	else
	{
		return false;
	}
}
/******************************************
Function name : validateContactChange
Return type : boolean
Date created : 01 Dec 2008
Date last modified : 2 Dec. September 2008
Author : Parmjeet Singh
Last modified by :  Parmjeet Singh
Comments : Function will validate admin contacts  in settings
User instruction : validateContactChange(formname)
******************************************/
function validateContactChange(formname)
{
	if(validateForm(formname,'frmAdminContact', 'Contact Details', 'R'))
	{	
		return true;
	}
	else
	{
		return false;
	}	
}

/******************************************
Function name : rpValidInteger
Return type : none
Date created : 10th Dec 2008
Date last modified :10th Dec 2008
Author : Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : Function will check whether value entered is integer or not.
User instruction : rpValidInteger(myfield, e)
******************************************/

function rpValidInteger(myfield, e) 
 
{
 
            var key;
 
            var keychar;
 
            if (window.event) 
 
            {
 
                        key = window.event.keyCode;
 
            }           
 
            else if (e) 
 
            {
 
                        key = e.which;
 
            }           
 
            else 
 
            {
 
                        return true;
 
            }
 
                        
 
            keychar = String.fromCharCode(key);
 
            // control keys
 
            if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) 
 
            {
 
                        return true;
 
            }           
 
            // numbers or decimal
 
            else if( (("0123456789.").indexOf(keychar) > -1) ) 
 
            {
 
                        return true;
 
            }
 
            else 
 
            {
 
                        return false;
 
            }
 
}

/*****************************
Function name : displayState
Return type : integer
Date created : 22 Oct 2008
Date last modified : 
Author : Prashant Kumar
Last modified by : 
Comments : This function is used to populate state.
User instruction : displayState(formname)
************************************/
function displayState(countryID)
{
	if(countryID == '')
	{
		//document.getElementById('frmVisibleStateLabel').style.display = 'none';
	}
	else
	{
		//document.getElementById('frmVisibleStateLabel').style.display = 'block';
		var QryStr = "CountryID="+countryID;
		doAjax('ajax_act.php',QryStr,'addStateToDiv','get','2');
	
	}
}

/*****************************
Function name : displayShippingState
Return type : integer
Date created : 16th Dec 2008
Date last modified : 16th Dec 2008
Author : Pankaj Pandey
Last modified by :Pankaj Pandey 
Comments : This function is used to populate Shipping state.
User instruction : displayState(formname)
************************************/
function displayShippingState(countryID, stateID, type, checked)
{
	if(countryID == '')
	{
		//document.getElementById('frmVisibleStateLabel').style.display = 'none';
	}
	else
	{
		//document.getElementById('frmVisibleStateLabel').style.display = 'block';
		var QryStr = "CountryID="+countryID+'&stateID='+stateID+'&type='+type+'&checked='+checked;
		doAjax('ajax_act.php',QryStr,'addShippingStateToDiv','get','2');
	
	}
}


 /*****************************
Function name : addStateToDiv
Return type : string
Date created : 22 Oct 2008
Date last modified : 
Author : Prashant Kumar
Last modified by : 
Comments : This function is used to display states into div.
User instruction : addStateToDiv(formname)
************************************/
function addStateToDiv(item)
{
	if(item)
	{
		 document.getElementById('frmVisibleState').innerHTML = item;	
	}
}

 /*****************************
Function name : addShippingStateToDiv
Return type : string
Date created : 16th Dec 2008
Date last modified :  16th Dec 2008
Author : Prashant KumarPankaj Pandey
Last modified by : Pankaj Pandey
Comments : This function is used to display Shipping states into div.
User instruction : addStateToDiv(formname)
************************************/
function addShippingStateToDiv(item)
{

	if(item)
	{
		 document.getElementById('frmVisibleState1').innerHTML = item;	
	}
}

/*****************************
Function name : validateUserLogin
Return type : integer
Date created : 11th Dec 2008
Date last modified : 11th Dec 2008
Author :Pankaj Pandey
Last modified by : 
Comments : This is used to check admin login authentications.
User instruction : validateAdminForm(charToCheck)
************************************/
function validateUserLogin(formname)
{
	if(validateForm(formname,'frmUserUserName','Username (Email)','RisEmail', 'frmUserPassword','Password','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 
}

/*****************************
Function name : validateForgotUserPassword
Return type : none
Date created : 11th Dec 2008
Date last modified : 11th Dec 2008
Author :Pankaj Pandey
Last modified by :Pankaj Pandey
Comments : This function is used to validate forgot password form.
User instruction : validateForgotUserPassword(formname)
************************************/
function validateForgotUserPassword(formname)
{
	
	if(validateForm(formname,'frmUserUserName','Username (Email)','RisEmail','frmSecurityCode','Verification code','R'))
	{	
		return true;
	} 
	else 
	{
		
		document.getElementById('frmUserUserName').value='';
		return false;
	} 
}

/*****************************
Function name : validateResetPassword
Return type : boolean
Date created : 12th Dec 2008
Date last modified : 12th Dec 2008
Author :Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : This is used to validate admin password and confirm passwords.
User instruction : validateResetPassword(formname)
************************************/
function validateResetPassword(formname)
{
	if(validateForm(document.getElementById(formname).id,'frmCurrentPassword', 'Current Password', 'RisSpace', 'frmNewPassword', 'New Password','RisSpace','frmConfirmNewPassword', '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 : validateContactForm
Return type : boolean
Date created : 15th Dec 2008
Date last modified : 15th Dec 2008
Author : Pankaj Pandey
Last modified by :  Pankaj Pandey
Comments : Function will validate user 
User instruction : validateContactForm(formname)
******************************************/
function validateContactForm(formname)
{ 
	if(validateForm(formname,'frmFirstName', 'First Name', 'R', 'frmLastName', 'Last Name', 'R','frmEmailID','Email','RisEmail','frmContactSubject','Subject','R','frmCompanyName','Company','R','frmTelephone','Telephone','R', 'frmMessage','Message','R'))
	{	
		return true;
	}
	else
	{
		return false;
	}

}


/*****************************
Function name : validateTestimonialForm
Return type : integer
Date created : 20 june 2008
Date last modified : 20 june 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : This is used to check admin login authentications.
User instruction : validateAdminForm(charToCheck)
************************************/
function validateTestimonialForm(formname)
{

	if(validateForm(formname,'frmTestimonialTitle','Testimonial Title','R'))
	{	
		return true;
	} 
	else 
	{
		return false;
	} 

}

/******************************************
Function name : validateAccountDetails
Return type : boolean
Date created : 15th Dec 2008
Date last modified : 15th Dec 2008
Author : Pankaj Pandey
Last modified by :  Pankaj Pandey
Comments : Function will validate account details from 
User instruction :validateAccountDetails(formname)
******************************************/
function validateAccountDetails(formname, hdnProcess)
{ 
   return chkCardDetails(hdnProcess);
}

/******************************************
Function name : validateAccountDetails
Return type : boolean
Date created : 15th Dec 2008
Date last modified : 15th Dec 2008
Author : Pankaj Pandey
Last modified by :  Pankaj Pandey
Comments : Function will validate account details from 
User instruction :validateAccountDetails(formname)
******************************************/
function validateCheckoutAccountDetails(formname, hdnProcess)
{ 
   return chkCardCheckoutDetails(hdnProcess);
}

function checkEnterEvent(event)
{
	e = (window.event)? window.event : event;

	if (e.keyCode == 13) // checks whether the Enter key  is pressed
	{	
		return true;
	}
	else
	{
		return false;
	}
}

/******************************************
Function name : copyBillingValue
Return type : none
Date created : 16th Dec 2008
Date last modified : 16th Dec 2008
Author : Pankaj Pandey
Last modified by : Pankaj Pandey
Comments : Function will copy all the Billing informations in shipping informations.
User instruction : copyBillingValue(id)
******************************************/
function copyBillingValue(id)
{
	if(document.getElementById('frmAccountcheck').checked)
	{
		document.getElementById('frmUserShippingAddressOne').value = document.getElementById('frmUserAddressOne').value;
		document.getElementById('frmUserShippingAddressOne').disabled = true;
		document.getElementById('frmUserShippingAddressTwo').value = document.getElementById('frmUserAddressTwo').value;
		document.getElementById('frmUserShippingAddressTwo').disabled = true;
		document.getElementById('frmUserShippingCity').value = document.getElementById('frmUserCity').value;
		document.getElementById('frmUserShippingCity').disabled = true;
		document.getElementById('frmUserShippingZipCode').value = document.getElementById('frmUserZipCode').value;
		document.getElementById('frmUserShippingZipCode').disabled = true;
		document.getElementById('frmUserShippingCountry').value = document.getElementById('frmUserCountry').value;
		document.getElementById('frmUserShippingCountry').disabled = true;
		document.getElementById('frmUserShippingCode1').value = document.getElementById('frmUserCode1').value;
		document.getElementById('frmUserShippingCode1').disabled = true;
		document.getElementById('frmUserShippingPhone').value = document.getElementById('frmUserPhone').value;
		document.getElementById('frmUserShippingPhone').disabled = true;
		if(document.getElementById('frmUserState') != null)
		{
			document.getElementById('frmVisibleState1').innerHTML = document.getElementById('frmUserState').value;
			document.getElementById('frmAccountcheck').value = 'Yes';
			displayShippingState(document.getElementById('frmUserCountry').value, document.getElementById('frmUserState').value,  'shipping', 'true');
		}
		else
		{
			document.getElementById('frmVisibleState1').innerHTML = 'Choose country to populate this'; 
		}
	}
	else
	{
		document.getElementById('frmUserShippingAddressOne').value = '';
		document.getElementById('frmUserShippingAddressOne').disabled = false;
		document.getElementById('frmUserShippingAddressTwo').value = '';
		document.getElementById('frmUserShippingAddressTwo').disabled = false;
		document.getElementById('frmUserShippingCity').value = '';
		document.getElementById('frmUserShippingCity').disabled = false;
		document.getElementById('frmUserShippingZipCode').value = '';
		document.getElementById('frmUserShippingZipCode').disabled = false;
		document.getElementById('frmVisibleState1').innerHTML = 'Choose country to populate this';	
		document.getElementById('frmUserShippingCode1').value = '';
		document.getElementById('frmUserShippingCode1').disabled = false;
		document.getElementById('frmUserShippingPhone').value = '';
		document.getElementById('frmUserShippingPhone').disabled = false;
		document.getElementById('frmUserShippingCountry').value = '';
		document.getElementById('frmUserShippingCountry').disabled = false;
		if(document.getElementById('frmUserState') != null)
		{
			displayShippingState(0, document.getElementById('frmUserState').value,  'shipping', 'false');
		}
	}
}

/******************************************
Function name : confirmDeleteProduct
Return type : Boolean
Date created : 19th Dec 2008
Date last modified : 19th Dec 2008
Author : Neha Sharma
Last modified by : Neha Sharma
******************************************/
function confirmDeleteProduct()
{
	var flag=confirm('Are you sure you want to delete selected product(s)?');
	if(flag)
	{
		return true;
	}
	else
	{
		return false;		
	}
}



/*****************************
Function name : validqyantity
Return type : integer
Date created : 19th Dec 2008
Date last modified : 19th Dec 2008 
Author :  Neha Sharma
Last modified by :  Neha Sharma
Comments : This function is used to validate the User.
User instruction : validateUser(formname)
************************************/  
function validQuantity(val)
{
    var isOK = true;
	var lent = document.forms[0].elements.length;
	var regNumeric = /^([0-9]+)$/; 
	with(val)
	  { 
		for (var i = 0; i < lent ; i++)
		{ 
		
		  if ((document.forms[0].elements[i].type == "text") )
		  { 
			if (document.forms[0].elements[i].value == 0 || (!regNumeric.test(document.forms[0].elements[i].value)))      
			{ 
			  isOK = false;
			 
			} 
		   } 
		} 
	 }
	if(!(isOK))
	{	
		error ='\n - Please enter valid quantity.';
		checkError(error);
		return false;
		
	}
	else
	{
	document.frmShoppingCart.frmProcess.value = "UpdateCart"
	document.frmShoppingCart.action="shopping_cart_action.php";
	document.frmShoppingCart.submit();
	return true;
	}
	
}



function loadRelatedProduct(rprdID)
{
	
	if(document.getElementById('frmProductFeatured').checked)
	{
		doAjax('ajax_act.php','type=LoadRelatedProduct&rprdID='+rprdID,'loadPrd','GET', 2);
	}
	else
	{
		hdn ="<input type='hidden' name='frmRelatedProduct' value='0'>";
		document.getElementById('reltedPrd').style.display = 'none';	
		document.getElementById('loadRelatedProduct').innerHTML = hdn;
	}
}
function loadPrd(item)
{
	document.getElementById('reltedPrd').style.display = '';	
	document.getElementById('loadRelatedProduct').innerHTML = item;
}


/*****************************
Function name : confirmDelete
Return type : integer
Date created : 20th December 2008
Date last modified : 20th December 2008 
Author : Neha Sharma
Last modified by : Neha Sharma
Comments : This function is used to validate the User.
User instruction : validateUser(formname)
************************************/  
function confirmDelete(formname) 
{
	var flagVal  = carValidator('remove the product(s) from Shopping Cart',formname);
   	if (flagVal)
	{
		document.frmShoppingCart.frmProcess.value = "DeletefromCart";
		document.frmShoppingCart.action = "shopping_cart_action.php";
		document.frmShoppingCart.submit();
	}
	else
	{
		
		var obj = document.forms[0];
	    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)
			{
				obj.elements[i].checked = false;
			}
			
		 }
	  }
		
		return false;
	}
}


/******************************************
Function name : validator
Return type : boolean
Date created : 20th December 2008
Date last modified : 20th December 2008
Author : Neha Sharma
Last modified by : Neha Sharma
Comments : Function will return the true or error message after validating checkboxes
User instruction : validator(btnType)
******************************************/
var btnType;
function carValidator(btnType,formname)
{
	
	var obj = document.forms[0];
	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 : changeImage
Return type : boolean
Date created : 20th December 2008
Date last modified : 20th December 2008
Author : Neha Sharma
Last modified by : Neha Sharma
Comments : Function will change the image
******************************************/
function changeImage(image, height, width, padding)
{
	//alert(image+"======="+height+"======="+width+"======="+padding);
	//var imageText = '<img id="img1" src="'+image+'" alt="" height="'+height+'" width="'+width+'" style="padding-top:'+padding+'px;"  />';
	var imageText = '<img id="img1" src="'+image+'" alt="" height="'+height+'" width="'+width+'" />';
	//alert(imageText);
	document.getElementById('checkMe').innerHTML = imageText; 	
	//alert(document.getElementById('checkMe').innerHTML);
	
	
	//document.getElementById('img1').src = image; 
	//document.getElementById('img1').height = height; 
	//document.getElementById('img1').width = width; 	
}
function disabledElement(chk)
{
	if(chk == 'Yes')
	{
		document.getElementById('frmUserShippingAddressOne').value = document.getElementById('frmUserAddressOne').value;
		document.getElementById('frmUserShippingAddressOne').disabled = true;
		document.getElementById('frmUserShippingAddressTwo').value = document.getElementById('frmUserAddressTwo').value;
		document.getElementById('frmUserShippingAddressTwo').disabled = true;
		document.getElementById('frmUserShippingCity').value = document.getElementById('frmUserCity').value;
		document.getElementById('frmUserShippingCity').disabled = true;
		document.getElementById('frmUserShippingZipCode').value = document.getElementById('frmUserZipCode').value;
		document.getElementById('frmUserShippingZipCode').disabled = true;
		document.getElementById('frmUserShippingCountry').value = document.getElementById('frmUserCountry').value;
		document.getElementById('frmUserShippingCountry').disabled = true;
		document.getElementById('frmUserShippingCode1').value = document.getElementById('frmUserCode1').value;
		document.getElementById('frmUserShippingCode1').disabled = true;
		document.getElementById('frmUserShippingPhone').value = document.getElementById('frmUserPhone').value;
		document.getElementById('frmUserShippingPhone').disabled = true;
		document.getElementById('frmVisibleState1').innerHTML = document.getElementById('frmUserState').value;
		document.getElementById('frmAccountcheck').value = 'Yes';
		displayShippingState(document.getElementById('frmUserCountry').value, document.getElementById('frmUserState').value,  'shipping', 'true');
	}
		
		
}

function addMemberProfessionPackage(cnt)
{
 var appNav = navigator.appName;
 document.getElementById("MemberProfessionPackageCount").value = parseInt(document.getElementById("MemberProfessionPackageCount").value) + 1;
 if (cnt == "")  {  
  cnt = document.getElementById("MemberProfessionPackageCount").value;
 } 
 
 var oDiv = document.createElement("DIV");
 oDiv.id = "sub_package"+cnt;
 if(appNav == "Microsoft Internet Explorer") {
  var frmContent = document.getElementById("main_block_professional_exp").childNodes[0].innerHTML;
 } 
 else{
  var frmContent = document.getElementById("main_block_professional_exp").childNodes[1].innerHTML;
 }
 
 var re = /AUTONUM/g;
 var frmContent1 = frmContent.replace(re,cnt);
 oDiv.innerHTML = frmContent1;
 
 document.getElementById("main_block_professional_exp").appendChild(oDiv);
}
 
 //Remove member profile profession package
function removeMemberProfessionalPackake(num)
{
 var rmDiv = "sub_package"+num;
 document.getElementById("main_block_professional_exp").removeChild(document.getElementById(rmDiv));
}

function addMultipleSizes(cnt)
{

 var appNav = navigator.appName;
 document.getElementById("frmProductSizeCount").value = parseInt(document.getElementById("frmProductSizeCount").value) + 1;
 if (cnt == "")  {  
  cnt = document.getElementById("frmProductSizeCount").value;
 } 
 
 var oDiv = document.createElement("DIV");
 oDiv.id = "sub_package"+cnt;
 if(appNav == "Microsoft Internet Explorer") {
  var frmContent = document.getElementById("main_block_professional_exp1").childNodes[0].innerHTML;
 } 
 else{
  var frmContent = document.getElementById("main_block_professional_exp1").childNodes[1].innerHTML;
 }
 
 var re = /AUTONUM/g;
 var frmContent1 = frmContent.replace(re,cnt);
 oDiv.innerHTML = frmContent1;
 
 document.getElementById("main_block_professional_exp1").appendChild(oDiv);
}
 
 //Remove member profile profession package
function removeMultipleSizes(num)
{
 var rmDiv = "sub_package"+num;
 mainDiv = document.getElementById('main_block_professional_exp1');
 
 //alert(rmDiv+'====='+document.getElementById(rmDiv));
if (mainDiv.hasChildNodes())
// So, first we check if the object is not empty, if the object has child nodes
 {
  var children = mainDiv.childNodes;
   for (var i = 0; i < children.length; i++) 
   {
   // do something with each child as children[i]
   // NOTE: List is live, Adding or removing children will change the list
   		childNode = children[i]
	   if(childNode.id == rmDiv)
	   {
		   childNode.parentNode.removeChild(childNode);
	   }
   };
 /*  while (mainDiv.firstChild) {
  mainDiv.removeChild(mainDiv.firstChild);
}*/

 };

return false;
 //
}


function validateCreditCardInfo(cardnumber, cardname)
{
	 var cardnumber = document.getElementById(cardnumber);
	 var cardname = document.getElementById(cardname);
	 checkCreditCard(cardnumber, cardname);
}
/******************************************
Function name : CheckKey
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function is used to check the browser
User instruction : CheckKey(event)
******************************************/
function checkEnter(event)
{

	if(window.navigator.appName=='Microsoft Internet Explorer')
	{
		checkKeyIE();
	}
	else if(window.navigator.appName=='Netscape')
	{
		checkKeyMozilla(event);
	}
}
/******************************************
Function name : checkKeyIE
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the ie
User instruction : checkKeyIE()
******************************************/
function checkKeyIE(btn)
{
	if (window.event.keyCode == 13) // checks whether the SHIFT key	// is pressed
	{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
 validateAccountDetails('frmEditAccountDetais');
	}
}
/******************************************
Function name : checkKeyMozilla
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the Mozilla
User instruction : checkKeyMozilla(e,btn)
******************************************/	
function checkKeyMozilla(e,btn)
{
	e = (window.event)? window.event : e;
	if (e.keyCode == 13) // checks whether the SHIFT key
	// is pressed
	{
	e.stopPropagation();
	e.preventDefault();
	 validateAccountDetails('frmEditAccountDetais');
	}	
}

/******************************************
Function name : CheckKey
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function is used to check the browser
User instruction : CheckKey(event)
******************************************/
function checkSubmit(event)
{

	if(window.navigator.appName=='Microsoft Internet Explorer')
	{
		checkKeysIE();
	}
	else if(window.navigator.appName=='Netscape')
	{
		checkKeysMozilla(event);
	}
}
/******************************************
Function name : checkKeyIE
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the ie
User instruction : checkKeyIE()
******************************************/
function checkKeysIE(btn)
{
	if (window.event.keyCode == 13) // checks whether the SHIFT key	// is pressed
	{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
 validateAccountDetails('frmCheckoutProcess');
	}
}
/******************************************
Function name : checkKeyMozilla
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the Mozilla
User instruction : checkKeyMozilla(e,btn)
******************************************/	
function checkKeysMozilla(e,btn)
{
	e = (window.event)? window.event : e;
	if (e.keyCode == 13) // checks whether the SHIFT key
	// is pressed
	{
	e.stopPropagation();
	e.preventDefault();
	 validateAccountDetails('frmCheckoutProcess');
	}	
}
/******************************************
Function name : CheckKey
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function is used to check the browser
User instruction : CheckKey(event)
******************************************/
function checkEnterForUpdate(event)
{

	if(window.navigator.appName=='Microsoft Internet Explorer')
	{
		checkKeyIEEnter();
	}
	else if(window.navigator.appName=='Netscape')
	{

		checkKeyMozillaEnter(event);
	}
}
/******************************************
Function name : checkKeyIE
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the ie
User instruction : checkKeyIE()
******************************************/
function checkKeyIEEnter(btn)
{
	if (window.event.keyCode == 13) // checks whether the SHIFT key	// is pressed
	{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
if(validQuantity('frmQty')){document.getElementById('frmShoppingCart').submit();}
	}
}
/******************************************
Function name : checkKeyMozilla
Return type : none
Date created : 27th June 2008
Date last modified : 27th June 2008
Author : Gulshan Verma
Last modified by : Gulshan Verma
Comments : Function will call the click evemt when enter is pressed on the Mozilla
User instruction : checkKeyMozilla(e,btn)
******************************************/	
function checkKeyMozillaEnter(e,btn)
{
	e = (window.event)? window.event : e;
	if (e.keyCode == 13) // checks whether the SHIFT key
	// is pressed
	{
	e.stopPropagation();
	e.preventDefault();
	if(validQuantity('frmQty')){document.getElementById('frmShoppingCart').submit();}
	}	
}

function openLayer(layer1, layer2)
{
	document.getElementById(layer1).style.display = '';
	document.getElementById(layer1+'Link').className = 'current';	
	document.getElementById(layer2).style.display = 'none';
	document.getElementById(layer2+'Link').className = '';		
	
}
