function CheckCCType(source, args) {
    var sFirstChar = "";
    args.IsValid = (args.Value.length > 0);
    if (args.IsValid)
    {
        sFirstChar = args.Value.substring(0, 1);
        args.IsValid = (sFirstChar == "5" || sFirstChar == "4" || sFirstChar == "6");
    }
}


function AgeValidation(source, args) {
    
    args.IsValid = ! isNaN(args.Value);
    
    if ( args.IsValid ) {
        var age = parseInt(args.Value,10);
        if ( age < 18 )
        {
            alert("You must be 18 or over to register on our site.");
            window.location.href="../default.aspx";
        }
    }
}



//Ajax
function reportError(t) {
    alert('Error ' + t.status + ' -- ' + t.statusText);
}


function ChangeColor(x, on) {
    
    //var x = document.getElementById(cntrl);
    if (on=="1") {
        x.className="but_hover";
    }
    else {
        x.className="but";
    }

}

function post(u) {
    var t = document.createElement("form");
    t.action = u;
    t.method = "POST";
    document.body.appendChild(t);
    t.submit();
    return t;
}


function PopClose(divId) {
    var pop = document.getElementById(divId);
    pop.style.visibility="hidden";
}

function PopOpen(divId, content, top, left) {
    var pop = document.getElementById(divId);
    pop.style.visibility="visible";
    pop.style.left = "425px";
    pop.style.top = "245px";

}

function popUpFAQ(faqId) {
    popUpFAQEx(faqId, "../");
}

function popUpFAQEx(faqId, path){
    //alert(path +  " ||||| " +  faqId);
	window.open(path + 'help/faq.aspx?faq=' + faqId, 'faq', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=380');

}

function popUpCVVEx(paymentType, path) {

    window.open(path + 'help/cvv.aspx?ptc=' + paymentType, 'cvv_help', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=380');
}

function popUpWindow(url, name, width, height){    
	var win = window.open(url, name, 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height);
	return win;
}

// Textarea countdown
// Element = textarea ( or textbox )
// maxLength = max. # of characters
// visCnt1 = the span or div where the counter is shown
function taLimit(element, maxLength, visCnt1) {
	var taObj=element;
	var visCnt= document.getElementById(visCnt1);
	if (taObj.value.length==maxLength) 
	{
	    visCnt.innerHTML="0";
	    return false;
	}
	else 
	{ 
	    if (taObj.value.length>maxLength) taObj.value=taObj.value.substring(0,maxLength);
	    visCnt.innerHTML=maxLength-taObj.value.length;
    }
	
}

// Replace Characters with these characters.
function replaceChars(entry, replaceChar, replaceWith) {
    temp = "" + entry; // temporary holder
    while (temp.indexOf(replaceChar)>-1) {
        pos= temp.indexOf(replaceChar);
        temp = "" + (temp.substring(0, pos) + replaceWith + 
        temp.substring((pos + replaceChar.length), temp.length));
    }
    return temp;
}

// Change the size of the Checkout Logo image to not be any bigger than 200X200
function reSizeImage(img) {
    
    var iCount = 100;
    for ( i = 0; i < iCount; i++) {
        x = "";
        
    }
    
    if (img.width > 200){
        img.width = 200;
    }
    if (img.height > 200){
        img.height = 200;
    }


}

function reSizeImageToSpecificSize(img, newWidth, newHeight) {

    if (img.width > newWidth) {
        img.width = newWidth;
    }
    if (img.height > newHeight) {
        img.height = newHeight;
    }


}
