/* start - Following parameter are the global variables for the jsp.*/
// declare hashmap for storing search suggestions (array of search suggestion)
var searchSuggestionHashMap = new map();
var myState = null;
var firstCellIndex=0;
var secondCellIndex = 0;
var firstColumn = -1;
var secondColumn = 0;
var queryStr = null;
/* end - Following parameter are the global variables for the jsp.*/
/*start - function is used for map in javascript like java - used in search suggestion box*/
function map()
{
			var gKeys = new Array();
			var gValues = new Array();
			
			
			this.keys = gKeys;
			this.values = gValues;
			this.size = 0;
			this.put = setMapEntry;
			this.get = getMapEntry;
			this.containsKey = checkContainsKey;

			function setMapEntry(key , value)
			{
					gKeys[gKeys.length]  = key;
					gValues[gValues.length] = value;
					this.size++;
			}
			
			function getMapEntry(keyParam)
			{
				
				for(var i=0;i<this.size;i++)
				{
					if(gKeys[i]==keyParam)
					return gValues[i];
				}

				return "";
			}
			function checkContainsKey(keyParam)
			{
     			for(var i=0;i<this.size;i++)
				{
					if(gKeys[i]==keyParam)
					return true;
					
				}

				return false;
    		}
		
}

/*end - function is used for map in javascript like java - used in search suggestion box*/



/////////// functions from cspLogin.jsp
// following function is used for setting the url which send some parameters using hidden field variables.
//It dont show the parameter in url.
function setURLToLink(url,formId,viewType,tabId)
{
	var formObj = document.getElementById(formId);
	formObj.viewType.value = viewType;
	if(tabId)
		formObj.tab.value = tabId;
	formObj.action  = url;
	formObj.submit();
}

//function for getting the state and cities for dropdown list
function getState(countryId,frm,otherStateId,otherCityId) {
var form = frm.name;
	var otherStateObj = document.getElementById(otherStateId);
	var otherCityObj = document.getElementById(otherCityId);
	if(otherStateObj && otherCityObj){
	otherStateObj.style.display='none';
	otherCityObj.style.display='none';
	}
	makeRequest(path+'/jsp/statesForCountry.jsp','countryId='+countryId+'&statesforcountry=statesforcountry&formName='+form);
}

// Method for get City List

function getCity(stateId,frm,otherStateId,otherCityId) {
	//alert(stateId)
	var form = frm.name;
	var state = document.forms[form].state;
	if(state.options[state.options.selectedIndex].text=='Other')
	{
		document.getElementById(otherStateId).style.display='';
	}
	else
	{
		var otherStateObj = document.getElementById(otherStateId);
	    var otherCityObj = document.getElementById(otherCityId);
	     if(otherStateObj && otherCityObj){
		     otherStateObj.style.display='none';
		     otherCityObj.style.display='none';
	    }
	}
	makeRequest(path+'/jsp/cityForState.jsp','stateId='+stateId+'&cityforstate=cityforstate&formName='+form);
}
//end for function getting state and cities.

function checkCitySelected(city,frm,otherCityId){

	var formname = frm.name;
	
	var otherCity = document.forms[formname].otherCity;
	
	if(city.options[city.options.selectedIndex].text=="Other")
	{
		document.getElementById(otherCityId).style.display='';
		otherCity.disabled=false;
		otherCity.focus();
	}
	else{
		document.getElementById(otherCityId).style.display='none';
		//otherCity.disabled=true;
		//otherCity.value="";
	}
}

function hidden_div(id)
{
	var divObj = document.getElementById(id);
		if(divObj!=null)
		{
				divObj.style.display="none";
				divObj.style.visibility="hidden";	
		}
}
function visible_div(id)
{
	var divObj = document.getElementById(id);
		if(divObj!=null)
		{
				divObj.style.display="block";
				divObj.style.visibility="visible";	
		}
}
function formatUrl(storeUrl) //goto URL on Buy Now Button on Online Seller Page
{
	if(storeUrl.substring(0,7)!="http://")
		storeUrl = "http://"+storeUrl;
	    window.open(storeUrl);
}
//End -- when a user want to buy product //

/**
check if user is login . If not display user sign in popup else display logout as seller popup
*/
function checkUserIsLogin(email_Id)
{
	if(email_Id == "null")
	{
		doRequest('request:SellerLoginForm','sellerLoginLink');
	}
	else 
	{
		doRequest('request:UserLogOutForm','sellerLoginLink');
	} 
}

/**
check if seller is login . If not display seller sign in popup else display logout as buyer popup
*/
function checkSellerLogin(sellerEmail_Id)
{
	if(sellerEmail_Id == "null"){
		doRequest('request:LoginForm','userLoginLink');
	 }else{
		doRequest('request:SellerLogOutForm','userLoginLink');
	 }
	
}
/**
	It check if user logout from userDetails.jsp or sellerDetails.jsp 
	then it will forword to index.jsp else it will set on same jsp where is the user.
*/
function popupLogOut(logOutPath)
{
if((logOutPath.match("myDetails.jsp")== 'myDetails.jsp')||(logOutPath.match("slr.html")== 'slr.html'))
	{
		
					
		location.href=path+"/jsp/logOut.jsp";
	}
	else
	{	
		location.href=path+"/jsp/logOut.jsp?pathNew="+logOutPath;
	}
}
/////////// functions from luceneSearcher.jsp

