function submitSearch(url,count) {
	var urlHref = document.signInForm.url.value;
	if(urlHref.startsWith("color")){
		removeColorPickers();
	}
	if(url == 'searchProductbyName'){
		/*document.getElementById("product").innerHTML = " Fabrics";
		document.getElementById("market").innerHTML = "Market ";*/
		document.getElementById("colorSearchEvent").value = "colorSrDone";
		return productValidation(url);
	}else if(url == 'searchProduct'){
		/*document.getElementById("product").innerHTML = " Fabrics";
		document.getElementById("market").innerHTML = "Market ";*/
		document.getElementById("colorSearchEvent").value = "colorSrDone";
		return searchValidation(url,count);
	}
}
function searchValidation(url,count){
	var selectOptionName;
	var selectCount = 0;
	var selectMarket = 0;
	for(var i=1;i<count;i++){
		selectOptionName = 'select'+i;
		if(document.getElementById(selectOptionName).value == 'select'){
			selectCount++;
		}
	}
	if(document.getElementById("MarketGroup").value == 'select'){
		selectMarket++;
	}
	if(selectCount == 0){
		if((selectMarket > 0) && (!(document.getElementById("newProduct").checked))){
		//if((!(document.getElementById("newProduct").checked))){
			alert("Select atleast One Search Criteria");
			return false;
		}else{
			document.searchProduct.action= url+'.jef'; 
			document.searchProduct.method='get';
			document.searchProduct.submit();
			/*var url1=url+'.jef';
			new Ajax.Updater('items', url1,
	    	{method: 'post',onCreate: function() { showOverlay(); },
			  	  onComplete: function() { hideOverlay();},  parameters: $(document.searchProduct).serialize(true) });*/	
		}		
	}else{
		if( (selectCount == (count-1)) && (selectMarket > 0) && (!(document.getElementById("newProduct").checked))){
		//if( (selectCount == (count-1)) &&  (!(document.getElementById("newProduct").checked))){
			alert("Select atleast One Search Criteria");
			return false;
		}else{
			document.searchProduct.action= url+'.jef'; 
			document.searchProduct.method='get';
			document.searchProduct.submit();
			/*var url1=url+'.jef';
			new Ajax.Updater('items', url1,
	    	{method: 'post',onCreate: function() { showOverlay(); },
			  	  onComplete: function() { hideOverlay();},  parameters: $(document.searchProduct).serialize(true) }); */	
		}
	}
}
function productValidation(url){
	if(document.searchProduct.productName.value == ""){
		alert("Enter the Product Number or Product Name");
		document.searchProduct.productName.focus();
		return false;
	}else if(!checkSpecial(document.searchProduct.productName.value)){
		alert("Enter only Alpha Numeric");
		document.searchProduct.productName.value = "";
		document.searchProduct.productName.focus();
		return false;
	}else{
	  	/*document.searchProduct.action= url+'.jef'; 
		document.searchProduct.method='post';
		document.searchProduct.submit();*/
		var url1=url+'.jef';
			new Ajax.Updater('items', url1,
	    	{method: 'post',onCreate: function() { showOverlay(); },
			  	  onComplete: function() { hideOverlay();}, parameters: $(document.searchProduct).serialize(true) });	
	}
}
//check for special characters
function checkSpecial(val){
	var specialChar = "!@#$%^&*'\()~-_=+?/><.,;:";
	var spExists = false;
	for(var i=0; i< val.length; i++) {
    	if(specialChar.indexOf(val.charAt(i)) >= 0) {
    		spExists = true;
        }
    }
    if(spExists){
    	return false;
    }else{
    	return true;
    }
}
//Ended.
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	document.getElementById("colorSearchEvent").value = "colorSrDone";
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
function searchCategory(){
	if(document.getElementById("Category").value == 'select'){
		alert("Select any one Category");
		document.getElementById("Category").focus();
		return false;
	}else{
		document.searchProduct.action= 'searchProductCategory.jef'; 
		document.searchProduct.method='get';
		document.searchProduct.submit();
	}
}


function onKeyPressValidate(evt){
	var key;
	if(window.event){ // IE
		key = evt.keyCode;
	}else{ // FIREFOX
		key = evt.which;
	}
	if(key==13){
		return validatePID();
	}
}
function lockElements(){ 
	var winW = 630, winH = 460;
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	winH = winH +"px";
	winW =winW+"px";
	document.getElementById("backDiv").style.width = winW;
	document.getElementById("backDiv").style.height =winH;
	document.getElementById("backDiv").style.left = "0px";
	document.getElementById("backDiv").style.top = "0px";
	document.getElementById("backDiv").style.display = "block";
} 
function unLockElements(){  
if(document.getElementById("backDiv")!=null){
   document.getElementById("backDiv").style.display = "none";
   }
}


function showEmailblock(left, top)	{
	lockElements();
	document.getElementById("blockEmailValue").style.width = "530px";
	document.getElementById("blockEmailValue").style.left = (screen.width - 750) + "px";
	document.getElementById("blockEmailValue").style.top = "600px";
	document.getElementById("blockEmailValue").style.display = "block";
	document.getElementById("mailId").focus();
}
function hideEmailblock()	{
    unLockElements();
	document.getElementById("blockEmailValue").style.display = "none";
}
function validateEmail(){
		

	return false;
}
function removeColorPickers(){
   var images = document.images;
   
         for (i=0;i < images.length; i++){
               
               var url=images[i].src;
               var urlArr=url.split("/");
               
               if(urlArr[urlArr.length-1]=="mappoint.gif"){
               images[i].style.display='none' ;    
               }
               if(urlArr[urlArr.length-1]=="rangearrows.gif"){
               images[i].style.display='none' ;    
               }
         }
}
function showOrderblock(left, top)	{
	addLock();
	document.getElementById("blockOrder").style.width = "650px";
	document.getElementById("blockOrder").style.left = (screen.width - 850) + "px";
	document.getElementById("blockOrder").style.top = "170px";
	document.getElementById("blockOrder").style.display = "block";
}
function hideOrderblock()	{
    unLockElements();
	document.getElementById("blockOrder").style.display = "none";
}


function ajaxAddtoCart(resultFromOrder){
	var url = 'addToCart.jef?val='+resultFromOrder;
	if (window.XMLHttpRequest) {
	     self.xmlHttpReq = new XMLHttpRequest();
	  } else if (window.ActiveXObject) { 
	     self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
	  }
	  self._async=Boolean(true);
	  self.xmlHttpReq.open('POST', url, true);
	  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  self.xmlHttpReq.onreadystatechange = function() {
	  	if (self.xmlHttpReq.readyState == 4) {
	  	  if(self.xmlHttpReq.status == 200){
			var response = self.xmlHttpReq.responseText;
			var result = response.substring(0,12);
			if(result.startsWith('success')){
				var countarr = new Array();
				countarr = result.split('||');
				document.getElementById("cartItems").innerHTML = "("+trim(countarr[1])+") ";
				if(trim(countarr[1])!=""){
					document.getElementById("errMessage").innerHTML = "";
				}else{
					document.getElementById("errMessage").innerHTML = "Product not added to Cart";
				}
				document.getElementById("error").focus();
				return false;
			}else{
				document.getElementById("errMessage").innerHTML = "Product not added to Cart";
				document.getElementById("error").focus();
				return false;
			}
		  }
		}
	  }
	  self.xmlHttpReq.send('');
}
function trim(stringToTrim) {
 	return stringToTrim.replace(/^\s+|\s+$/g,"");
 }