﻿function RestrictSize(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
       
    }
    
}
function RestrictSize5(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 5 Char allowed");
    }
    
}
function RestrictSize10(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 10 Char allowed");
    }
    
}

function RestrictSize2(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 2 Char allowed");
    }
    
}
function RestrictSize50(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 50 Char allowed");
    }
    
}
function RestrictSize200(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 200 Char allowed");
    }
    
}
function RestrictSize100(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 100 Char allowed");
    }
    
}

function RestrictSize1000(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 1000 Char allowed");
    }
    
}
function RestrictSize500(text,long) 
{
    var maxlength = new Number(long);
    if (text.value.length > maxlength)
    {
        text.value = text.value.substring(0, maxlength);
        alert("Only 1000 Char allowed");
    }
    
}
function MoveItem(ctrlSource, ctrlTarget) 
{
    var Source = document.getElementById(ctrlSource);
    var Target = document.getElementById(ctrlTarget);

    if ((Source != null) && (Target != null)) 
    {
        if(Source.length < 1) 
        {
            alert('There are no items in the source ListBox');
            return false;
        }
        if(Source.options.selectedIndex == -1) // when no Item is selected the index will be -1
        {
            alert('Please select an Item to move');
            return false;
        }
        while ( Source.options.selectedIndex >= 0 ) 
        {
            var newOption = new Option(); // Create a new instance of ListItem
            newOption.text = Source.options[Source.options.selectedIndex].text;
            newOption.value = Source.options[Source.options.selectedIndex].value;

            Target.options[Target.length] = newOption; //Append the item in Target
            Source.remove(Source.options.selectedIndex);  //Remove the item from Source
        }
    }
}

function AddToCart(productId)
{
    PageMethods.AddToCart(productId, onSucceeded,onFailed);
}

function CustomizeProduct(productId)
{
    PageMethods.CustomizeProduct(productId, onSucceeded, onFailed);
}


function onSucceeded(result, userContext, methodName)
{
    alert(result + "\n" + methodName);
}

function onFailed(error,userContext,methodName)
{
  alert("An error occurred");
}