function  validateTextField(elements){
		  
		   var string = elements;
		 	var jChars = "{}[]()!^*";
			 var iChars = "*|,\":?.<>[]{}~`=\';()@&$#%+-!^";
		 	if (iChars.indexOf(string.charAt(0)) != -1){
		 	       alert ("  No Special Characters Allowed !  "); 
			       return false;
	        }
	        for (var i=0; i< string.length; i++ )
	       {
		    if(jChars.indexOf(string.charAt(i)) != -1){
            alert (" No Special Characters Allowed ! "); 
            return false;
		    }
		   }
	       return true;
	} 
function searchAction(fieldValue)
{
//alert("searchAction-->>"+fieldValue);
  var query = fieldValue;
   if(trim(query)==null || trim(query)=="" || trim(query)==" ")
  {
  	alert('Please Enter keyword you want to Search.');
  	document.getElementById('searchtxt').focus();
 	return false;
  }
  else
	{
	  //var query = document.getElementById('searchtxt').value;
	  var form_id = document.getElementById('formid');
	  //document.getElementById('suggestionKeyOnEnter').value = fieldValue;
	  //var path ="<%=request.getContextPath()%>/faces/components/search/searchEncode.jsp?suggestionKeyOnEnter="+query;
	  document.searchForm.action=path+"/faces/components/search/searchEncode.jsp";
	  document.searchForm.submit();

//	  var form_id = document.getElementById('formid');
//	  form_id.action = path;
//	  var queryvalue = document.getElementById('queryvalueId');
//	  queryvalue.value=query;
//	  document.searchForm.submit();
	}
}
 function checkSpecialChars(evt){	

	//alert("checkSpecialChars");
	
			var charCode = (evt.which) ? evt.which : evt.keyCode;
			if (!((charCode > 64 && charCode < 91) || ((charCode > 96) && (charCode < 123)) || ((charCode > 47) &&
					(charCode < 58)) || ((charCode > 31) && (charCode < 33)) || ((charCode > 45) && (charCode < 47)) ||
				((charCode > 12) && (charCode < 14)) || ((charCode > 7) && (charCode < 9)))) 	{
							alert(" No Special Characters Allowed ! ");
							
  							return false;
			}
			if(charCode == 13){
				//alert("return search Action");
				return searchAction();
			}
			return true;
}
var globalValue = "";	
var globalLength = 0;
var globalCursor = false;
var browserName = navigator.appName;
var fromTop = 0;
function checkBrowser()
{
if(browserName.match("Microsoft Internet Explorer") == "Microsoft Internet Explorer")
{
	var divObj = document.getElementById("suggesstionBox");
	divObj.style.marginTop = -12;
	
	
}
else
{
	var divObj = document.getElementById("suggesstionBox");
	divObj.style.marginTop = -12;
}
}
/**
	Function used for showing the suggestion box
	and forword the page when user will select any suggestion.
	And also set the selection on navigation key's(up/down right/left).
*/
function suggetionBox(boxDivId,fieldId,e)
{

	//document.getElementById('suggestionKeyOnEnter').value = document.getElementById(fieldId).value;
	delete_cookie(document.getElementById('searchtxt').value);
	var fieldVal = document.getElementById(fieldId).value
	if(fieldVal.length > 2){
	if(e.keyCode != 40 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 37)
	{
	var fieldValue = document.getElementById(fieldId).value;
	globalCursor = true;
	var isSpace = true;
	if(e.keyCode != 8)
	{
		globalValue = fieldValue;
		globalLength = fieldValue.length;
		
	}
	else
	{
		var oldVal = document.getElementById(fieldId).value;
		var oldLength = oldVal.length;
		if(trim(globalValue) == trim(oldVal))
		{
			
				//alert("isTrue--false");
				isSpace = false;
			
		}
		
	}
	checkBrowser();
	if(fieldValue.length > 2)
	{
		var firstVal = fieldValue.substring(0,3);
		//alert("after->>"+firstVal);
		if( e.keyCode != 32 && trim(fieldValue) != "" && trim(fieldValue) != null && isSpace)
		{
			if(!searchSuggestionHashMap.containsKey(firstVal))
			{
				
					makeRequest(path+"/jsp/commonForMakeRequest.jsp","pageId=suggessionBoxPageId&fieldValue="+trim(fieldValue));
				
			}
					
			else
			{
			
				var j = 0;
				var fieldValue = trim(document.getElementById(fieldId).value);
				var len = fieldValue.length;
				var boxDivObj = document.getElementById('suggesstionBox');
	            var params = new Array();
	            suggparams = searchSuggestionHashMap.get(firstVal);
				
				for(var i=0;i<suggparams.length;i++)
				{
					var suggestionVal = trim(suggparams[i]).substring(0,fieldValue.length);
					if(trim(suggestionVal).toLowerCase() == trim(fieldValue).toLowerCase())
					{
						params[j] = trim(suggparams[i]);
						j++;
					}
					
				}
				var html = "";
				var i = 0;
				var divHeight = 0;
				var scroll = null;
				if(params.length > 6)
				{
					divHeight = 100;
					scroll = "auto";
				}
				else
				{
					divHeight = "";
					scroll = "hidden";
				}
				while(i<params.length)
				{
	
					html+="<tr><td width='50%' onmouseOver=\"this.style.backgroundColor='#F8FBF0';\" onmouseOut=\"this.style.backgroundColor='#ffffff';\" style=\"padding-left:5px;\"><div style='visibility:hidden;display:block;position:absolute;'>"+params[i]+"</div><a href=\"javascript:selectedSuggestion('"+params[i]+"');\" onmouseOver=\"this.style.color='#71A115';\" onmouseOut=\"this.style.color='#006699';\" style='cursor:pointer;font-size:12px;color:#006699;'><span style='font-weight:bold;'\">"+params[i].substring(0,len)+"</span><span>"+params[i].substring(len,params[i].length)+"</span></a></td><td width='50%' onmouseOver=\"this.style.backgroundColor='#F8FBF0';\" onmouseOut=\"this.style.backgroundColor='#ffffff';\" style=\"padding-left:5px;\">";
					if(params[i+1] != null && params[i+1] != "")
					{
						i++;
						html+="<div style='visibility:hidden;display:block;position:absolute;'>"+params[i]+"</div><a href=\"javascript:selectedSuggestion('"+params[i]+"');\" style='cursor:pointer;font-size:12px;color:#006699;' onmouseOver=\"this.style.color='#71A115';\" onmouseOut=\"this.style.color='#006699';\"><span style='font-weight:bold;'>"+params[i].substring(0,len)+"</span><span>"+params[i].substring(len,params[i].length)+"</span></a>";
					}
					html+="</td></tr>";
					i++;
				}
				var htmlString = "";
				var isLength = true;
				if(params.length == 0)
				{
					boxDivObj.style.visibility = "hidden";
					boxDivObj.style.display = "none";
					isLength = false;
					//htmlString ="<br><div style='font-size:12px;color:red;font-weight:bold;' align='center'>Sorry! No Suggestions.</div><br>";
	
				}
				else
				{	
					htmlString = html;
				}
				var htmlString = "<table id='tab11' border='0' width='100%' cellspacing='0' cellpadding='0'><tr><th width='50%' align='left'>Search suggestions:</th><th width='50%' align='right' ><a href=\"javascript:hideSuggestionBox('suggesstionBox');\" style='cursor:pointer;'><img src='"+contextPath+"/naaptolImages/Bt_Remove.gif'></a></th></tr><tr><td valign='top' colspan='2' style='margin: auto;'><div id='test' style='overflow:"+scroll+";height:"+divHeight+"px;margin-top:0px;'><table id='suggestionTable' width='100%' border='0' cellspacing='0' cellpadding='0'>"+htmlString+"</table></div></td></tr></table>";

				if(isLength)
				{
					boxDivObj.innerHTML = htmlString;
					boxDivObj.style.visibility = "visible";
					boxDivObj.style.display = "block";
				}
				
			}
		}
	}
	else if(fieldValue.length < 1)
	{
		hideSuggestionBox(boxDivId);
	}
	}
}
else if(fieldVal.length < 1)
	{
		hideSuggestionBox(boxDivId);
	}
}
/**
	Hide suggestion box.
*/
function hideSuggestionBox(boxDivId)
{
		var boxDivObj = document.getElementById(boxDivId);
		boxDivObj.style.visibility = "hidden";
		boxDivObj.style.display = "none";
}
/**
	Show Suggstion box.
*/
function showSuggestionBox(fieldId,boxDivId)
{
		var fieldObj = document.getElementById(fieldId);
		var fieldValue = fieldObj.value;
		var boxDivObj = document.getElementById(boxDivId);
		if(trim(fieldValue).length > 0)
		{
			boxDivObj.style.visibility = "visible";
			boxDivObj.style.display = "block";
		}
}
/**
	when user will select suggestion , it will forword suggestion on search result page.
*/
function selectedSuggestion(fieldValue)
{
	
		document.getElementById('searchtxt').value = fieldValue;
		document.searchForm.action=path+"/faces/components/search/searchEncode.jsp";
	 	document.searchForm.submit();	
	 
}
/** 
	hide the suggestion box.
*/
function hideNActivate(fieldId,boxDivId)
{
	hideSuggestionBox(boxDivId);
	
}
/**
	It will set the cursor on selected suggestion using navigation key.
	Highlight the selected suggestion.
*/
function setCursor(e)
{
var textObj = document.getElementById('searchtxt');
	
	try{
	if(e.keyCode != 13)
	{
	if(e.keyCode == 40 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 37)
	{
	if(e.keyCode == 40)
	{
		var isTrue = false;
		try
		{
			firstColumn++;
			var x = document.getElementById('suggestionTable').rows[firstColumn].cells;
			isTrue = true;
			
			//var obj = document.getElementById('test');
			//obj.scrollDown;
			
		}
		catch(e)
		{
			isTrue = false;
			firstColumn--;
			
		}
		if(isTrue)
		{
			if(myState != null)
			{
				myState.style.backgroundColor = "#FFFFFF";
				myState.style.color = '#006699';
				
				
			}
			x[firstCellIndex].style.backgroundColor = "#F8FBF0";
			myState = x[firstCellIndex];
			myState.focus();
			textObj.focus();
			
			
			
		}
		
	}
	else if(e.keyCode == 38)
	{
		
		var isTrue = false;
		try
		{
			firstColumn--;
			var x = document.getElementById('suggestionTable').rows[firstColumn].cells;
			isTrue = true;
			
		}
		catch(e)
		{
			isTrue = false;
			firstColumn++;
			
		}
		if(isTrue)
		{
			if(myState != null)
			{
				myState.style.backgroundColor = "#FFFFFF";
				myState.style.color = "#006699";
			}
			x[firstCellIndex].style.backgroundColor = "#F8FBF0";
			x[firstCellIndex].style.color = "#71A115";
			myState = x[firstCellIndex];
			myState.focus();
			textObj.focus();
		}
		
	}
	else if(e.keyCode == 39)
	{
		var isTrue = false;
		try
		{
			var x = document.getElementById('suggestionTable').rows[firstColumn].cells;
			isTrue = true;
		
		}
		catch(e)
		{
			isTrue = false;
		}
		if(isTrue)
		{
			if(firstCellIndex == 0)
			{
				firstCellIndex++;
				myState.style.backgroundColor = "#FFFFFF";
				myState.style.color = "#006699";
			}
		else
		{
			firstCellIndex--;
			myState.style.backgroundColor = "#FFFFFF";
			myState.style.color = "#006699";
		}
			x[firstCellIndex].style.backgroundColor = "#F8FBF0";
			x[firstCellIndex].style.color = "#71A115";
			myState = x[firstCellIndex];
		}


	}
	else if(e.keyCode == 37)
	{
		var isTrue = false;
		try
		{
			var x = document.getElementById('suggestionTable').rows[firstColumn].cells;
			isTrue = true;
		
		}
		catch(e)
		{
			isTrue = false;
			
		}
		if(isTrue)
		{
			if(firstCellIndex == 0)
			{
				firstCellIndex++;
				myState.style.backgroundColor = "#FFFFFF";
				myState.style.color = "#006699";
			}
			else
			{
				firstCellIndex--;
				myState.style.backgroundColor = "#FFFFFF";
				myState.style.color = "#006699";
			}
			x[firstCellIndex].style.backgroundColor = "#F8FBF0";
			x[firstCellIndex].style.color = "#71A115";
			myState = x[firstCellIndex];
		}

	}
	document.getElementById('searchtxt').value = x[firstCellIndex].firstChild.innerHTML;
	
	}
	}
	else if(e.keyCode == 13)
	{
		searchAction(document.getElementById('searchtxt').value);
	}
	}catch(e)
	{
	}
	
}


