﻿// JScript File

    function MouseHover(e) {
        e.className = "FeaturesFeatureHover";
    }


function OpenWindow(url) 
{
    myRef = window.open(url,'mywin','width=400,height=500,toolbar=0,resizable=1,scrollbars=1');
}

function OrderAffiliate(productid, productname, price, btnOrder,pp) {

	
	switch (pp) 
	{
		// paypal
		case 1:
		document.order.action = "https://www.paypal.com/cgi-bin/webscr";
		break;
		// 2checkout
		case 2:	
		document.order.action = "https://www.2checkout.com/2co/buyer/purchase";
		break;	
	}
	
	productid = Translate2COProductId(productid);
	
	document.order.c_name.value = productname;
	document.order.item_name.value = productname;
	document.order.c_description.value = "";
    document.order.c_prod.value = productid;
    document.order.c_price.value = price;
    document.order.x_amount.value = price;
    document.order.merchant_product_id.value = productid;
    document.order.__VIEWSTATE.disabled="disabled";
    document.order.__EVENTVALIDATION.disabled="disabled";
        
    //<input type="hidden" name="x_amount" value="19"/>
    btnOrder.value = "Please wait..";
    btnOrder.disabled = true;
	document.order.submit();

}

function Order(productid, btnOrder,price1,price2,chk) 
{
    var price = 0;

    if (!chk[0].checked && !chk[1].checked)
    {
        alert("You have to select maintenance and support level before proceding.")
        return false;
    }
    
    if (chk[0].checked) 
    {
        // if first is checked then maintenance is included
        switch(productid) 
        {
            case 1:
                productid = 21;
                break;
            case 2:
                productid = 22;
                break;
            case 3:
                productid = 23;
                break;
            case 4:
                productid = 24;
                break;
           default:
                // do nothing
                break;
        }
        
        // set correct price
        price = price1;
    } else {
        price = price2;
    }
    
    if (chk[1].checked && productid == 32) 
    {
        //site maintenance
        productid = 34;
    }

    PlaceOrder(productid,price,btnOrder);
}

function PlaceOrder(productid,price,btnOrder) 
{
    document.aspnetForm.amount.value = price;
	switch (productid) {
		case 1: 
			document.aspnetForm.item_name.value = 'VisualCron - 1 Server License (Personal)';
			//document.aspnetForm.amount.value = document.aspnetForm.PricePersonal1Server.value;
			if (confirm("This license is only for private users - not for companies. Make sure that you buy the correct license or your license will be invalid for future updates and support. If you have any questions regarding the license the please contact Sales.\n\nAre you sure you want to continue buying a private license?\n\n"))
			{
				//
			}
			else
			{
				return;
			}
 
			break;
		case 21:
			document.aspnetForm.item_name.value = 'VisualCron - 1 Server License (Personal) + Maintenance';
			//document.aspnetForm.amount.value = document.aspnetForm.PricePersonal1Server.value;
			if (confirm("This license is only for private users - not for companies. Make sure that you buy the correct license or your license will be invalid for future updates and support. If you have any questions regarding the license the please contact Sales.\n\nAre you sure you want to continue buying a private license?\n\n"))
			{
				//
			}
			else
			{
				return;
			}
 
			break;
		case 2: 
			document.aspnetForm.item_name.value = 'VisualCron - 1 Server License (Business)';
			break;
		case 22:
			document.aspnetForm.item_name.value = 'VisualCron - 1 Server License (Business) + Maintenance';
			break;
		case 3:
			document.aspnetForm.item_name.value = 'VisualCron - 5 Server License (Business)';
			break;
		case 23:
			document.aspnetForm.item_name.value = 'VisualCron - 5 Server License (Business) + Maintenance';
			break;
		case 4: 
			document.aspnetForm.item_name.value = 'VisualCron - Site license (Business)';
			break;
		case 24:
			document.aspnetForm.item_name.value = 'VisualCron - Site license (Business) + Maintenance';
			break;
		case 32:
		    document.aspnetForm.item_name.value = '1-Server Maintenance pack (1 year)';
		    break;
		case 34:
		    document.aspnetForm.item_name.value = 'Site Maintenance pack (1 year)';
		    break;
		case 50:
		    document.aspnetForm.item_name.value = '50-Server licenses (business)';
		    break;
		case 99:
		    document.aspnetForm.item_name.value = 'Custom development';
		    break;
		default:	
			document.aspnetForm.item_name.value = 'VisualCron - 1 Server License (Business)';
			break;
	}
	
	document.aspnetForm.__VIEWSTATE.value = "";
	//document.aspnetForm.__EVENTVALIDATION.value = "";
	document.aspnetForm.__VIEWSTATE.disabled= true;
    //document.aspnetForm.__EVENTVALIDATION.disabled=true;
	btnOrder.disabled=true;
	btnOrder.value='Please wait..';
	
	switch (document.aspnetForm.paymentprocessor.value) 
	{
		// paypal
		case "1":
		// enable some input boxes for paypal
		document.aspnetForm.custom.disabled=false;
		document.aspnetForm.item_number.disabled=false;
		document.aspnetForm.item_name.disabled=false;
		document.aspnetForm.amount.disabled=false;
		document.aspnetForm.paymentprocessor.disabled=false;
		document.aspnetForm.lc.disabled=false;
		document.aspnetForm.no_shipping.disabled=false;
		document.aspnetForm.no_note.disabled=false;
		
		document.aspnetForm.item_number.value = productid;
		document.aspnetForm.action = "https://www.paypal.com/cgi-bin/webscr";
		break;
		// 2checkout
		case "2":	
		productid = Translate2COProductId(productid);
		
		// disable some input boxes for paypal
		document.aspnetForm.custom.disabled=true;
		document.aspnetForm.item_number.disabled=true;
		document.aspnetForm.item_name.disabled=true;
		document.aspnetForm.amount.disabled=true;
		document.aspnetForm.paymentprocessor.disabled=true;
		document.aspnetForm.lc.disabled=true;
		document.aspnetForm.no_shipping.disabled=true;
		document.aspnetForm.no_note.disabled=true;
		
	    document.aspnetForm.product_id.value = productid;
		document.aspnetForm.action = "https://www.2checkout.com/2co/buyer/purchase";
		break;	
	}
	document.aspnetForm.submit();
}

// 2CheckOut uses own id:s
function Translate2COProductId(productid) 
{
    switch(productid) 
    {
        case 22:
            productid =18;
            break;
        case 23:
            productid = 19;
            break;
        case 24:
            productid = 20;
            break;
        case 32:
            productid = 15;
            break;
         case 34:
            productid = 16;
            break; 
    }
    
    return productid;
}
 
function ShowInstructions() {
	window.open('/PaymentInstructions.aspx','bd','resizable=1,scrollbars=yes,width=400,height=400');
	return false;
}

function ShowTutorial(url,w,h) {
    window.open(url,'mywindow','width=' + w +',height=' + h);
}