function OnDescription( url )
{ 
	w = 700;
	h = 580;
	
	if (screen) {
		leftPos = screen.width/2-w/2
		topPos = screen.height/2-h/2
	}
	photoWin =  window.open( url, null, "width="+w+",height="+h+",top="+topPos+",left="+leftPos+",location=no,menubar=no,scrollbars=no,toolbar=no,resizable=yes", "true"); 
	photoWin.focus();
}

function OnPriceChange( code, isDiscount )
{ 
	window.open( "/Pub/PriceChange.aspx?itemcode=" + code + "&isDiscount=" + isDiscount, null, "width=780,height=400,location=no,menubar=no,scrollbars=no,toolbar=no", "true"); 
}

function OnGlossaryWord( gid )
{
	window.open( "/Print/Print.aspx?Page=GlossaryInner&gid=" + gid, null, "width=440,height=360,location=no,menubar=no,scrollbars=auto,toolbar=no,resizable=yes", "true"); 
}

function OnPrint()
{
	OnDescription("/Print/Print.aspx?Page=CatalogPrint");
}

function OnExport(oSelID)
{
	oSel = document.getElementById(oSelID);	
	OnDescription("/Print/Export2.aspx?ExportMode=" + oSel.options(oSel.selectedIndex).value);	
}

function OnCartExport(oSelID)
{
	oSel = document.getElementById(oSelID);	
	OnDescription("/Print/Export.aspx?ExportMode=" + oSel.options(oSel.selectedIndex).value);	
}


function OnRepairPrint()
{
	OnDescription("/Print/Print.aspx?Page=RepairPrint");
}

function OnGlossaryPrint( gid )
{
	OnDescription("/Print/Print.aspx?Page=GlossaryPrint&char=" + gid);
}

function OnCalcPrint()
{
	OnDescription("/Print/Print.aspx?Page=CalculatorPrint");
}

function OnCartCurrentPrint( orderID, lang, currency ) {
	OnDescription("/Print/Print.aspx?Page=CartCurrentPrint&PrintMode=1&OrderID=" + orderID + /*"&L=" + lang +*/ "&C=" + currency);
}

function OnCartPrint()
{
	OnDescription("/Print/Print.aspx?Page=CartPrint&PrintMode=1");
}

function OnCart3Print()
{
	OnDescription("/Print/Print.aspx?Page=Cart3Print&PrintMode=1");
}


function OnStep0()
{
	window.location.href = '/Pub/default.aspx?Page=Cart';
}

function OnStep1()
{
	window.location.href = '/Pub/default.aspx?Page=Cart1';
}

function OnStep2()
{
	window.location.href = '/Pub/default.aspx?Page=Cart2';
}

function OnBuy() {
	window.location.href = '/Pub/default.aspx?Page=Cart';
}

function OnNewPrint(ID)
{
	OnDescription("/Print/Print.aspx?Page=NewsPrint&ID=" + ID);
	
}	

function OnPlus( quantity ) {
	if (!isNaN(quantity.value)) quantity.value++;	
	else quantity.value = 1; 
	quantity.select()	
	evaluateObjectResult( quantity )
}

function OnMinus( quantity ) {
	if (!isNaN(quantity.value) && quantity.value>1) quantity.value--;
	else quantity.value='1'; 
	quantity.select();
	evaluateObjectResult( quantity )
	return false;
}

function OnItemPrint( id ) {
	OnDescription("/Print/Print.aspx?Page=ItemPrint&ID=" + id);
}

function AddToCart(id, discount){
       $.jmsajax({
                type: "POST",
                url: "default.aspx",
                method: "AddCartItem",
                data: {ID:id, Quantity:$("input#Q" + id).val(), Discount:discount},
                success: function(data) {
                    $("#cartContent").fadeOut("fast",function() {$(this).html(String(data))}).fadeIn("fast");
                    $("#PartNumberCell_" + id).addClass("simpleCellInCart");
                    $("#InputCell_" + id).addClass("simpleCellInCart");                  
                    $("#VendorCell_" + id).addClass("simpleCellInCart");
                    $("#ItemNameCell_" + id).addClass("simpleCellInCart");
                    $("#QuantityCell_" + id).addClass("simpleCellInCart");
                    $("#TotalPriceCell_" + id).addClass("simpleCellInCart");
                    $("#InputQuantityCell_" + id).addClass("simpleCellInCart");
                    $("#AddToCartCell_" + id).addClass("simpleCellInCart");
                }
       });
}

function RemoveItem(id){
        $.jmsajax({
            type: "POST",
            url: "default.aspx",
            method: "RemoveCartItem",
            data: {ID:id},
            success: function(data) {
                $("#cartContent").fadeIn("fast",function() {$(this).html(String(data))});
            }
        });
      }
      
      function RefreshCart(id){
        $.jmsajax({
            type: "POST",
            url: "default.aspx",
            method: "RefreshCart",
            data: {ID:1},
            success: function(data) {
                $("#cartContent").fadeIn("fast",function() {$(this).html(String(data))});
            }
        });
      }