/////////// functions from luceneSearcherForFooter.jsp


function searchActionFooter()
{
	var query = document.getElementById('footertxt').value;
//  alert(query);
  if(trim(query)==null || trim(query)=="" || trim(query)==" ")
  {
  alert('Please Enter keyword you want to Search.');
  document.getElementById('footertxt').focus();
 return false;
  }
  else{	
	//	alert("searchtxtFooter");
		var form_id = document.getElementById('searchFormFooter');
		document.searchFormFooter.action=path+"/faces/components/search/searchEncode.jsp";
		document.searchFormFooter.submit();
	//	alert("return");
	}
}
 function checkSpecialCharsFooter(evt){	

		//	alert("sagar");
	
			var charCode = (evt.which) ? evt.which : evt.keyCode;
			if (!((charCode > 64 && charCode < 91) || charCode==8 || ((charCode > 96) && (charCode < 123)) || ((charCode > 47) &&
					(charCode < 58)) || ((charCode > 31) && (charCode < 33)) || ((charCode > 45) && (charCode < 47)) ||
				((charCode > 12) && (charCode < 14))  )) 	{
							alert(" No Special Characters Allowed ! ");
							
  							return false;
			}
			if(charCode == 13){
			//	alert("return search Action");
				return searchActionFooter();
			}
			return true;
}	
function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

