//----trim spaces function---->
function trimspace(str)
{
  var len= str.length;
  if (len != 0)
  {
    for(var i=0;i<len;i++)
    {
      if(str.indexOf(" ")==0)
        str=str.substring(1,len);
    }
    strtrim=str;
  }
  else
  {
    strtrim=str;
  }
  return strtrim;
}

function addtocart(code,i){
	var q = document.getElementById(i);
	//alert(q);
	
	
		if(q){			
			if(trimspace(q.selectedIndex) == '')
			{
				alert("Please Select the Quantity to Add to Cart");
				document.getElementById(i).focus();
				return;
			}else
				q = q.selectedIndex;
		}
		else
			q = 1;
		var hr = location.href;
		location.href = "cart_proccess.php?id="+code+"&qty="+q+"&q="+escape(hr.substr(hr.lastIndexOf("/") + 1));
	
}

function addtocart1(code,i){
	var q = document.getElementById(i);
		if(q){			
			if(trimspace(q.selectedIndex) == '')
			{
				alert("Please Select the Quantity to Add to Cart");
				document.getElementById(i).focus();
				return;
			}else
				q = q.selectedIndex;
		}
		else
			q = 1;
		var hr = location.href;
		location.href = "cart_proccess1.php?id="+code+"&qty="+q+"&q="+escape(hr.substr(hr.lastIndexOf("/") + 1));
}

function checkLogin(frm){
	if((frm.ulogin.value == "") || (frm.upass.value == "")){
		alert("Please enter Login ID and Password!");	
		frm.ulogin.focus();
		return false;
		<!--|| (frm.upass.value == "")-->
		<!--alert("Please enter User name and Password!");-->
	}	
}
function fnc_search(id1)
{
	var id =  document.getElementById(id1).selectedIndex;
	//alert(id);
	if(id == '' || id == 0)
	{
		alert("Please select the Artisan Country ");
		document.getElementById(id1).focus();
		return false;
	}
	else
	{		
		window.location.href = "find_artisans.php?aid="+id;
	}
}
function fnc_search1(i)
{
	var searchValue =  document.getElementById(i).value;
	if(trimspace(searchValue) == '')
	{
		alert("Please enter some text to Search");
		document.getElementById(i).focus();
		return false;
	}
	else
	{		
		window.location.href = "shop-listing.php?s="+searchValue;
	}
}





