function pviiClassNew(obj, new_style) 
{
	obj.className = new_style;
}
	
function removeFormat(str)
{
	var i, j;
	var newStr = "";
	var found;

	for (i=0; i<str.length; i++)
	{
		found = false;
		for (j=1; j<arguments.length; j++)
			if (str.substring(i, i+1) == arguments[j])
				found = true;
		if (!found)
				newStr = newStr + str.substring(i, i+1);
	}
	return newStr;
}
function keypress_number(isdecimal) {

	try
	{
		var kc = window.event.keyCode;
		var t = window.event.srcElement.value ;
		
			if (isdecimal) 
			{
				
				var idxOfComma = t.indexOf(',');
				
				if (idxOfComma != -1) {
					if( (kc >= 48 && kc <= 57) == false) 
					{
						window.event.keyCode = 0;
					}
					else 
					{
						var rNmb = t.substring(idxOfComma+1);
						if (rNmb.length == 2)
						window.event.keyCode = 0;
					}
				}
				else 
				{
					if ((kc >= 48 && kc <= 57 || kc == 44) == false) 
					{
						window.event.keyCode = 0;
					}
		            
					var ft = removeFormat(t, ".");
					if (ft.length >= 14 && (kc >= 48 && kc <= 57)) {
						window.event.keyCode = 0;
					}
				}
			}
			else 
			{
				if ((kc >= 48 && kc <= 57) == false) 
				{
					window.event.keyCode = 0;
				}
				
				
			}
	}
    catch(e){}
        
	
}
function Popup(url,width,height,resizable,scrollbars)
{
	var top		= (screen.height/2) - (height/2);
	var left	= (screen.width/2) -  (width/2);
	var dialogWindow=window.open(url,null,'location=no, resizable='+resizable+',scrollbars='+scrollbars+', width=' + width + ', height=' + height + ', top=' + top + ', left=' + left)
	dialogWindow.focus();
}
function PopupWithName(url,width,height,resizable,scrollbars,name)
{
    var ranNum= Math.floor(Math.random()*1000000);

	var top		= (screen.height/2) - (height/2);
	var left	= (screen.width/2) -  (width/2);
	var dialogWindow=window.open(url,name+ranNum,'location=no, resizable='+resizable+',scrollbars='+scrollbars+', width=' + width + ', height=' + height + ', top=' + top + ', left=' + left)
	dialogWindow.focus();
}
function OpenPartPage(PartID)
{
    Popup("/ProductPart.aspx?ProductPartID="+PartID,720,520,0,1);
}
function ViewImage(URL)
{
    Popup("/ViewImage.aspx?IPath="+URL,405,490,0,0);
}
function ViewTechniqueImage(URL)
{
    Popup("/ViewImage.aspx?IPath="+URL + "&Type=1",605,690,0,0);
}
function OpenProductGalery(ProductID)
{
    Popup("/ViewGalery.aspx?ProductID="+ProductID,405,560,0,0);
}
function resize(X,Y)
{
    window.resizeTo(X,Y);
}
function OpenRequestInfo(ProductID)
{
    Popup("/RequestProductInfo.aspx?ProductID="+ProductID,510,560,0,0);
}
function SetBackgroundImage()
{    
    var width='1024';
    
    var screenWidth=window.screen.width;
    var screenHeight=window.screen.height;
   
    if(screenWidth<=1280 && screenWidth>1024)
    {
        width='1280';
    }
    else if(screenWidth<=1400 && screenWidth>1280)
    {
        width='1400';
    }
    else if(screenWidth<=1440 && screenWidth>1400)
    {
        width='1440';
    }
    else if(screenWidth<=1600 && screenWidth>1440)
    {
        width='1600';
    }
    else if(screenWidth>1600)
    {
        width='1600';
    }
    else 
        width='1024';
    
    var ObjectIndex = Math.floor(Math.random()*arrBackground.length); 
    var ImageName   = arrBackground[ObjectIndex].toString();
    document.getElementById('tdbg').style.backgroundImage = "url('"+ImageName.replace('####',width)+"')";
    document.getElementById('tdbg').style.backgroundRepeat= "no-repeat"; 
    //document.getElementById('tdbg').style.backgroundPosition = "center-top;";
    var i = 0;
    for( i = 0;i<arrBackground.length;i++)
    {
        preloadBgImages(arrBackground[i].replace('####',width));
    }
}
function PopupCatalog(url)
{
    var width = '200';
    var height = '200';
    var screenWidth=window.screen.width;
    var screenHeight=window.screen.height;
    /*if(screenWidth<1024)
    {
        width='800';
        height = '600';
    }
    else if(screenWidth<1280 && screenWidth>1023)
    {
        width='1024';
        height = '768';
    }
    else if(screenWidth>1279)
    {
        width='1280';
        height = '800';
    }*/
    
	var top		= 0;
	var left	= 0;
	var dialogWindow=window.open(url,null,'location=no, resizable=no,scrollbars=yes, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
	dialogWindow.focus();
}
function MoveMenuTable(tblObj,lblBottomLimitObj)
{
    if(tblObj == null) return;
    var ScrollTop = document.body.scrollTop;
    var ScreenHeight=window.screen.height;
    var YLimit = lblBottomLimitObj.offsetTop;
    var MenuHeight = tblObj.offsetHeight;
    if (ScrollTop == 0)
    {
        if (window.pageYOffset)
            ScrollTop = window.pageYOffset;
        else
            ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
    if(ScrollTop < 130)  
    {
        tblObj.style.top='130px'; return;
    }
    else if(ScrollTop < YLimit-MenuHeight+100)
        tblObj.style.top=ScrollTop || 'px';
    else
        tblObj.style.top=YLimit-MenuHeight+100;
        
}