function showLink(ctr)	{				
				var divd = "";
				for (i=1; i<=5; i++){
					divd = eval("div"+i);
					divdTD = eval("div"+i+"Tab");
					if (i == ctr){
						divd.style.visibility = "visible";
						divd.style.display = "block";
						divdTD.className = "";
					}
					else{
						divd.style.visibility = "hidden";
						divd.style.display = "none";
						divdTD.className = "";
					}
				}
			}
var path="";
if(document.getElementById("contextPathJsp")){
	path= document.getElementById("contextPathJsp").value;
//	alert(path)
}



function isAgree(fieldValue,errObj,fieldId)
{
	var isReturnTrue = false;
	var test = document.getElementById(fieldId).checked;
	if(test)
	{
		isReturnTrue = true;
	}
	else
	{
		errObj.innerHTML = "Please agree Naaptol Terms & Conditions";
		isReturnTrue = false;
	}
	return isReturnTrue;
}

/* End- functions for userSignUp popup */


/* start - common javascript functions */
/*
function isFieldBlank(all parameters)
fieldValue - pass the string
errObj - pass the span/div object to show error message
errorMessage - pass the error Message which u want to show to the user.
fieldId - pass the field id to this function.Is the id of text field.
*/
function isFieldBlank(fieldValue,errorObj,errorMessage,fieldId)
{
	fieldBlank = false;
	//alert(fieldId);
	if(fieldValue==null || trim(fieldValue) == "" || fieldValue==0)
	{
		
		errorObj.innerHTML = errorMessage;
		document.getElementById(fieldId).focus();
		fieldBlank = false;
	}
	else
	{
		fieldBlank = true;
	}
	return fieldBlank;
}
/*function isValidFieldValueLength(all parameters) - This function validate the length of the field value.Parameters are
fieldValue - pass the string
errObj - pass the span/div object to show error message
errorMessage - pass the error Message which u want to show to the user.
fieldId - pass the field id to this function.Is the id of text field.
minLength - minimam length of string.
maxLength - maximum length of string.
*/

