var dFilterStep

function dFilterStrip (dFilterTemp, dFilterMask)
{
    dFilterMask = replace(dFilterMask,'#','');
    for (dFilterStep = 0; dFilterStep < dFilterMask.length++; dFilterStep++)
		{
		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}
		return dFilterTemp;
}

function dFilterMax (dFilterMask)
{
 		dFilterTemp = dFilterMask;
    for (dFilterStep = 0; dFilterStep < (dFilterMask.length+1); dFilterStep++)
		{
		 		if (dFilterMask.charAt(dFilterStep)!='#')
				{
		        dFilterTemp = replace(dFilterTemp,dFilterMask.charAt(dFilterStep),'');
				}
		}
		return dFilterTemp.length;
}

function dFilter (key, textbox, dFilterMask)
{
//alert(key);
//alert(String.fromCharCode(key));
		dFilterNum = dFilterStrip(textbox.value, dFilterMask);
		
		if (key==9)
		{
			
		    return true;
		}
		//else if (key==8&&dFilterNum.length!=0)
		//{
		 	// 	dFilterNum = dFilterNum.substring(0,dFilterNum.length-1);
		//}
		
		//////////////////////
		else if ((key==46) ||(key==8))
		{
			return true;
		}
 	  else if ( ((key>47&&key<58)||(key>95&&key<106)) && dFilterNum.length<dFilterMax(dFilterMask) )
		{
			if(key>95&&key<106)
			{
				key=key-48;
			}
        dFilterNum=dFilterNum+String.fromCharCode(key);
		}

		var dFilterFinal='';
    for (dFilterStep = 0; dFilterStep < dFilterMask.length; dFilterStep++)
		{
        if (dFilterMask.charAt(dFilterStep)=='#')
				{
					  if (dFilterNum.length!=0)
					  {
				        dFilterFinal = dFilterFinal + dFilterNum.charAt(0);
					      dFilterNum = dFilterNum.substring(1,dFilterNum.length);
					  }
				    else
				    {
				        dFilterFinal = dFilterFinal + "";
				    }
				}
		 		else if (dFilterMask.charAt(dFilterStep)!='#')
				{
				    dFilterFinal = dFilterFinal + dFilterMask.charAt(dFilterStep); 			
				}
//		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}


		textbox.value = dFilterFinal;
    return false;
}

function replace(fullString,text,by) {
// Replaces text with by in string
    var strLength = fullString.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return fullString;

    var i = fullString.indexOf(text);
    if ((!i) && (text != fullString.substring(0,txtLength))) return fullString;
    if (i == -1) return fullString;

    var newstr = fullString.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(fullString.substring(i+txtLength,strLength),text,by);

    return newstr;
}





function opencart()
{
window.open("showcart.html",'newpage','scrollbars=yes,status=no,width=300,height=250');

}


function viewreply(idOrder)
	{
	window.open("viewreply2783.html?pagetext=success&amp;idOrder="+idOrder,'newpage','scrollbars=yes,status=no,width=780,height=600');

	 /* var msg,res;	
	 if( idStatus==0)
	 {
	  msg="Do you want to Change Shipping status to 'Shipped' ";
	  }
	  else
	  {
	  msg="Do you want to Change Shipping status to 'Not Shipped' ";
	  }
	res=confirm(msg);	
	if (res)
	{
		window.location.href="salesccsuccess.asp?change=yes&idStatus="+idStatus+"&idOrder="+ idOrder +"&curPage="+curpage+"&searchfrom="+searchfrom+"&searchto="+searchto;
	}*/
	  
	
}
function clearnewsname()
{
	if (document.newsfm.newsname.value =="Name")
	{
	
	document.newsfm.newsname.value ="";
	document.newsfm.newsname.focus();
	}
}

function clearnewsemail()
{
	if (document.newsfm.newsemail.value =="Email")
	{
	
	document.newsfm.newsemail.value ="";
	document.newsfm.newsemail.focus();
	}
}
function clearnewscompanyname()
{
	if (document.newsfm.newscompanyname.value =="Company Name")
	{
	
	document.newsfm.newscompanyname.value ="";
	document.newsfm.newscompanyname.focus();
	}
}


function clearbox()
{
	if (document.searchfrm.searchfield.value =="Type product name")
	{
	
	document.searchfrm.searchfield.value ="";
	document.searchfrm.searchfield.focus();
	}
}
function checknews()
{
    if ((document.newsfm.newsname.value =="") ||(document.newsfm.newsname.value =="Name"))
	{
	window.alert("Please enter your name");
	document.newsfm.newsname.focus();
	document.newsfm.newsname.select();
	return false;
	}
	if ((document.newsfm.newsemail.value =="") || (document.newsfm.newsemail.value =="Email"))
	{
	window.alert("Please enter your eMail");
	document.newsfm.newsemail.focus();
	document.newsfm.newsemail.select();
	return false;
	}
	return true;
}	  
function codehide()
{
if (document.searchfrm1.code_search.value =="Type product #")
	{
	
	document.searchfrm1.code_search.value ="";
	document.searchfrm1.code_search.focus();
	}
}

function windowprint(idprd)
{
window.open("viewproductdetails86c8.html?idProd="+idprd+"", 'newpage','scrollbars=yes,status=no,width=690,height=500');

}
function windowopen1(idprd,imgw,imgh)
{
var imgwidth,imgheight;
imgwidth=parseInt(imgw)+100;
imgheight=parseInt(imgh)+100;
if (parseInt(imgwidth) < 250 )
{
imgwidth=250;
}

window.open("viewproductimage86c8.html?idProd="+idprd+"", 'newpage1','scrollbars=no,status=no,width='+imgwidth+',height='+imgheight+'');

}

function windowopen2(idprd,imgw,imgh)
{
var imgwidth,imgheight;
imgwidth=parseInt(imgw)+100;
imgheight=parseInt(imgh)+100;
if (parseInt(imgwidth) < 250 )
{
imgwidth=250;
}

window.open("viewxyzimage86c8.html?idProd="+idprd+"", 'newpage1','scrollbars=no,status=no,width='+imgwidth+',height='+imgheight+'');

}

function ordercheck()
{
	val=confirm("To confirm click ok"); 
	if(val)		
	   return true;
	else
	  return false;
}