function isValidFieldValueLength(fieldValue,errObj,errorMessage,fieldId,minLength,maxLength)
{
	var isReturnTrue = false;
	if(fieldValue.length < minLength || fieldValue.length > maxLength)
	{
		
		errObj.innerHTML=errorMessage;
		document.getElementById(fieldId).value="";
		document.getElementById(fieldId).focus();
		isReturnTrue = false;
	}
	else
	{
		isReturnTrue = true;
	}
	
	return isReturnTrue;
	
}

/* 
function isEqualTwoFieldStrings(all parameters)
firstString - pass String for checking the equal string
secondString - pass String for checking the equal string
errObj - pass the span/div object to show error message
errorMessage - pass the error Message which u want to show to the user.
firstFieldId - pass the field id to this function.Is the id of text field.
secondFieldId - pass the field id to this function.Is the id of text field.
*/
function isEqualTwoFieldStrings(firstString,secondString,errObj,errorMessage,firstFieldId,secondFieldId)
{
	var isReturnTrue = false;
	if(firstString == secondString)
	{
		isReturnTrue = true;
	}
	else
	{
		errObj.innerHTML = errorMessage;
		document.getElementById(firstFieldId).value="";
		document.getElementById(secondFieldId).value="";
		document.getElementById(firstFieldId).focus();
		isReturnTrue = false;
	}
	return isReturnTrue;
}

/*
function isNameisValid(all parameters)
firstNameString - pass First Name to check
errObj - pass the span/div object to show error message
errorMessage - pass the error Message which u want to show to the user.
fieldId - pass the field id to this function.Is the id of text field.
*/
function isNameisValid(firstNameString,errObj,errorMessage,firldId)
{
	var isReturnTrue = false;
	var regExpForFirstName = /^([a-z A-Z]+)([\s]*[\.]?[a-z A-Z]*)*$/;
	if (regExpForFirstName.test(firstNameString))
	{
		isReturnTrue = true;
	}
	else
	{
		errObj.innerHTML=errorMessage;
		document.getElementById(firldId).value="";
		document.getElementById(firldId).focus();
		isReturnTrue = false;
	}
	return isReturnTrue;
}
function isNumberStringValid(input)
{	
	var pattern=/^[0-9]+$/;
	return pattern.test(input);
}

/* End- common javascript functions  */


function checkTextAreaMaxlength(fieldValue,errObj,errorMessage,fieldId,fieldLength)
{
	var isReturn  = false;
	if(fieldValue != null)
	{
		if(parseInt(fieldValue.length) > parseInt(fieldLength)){
			errObj.innerHTML = errorMessage;
			document.getElementById(fieldId).focus();
			isReturn =  false;
		}
		else 
		{
			isReturn = true;
		}
	}
	else
	{
		isReturn = true;
	}
		return isReturn;
	}
function isSellerPhoneNo2Valid(fieldValue,errObj,errorMessage,fieldId)
{
	var isReturn = false;
	if(fieldValue != "" && fieldValue != null)
	{
		var validNo = isNumberStringValid(fieldValue);
		if(!validNo)
		{
			errObj.innerHTML = errorMessage;
			document.getElementById(fieldId).value = "";
			document.getElementById(fieldId).focus();
			isReturn = false;
		}
		else
		{
			isReturn = true;
		}
	}
	else
	{
		isReturn = true;
	}
	return isReturn;
}
function isUrlMandentary(fieldValue,isOnlineOffline,errObj,fieldId)
{
	var isReturn = false;
	//var isOn_Offline = document.getElementsByName(isOnlineOffline)[1].checked;
	if(isOnlineOffline == "Offline")
	{
		isReturn = true;
	}
	else if(isOnlineOffline == "Online" && fieldValue == "")
	{
		errObj.innerHTML = "Please Enter Store Url (If seller is Online).";
		document.getElementById(fieldId).focus();
		isReturn = false;
		
	}
	else if(isOnlineOffline == "Online" && fieldValue != "")
	{
		isReturn = true;
	}
	return isReturn;
}
function isSellerPhoneNoValid(fieldValue,errObj,errorMessage,fieldId)
{
	var isReturn = false;
	var validNo = isNumberStringValid(fieldValue);

	if(!validNo)
	{
		errObj.innerHTML = errorMessage;
		document.getElementById(fieldId).value = "";
		document.getElementById(fieldId).focus();
		isReturn = false;
	}
	else
	{
		isReturn = true;
	}
	return isReturn;
}
function isMobileNoValid(mobNo,errObj,errorMessage,fieldId)
{
	var isReturn = false;
	var isTrue = isNumberStringValid(mobNo);
	if(!isTrue)
	{
		errObj.innerHTML = errorMessage;
		document.getElementById(fieldId).value="";
		document.getElementById(fieldId).focus();
		isReturn = false;
	}
	else
	{
		if(!isValidFieldValueLength(mobNo,errObj,'Please enter a valid mobile number(atleast 10 Numbers).',fieldId,10,15))
		{
		
			isReturn = false;
		}
		else
		{
			isReturn = true;
		}
    	
	}
	return isReturn;
}


function checkMobileNo(mobNo,errObj,errorMessage,fieldId)
{

	var isReturn = false;
	
	if(mobNo.substring(0,2)=="92" || mobNo.substring(0,2)=="93" || mobNo.substring(0,2)=="94" || mobNo.substring(0,2)=="92" || mobNo.substring(0,2)=="97" || mobNo.substring(0,2)=="98" || mobNo.substring(0,2)=="99")
	{
		isReturn = true;
	}
	else
	{
		
		errObj.innerHTML = errorMessage;
		document.getElementById(fieldId).value="";
		document.getElementById(fieldId).focus();
		isReturn = false;
	}
	return isReturn;
	
}
function isPinCodeValid(fieldValue,errObj,errorMessage,fieldId)
{
	var isReturn = false;
	var isTrue = isNumberStringValid(fieldValue);
	if(!isTrue)
	{
		errObj.innerHTML = errorMessage;
		document.getElementById(fieldId).value="";
		document.getElementById(fieldId).focus();
		isReturn = false;
	}
	else
	{
		isReturn = true;
	}
	return isReturn;
}

function isEmailIdValid(emailId,divObj,errorMessage,fieldId)
{
	var emailRegxp = /^([a-zA-Z0-9]+)([_.]?[a-zA-Z0-9]+)*@([a-zA-Z0-9_]+)(.[a-zA-Z0-9_]{2,3}){1,2}$/;
	var emailrignt = false;
	if (emailRegxp.test(emailId))
	{
		emailrignt = true;
	}
	else
	{
		if(divObj && errorMessage)
		divObj.innerHTML=errorMessage;
		else
			alert("Exception:-Div Object or Error Message is not set.");
		if(fieldId)
		{
			document.getElementById(fieldId).value = "";
			document.getElementById(fieldId).focus();
		}
		emailrignt = false;
	}
	return (emailrignt);
}
/*End- functions for Seller Registration popup */

/* End - javascript validatins for seller popups  */

function getFavoriteParams(params){
	var extrparams = params;
	
	return  extrparams;
}


function validatePrice(price){
		var valPrice = price.value;
	
		var check = checkValidNumber(valPrice);
			
		
			if(!check && valPrice !=""){
				alert("Please Enter only Number");
				price.value="";
				price.focus();
				return false;
			}else{
				return true;					
			
		}
		
	}

	function checkValidNumber(input)
	{	

		var pattern=/^[+]?([0-9]+|([(]{1}[0-9]+[)]{1}[0-9]+)|([0-9]+[-]{1}[0-9]+))$/;
		
		return pattern.test(input);
	}
	

 function submitPopup(e,obj,id)
{
	if(e.keyCode == 13)
	{
		doRequest(id,obj);
		return true;
	}
	
	
}

/*start -  following function is used for cookies programing */
function getCookie(cookieName)
{

	if (document.cookie.length>0)
	{
		  c_start=document.cookie.indexOf(cookieName + "=");

  		  if (c_start!=-1)
		  { 
			    c_start=c_start + cookieName.length+1; 
			    c_end=document.cookie.indexOf(";",c_start);

				    if (c_end==-1) c_end=document.cookie.length;
					    return unescape(document.cookie.substring(c_start,c_end));

          } 

    }

return "";
}

 

function set_Cookies()

{
	var expiredays=365;
    var userMailId=document.getElementById('loginId').value;
    var password=document.getElementById('password').value;
    var rememberCheckBox = document.getElementById("rememberChkBox");

    if(rememberCheckBox.checked==true)
    {
        var exdate=new Date();
        exdate.setDate(exdate.getDate()+expiredays);
        document.cookie='userIdRembCookie'+"="+ escape(userMailId)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
        document.cookie='passwordRembCookie'+"="+escape(password)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

return true;
}

 

function check_Cookies()
{

	var userEnteredEmail=document.getElementById('loginId').value;
	if(userEnteredEmail != null && userEnteredEmail != ''){
		var userId=getCookie('userIdRembCookie');
		var paswd=getCookie('passwordRembCookie');
	
	 	if (userId!=null && userId!="")
	    {
	            if(userEnteredEmail==userId)
	            {
		            document.getElementById('password').value=paswd;
	            }
	     }
	}
return true;
}

function delete_cookie(cookie_name)
{
  var cookie_date = new Date ();  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
  
}
function logoutUser(path,cookieName)
{
	delete_cookie(cookieName);
	window.location.href = path;
	
}
/*end -  following function is used for cookies programing */

function checkSpecialCharsHeader(evt){

			var charCode = (evt.which) ? evt.which : evt.keyCode;
			if (!((charCode > 64 && charCode < 91) || ((charCode > 7) && (charCode < 10)) || charCode==91 || ((charCode > 96) && (charCode < 123)) || ((charCode > 47) &&
					(charCode < 58)) || ((charCode > 36) && (charCode < 41)) || ((charCode > 31) && (charCode < 33)) || ((charCode > 45) && (charCode < 47)) ||
				((charCode > 12) && (charCode < 14))  )) 	{
							alert(" No Special Characters Allowed ! ");
							
  							return false;
			}
			return true;
}	

/*Start - following function is used for showing the banner's at the time of body page load */
function showBanner(params){
	var bannerIdArray = new Array();
	bannerIdArray = params.split(",");
	
	for(var i=0;i<bannerIdArray.length;i++){
		var prms = new Array();
		prms = bannerIdArray[i].split("&");
		var pkId="";var bDesc="";var bannerParams="";
		if(prms[0]){
			pkId = prms[0];
		}if(prms[1]){
			bDesc = prms[1];
		}
		bannerParams = "pkId="+pkId+"&bannerDesc="+bDesc;
		//alert("bannerParams->>"+bannerParams);
		callBanner(bannerParams,pkId);
	}
}

function callBanner(bannerParams,divId)
{
	//invoke(path+"/jsp/showBanner.jsp?"+bannerParams,divId);
	
	var iframeObj = document.getElementById(divId);
	iframeObj.src = path+"/jsp/showBanner.jsp?"+bannerParams;
	
	
}
function getBannerDesc(parameters){
	var ary = parameters.split(",");
	var desc = document.getElementById();
}
/*End - following function is used for showing the banner's at the time of body page load */
/*start-following function are from mm_menu.js. This js is used for menuIndex.jsp*/
function divShowHide(divName,act,tdId){	
var browser = navigator.appName;
var b_version=navigator.appVersion;
//alert("--b_version--->>"+b_version);
	document.getElementById(divName).style.display = 'none';
	if (act == "show")
	{
		var obj = document.getElementById(tdId);
		var posx = findPosX(obj);
		var posy = findPosY(obj);
		var show0Obj = document.getElementById('show0');
		var widths1 = 995 + findPosX(show0Obj);
		var totWidth = posx + 285;
		if(parseInt(totWidth) > parseInt(widths1)){
			posx = widths1 - 285;
			
		}else{
			posx = posx;
			
		}
		
		if(b_version.match("Chrome") == "Chrome"){
		
		
			posy = posy+22;
		}else{
			posy = posy+44;
		}
		var divObj = document.getElementById(divName);
		divObj.style.display = 'block';
		divObj.style.zIndex = '10';
		divObj.style.left = posx+'px';
		divObj.style.top = posy+'px';
		
	}
	else if (act == "hide")
	{
		document.getElementById(divName).style.display = 'none';
	}
}
function findPosX(obj)
{
	var _e9=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			_e9+=obj.offsetLeft;
			obj=obj.offsetParent;
		}
		
	}
	else
	{
		if(obj.x){
			_e9+=obj.x;
		}
	}
	return _e9;
}

function findPosY(obj)
{
	var _eb=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			_eb+=obj.offsetTop;
			obj=obj.offsetParent;
		}
	}
	else
	{
		if(obj.y){
		_eb+=obj.y;
		}
	}
	return _eb;
}

/*end-following function are from mm_menu.js. This js is used for menuIndex.jsp*/
/**
	start - open div and hide sub-category when click on arrow image
*/		
function divopen(test,imageName,linkName)
{
	
	var imgName = document.getElementById(imageName);
	imgName.src = contextPath+'/images/Nav_more2.gif';

	var link_Name = document.getElementById(linkName);
	link_Name.href = "javascript:divclose('"+test+"','"+imageName+"','"+linkName+"')";

	document.getElementById(test).style.display="block";
	document.getElementById(test).style.visibility="visible";	
}				



function divclose(test,imageName,linkName)
{
	
	var imgName = document.getElementById(imageName);
	imgName.src = contextPath+'/images/Nav_more3.gif';
	
	var link_Name = document.getElementById(linkName);
	link_Name.href = "javascript:divopen('"+test+"','"+imageName+"','"+linkName+"')";

	document.getElementById(test).style.display="none";
	document.getElementById(test).style.visibility="hidden";
}
/**
	End - open div and hide sub-category when click on arrow image
*/		

/*
* function to display div popup at given offset position
* objId  - object id where to display popup
* leftOffset - left offset value
* topOffset - top offset value
* divId - divId to be displayed as popup
*/
function displayDivAtObjectPos(objId,leftOffset,topOffset,divId)
{

		closeDefnPopups = divId;
		 var posx= getRealLeft(objId);

                        var posy= getRealTop(objId);

                        var divObj = document.getElementById(divId);

                        if(divObj!=null)

                        {

                                    divObj.style.left=posx + leftOffset;

                                    divObj.style.top=posy + topOffset;

                                    divObj.style.display="block";

                                    divObj.style.visibility="visible";     

                        }                                   

}
/* funciton will return the left position of the component 
*	comid - 
*/

   function getRealLeft(comid) { 

    xPos = document.getElementById(comid).offsetLeft; 

    tempEl = document.getElementById(comid).offsetParent; 

      while (tempEl != null) { 

          xPos += tempEl.offsetLeft; 

          tempEl = tempEl.offsetParent; 

      } 

    return xPos; 

} 

/* this function well return the top position of component 
* comid - 
*/

function getRealTop(comid) {

    yPos = document.getElementById(comid).offsetTop; 

    tempEl = document.getElementById(comid).offsetParent; 

    while (tempEl != null) { 

          yPos += tempEl.offsetTop; 

          tempEl = tempEl.offsetParent; 

      } 

    return yPos; 

}
	function showHelpPopup(objId,divId,leftPos,rightPos)
	{
		displayDivAtObjectPos(objId,leftPos,rightPos,divId);
	}

	
	
	

function showImage(imgPath,e)
{

var ie4 = document.all && !document.getElementById;
var ie5 = document.all && document.getElementById;
var ns6 = !document.all && document.getElementById;
var ns4 = document.layers;

	var axisX = e.clientX;
	var axisY = e.clientY;
	var screenX = screen.width;
	var screenY = screen.height;
	
	var imgObj = document.getElementById('imageDiv');
	
	var newImg = new Image();
    newImg.src = imgPath;
    var height = 250;
    var width = 250;
	imgObj.style.width = "250px";
	imgObj.style.height = "250px";
	imgObj.src = imgPath;
	
	var posX = 0;
	var posY = 0;
	var mouse_x=0;
    var mouse_y=0;
	var pos_x = 0;
	var pos_y = 0;
	var win_width = 0;
	var win_height = 0;

	var win_scroll_x = (ie4 || ie5) ? self.document.body.scrollLeft : self.pageXOffset;
    var win_scroll_y = (ie4 || ie5) ? self.document.body.scrollTop : self.pageYOffset;

 	 var scrollbar_size =  0;


if(ie4)
{
	mouse_x=event.x;
    mouse_y=event.y;
}
if(ie5)
{
	mouse_x=event.x+self.document.body.scrollLeft;
    mouse_y=event.y+self.document.body.scrollTop;
}

if (ie4 || ie5)
 { 
	win_width = self.document.body.clientWidth;
	win_height = self.document.body.clientHeight;

		
 }
 if (ns4)
 {
	win_width = self.innerWidth;
	win_height = self.innerHeight;
	mouse_x=e.pageX;
	mouse_y=e.pageY;
 }
 if (ns6)
 { 
	win_width = self.outerWidth;
	win_height = self.outerHeight;
	mouse_x=e.pageX;
	mouse_y=e.pageY;
 }

 	if (mouse_y + height > win_height + win_scroll_y - scrollbar_size)
 	{
		pos_y = mouse_y - height-40;
		pos_x = mouse_x - width/2;
 	}
 	else
 	{
 		pos_x = mouse_x - width/2;
 		pos_y = mouse_y+10;
 	}
	
	var high = window.screen.availHeight
	var val = screenY-axisY;
	if(axisY+height > screenY) 
	{
		posX = 	axisX;
		posY = axisY - 45;
		
	}
	else 
	{
		posX = axisX;
		posY = axisY - height;
		
	}
	
	
	
	var divObj = document.getElementById('showImages');
	divObj.style.left = pos_x;
	divObj.style.top = pos_y;
	divObj.style.width = 250;
	divObj.style.height = 250;
	divObj.style.visibility = "visible";
	divObj.style.display = "block";
	divObj.style.position = "absolute";
	
	posX = 0;
	posY = 0;
	axisX = 0;
	axisY = 0;
	screenX = 0;
	screenY = 0;
	
}



function hideImage(divId)
{
	var divObj = document.getElementById(divId);
	divObj.style.visibility = "hidden";
	divObj.style.display = "none";

}

function rateReview(id,show_imgno)
	{
		
		val = id.substring(0,id.length-1);
		
			  for (ui=1;ui<=5;ui++)
          	  {
          	   mobj=document.getElementById(val+ui);
			   if (ui<=show_imgno) mobj.src=contextPath+"/naaptolImages/StarBig1.gif"
          	   else mobj.src=contextPath+"/naaptolImages/StarBig2.gif"
          	  }
		
	}

	function removeRatingReview(id,show_imgno)
	{
		val = id.substring(0,id.length-1);

	    	  for (ui=1;ui<=5;ui++)
          	  {
          	   mobj=document.getElementById(val+ui);
          	   mobj.src=contextPath+"/naaptolImages/StarBig2.gif"
          	  }
          	  
	
	}
	
	function setReview(id,show_imgno)
	{
	
		val = id.substring(0,id.length-1);
		
		for (ui=1;ui<=5;ui++)
          	  {
          	   mobj=document.getElementById(val + ui);
			   mobj.onmouseout="";	 
			   mobj.onmouseover="";	
		   	   if (ui<=show_imgno) 
				   mobj.src=contextPath+"/naaptolImages/StarBig1.gif"
				
          	   else
				   mobj.src=contextPath+"/naaptolImages/StarBig2.gif"
				
          	  }
		document.getElementById(val).value=show_imgno;
		
	}
	
	/* function to check continous text with no space in it */
	function checkSpace(textArea){
		
		var areaText = textArea.value;
		var text = new Array();
		text = areaText.split(" ");
		var newText=""; 
		var maxchars=30;
		for(var j=0;j<text.length-1;j++){
		
			newText = newText+text[j]+" ";
		}
		//alert("text  "+text);
		//var i= text.length-1;
		for(var i=0;i<text.length; i++)
		{
			areaText = textArea.value;
			if(text[i].length>maxchars){
			
			newText="";
				alert("Continuous text without space not allowed");
				
				//textArea.value=areaText.replace(text[i],text[i].substring(0,maxchars));
				maxText = text[i];
				while(text[i].length>maxchars){
					
					newText = newText+text[i].substring(0,maxchars)+" ";
					text[i]= text[i].substring(maxchars+1);
				}
				if(text[i].length<maxchars)
					newText = newText+ text[i];
					
					//alert("newText  "+newText+ " maxText... "+maxText);
				textArea.value = areaText.replace(maxText,newText);
				//return false;
			}
		}
		return true;
		
	}
	
