function ShowInvoice(orderID)
{
	fullWindow("../Payment/popInvoice.aspx?orderID=" + orderID);
}

function startCourseDemo(url)
{
    var larg = screen.availWidth - 10;
    var alt = screen.availHeight - 30;
    xposition=0; yposition=0;

    args = "width=" + larg + "," 
    + "height=" + alt + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=0,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition + ","     //IE Only
    + "fullscreen=0";             //IE Only

    window.open(url, "CourseDemo", args);
}

function changeText (elemid, txt) {
  if (document.getElementById) {
    document.getElementById(elemid).childNodes[0].nodeValue = txt;
    return false;
  } else {
    return true;
  }
}

// Close window function
function closeWin () {
  cWindow = window.close();
  parent.GetRadWindowManager().CloseAll();
  
}

function closeWinNotRads() {
    cWindow = window.close();
}

// Popup window function
function openWindow(url, name, size, scroll) {
  popupWin=window.open(url, name, '"toolbar=no,' + size +',left=15,top=15,status=no,' + scroll +',resizable=1,menubar=no"');
}

function fullWindow(url) { 
    var str = "left=0,screenX=0,top=0,screenY=0,resizable,scrollbars=yes,status=yes";
    if (window.screen) {
      var ah = screen.availHeight - 30;
      var aw = screen.availWidth - 10
      str += ",height=" + ah;
      str += ",innerHeight=" + ah;
      str += ",width=" + aw;
      str += ",innerWidth=" + aw;
    }
    win=window.open(url, "w", str);
    win.focus;
}

// RadWindow fixed size function
// url = the url of the page to load in the radWindow
// width = the width of the radWindow
// height = the height of the radWindow
// radWindowID (controls the titlebar behavior) =
//		use "RadWindowDefault" for the ability to move, resize, refresh, and close the radWindow (close and refresh buttons)
//		use "RadWindowNone" for only the ability to move the radWindow (no buttons)
//		use "RadWindowClose" for the ability to move, refresh, and close the radWindow (close and refresh buttons)
// onClientClose = the javscript to execute when the client closes the radWindow
function OpenRadWinFixed(url, width, height, radWindowID, onClientClose)
{
	openRadWindowInternal (url, width, height, radWindowID, onClientClose);
}

function OpenRadWinFixedCenter(url, width, height, radWindowID, onClientClose)
{
	var oWindow = openRadWindowInternal (url, width, height, radWindowID, onClientClose);

	if (oWindow != null)
		oWindow.Center();
}

function openRadWindowInternal(url, width, height, radWindowID, onClientClose)
{
	var oWindow = null;

	if (radWindowID != null && radWindowID != undefined)
		oWindow = window.radopen (url, radWindowID);
	else
		oWindow = window.radopen (url, "RadWindowDefault");

	if (oWindow != null)
	{
		if (onClientClose != null && onClientClose != undefined)
			oWindow.OnClientClose = onClientClose;

		oWindow.SetSize (width, height);
	}
	
	return oWindow;
}

// Rad Window Full Function
/*
function OpenRadWinFull(url) {
  var oWindow = window.radopen(url,null);

  oWindow.Maximize();
}
*/

function GetInputControlBySubID(subID)
    {
        var inputs = document.getElementsByTagName("input");
        var i = 0;
            
        var control = null;
        
        for (i = 0; i < inputs.length; i++)
        {
            if (inputs[i].id.indexOf(subID) != -1)
            {
                control = inputs[i];
                break;
            }
        }
        
        return control;
    }
    
//Locates and returns a control within a particular node using the passed in html tag name 
//and html id of the control in the usercontrol
function GetControlByTagAndSubIDByParentNode(tag, controlID, parentNode)
{
    var controls = parentNode.getElementsByTagName(tag);
    var i = 0;
        
    var control = null;
    
    for (i = 0; i < controls.length; i++)
    {
        if (controls[i].id.indexOf(controlID) != -1)
        {
            control = controls[i];
            break;
        }
    }
    
    return control;
}
    
// www.javascript.com
// Credit Card Number Validator Sample Credit Card Validator Scipt
// Date : 04/08/2004
// Uses Linh mod-10 formula to determine the validity and then
// calls different functions to check what category the number belongs
// to.
//******************************************************************** !>

var invalid = "Invalid";
//********************************************************************
// Check the Linh Mod-10 validity

function CheckCreditCardNum(num)
{
var len=num.length;
var first;
var sum=0;
var mul=1;
var i;
var numAtI;
var tempSum;
var theway;
var txtcard;
theway = "";
for(i=(len-1); i >= 0 ;--i)
{
numAtI = parseInt(num.charAt(i));
tempSum = numAtI * mul;
theway += numAtI +" x " + mul +"=" + tempSum;
if(tempSum > 9)
{
first = tempSum % 10;
theway += " => "+ 1 +" + " + first +"=";
tempSum = 1 + first;
theway += tempSum +" ";
}
theway += "\n";
sum += tempSum;

if (mul == 1)
mul++;
else
mul--;
}
theway += "----------\nSum: "+ sum +"\n";


//*********************************************************
// Comment this line if you want to see the calculation


theway = "";
if(sum % 10)
{
if (len == 15)
{
txtcard = CheckFor15(num,0);
if ( txtcard == invalid )
{
if (num!="") {
  alert(theway +"The credit card number \""+ num +"\" is not valid!");
} else {
  // Need to enable this line if only using Javascript for validation
  //alert(theway +"You must enter a credit card number!");
}
return false;
}
}
else
{
if (num!="") {
  alert(theway +"The credit card number \""+ num +"\" is not valid!");
} else {
  // Need to enable this line if only using Javascript for validation
  //alert(theway +"You must enter a credit card number!");
}
return false;
}

}

{
switch(len)
{
case 13:
txtcard = CheckFor13(num);
break;
case 14:
txtcard = CheckFor14(num);
break;
case 15:
txtcard = CheckFor15(num,1);
break;
case 16:
txtcard = CheckFor16(num);
break;
default:
txtcard = invalid;
}
if(txtcard == invalid)
{
if (num!="") {
  alert(theway +"The credit card number \""+ num +"\" is not valid!");
} else {
  // Need to enable this line if only using Javascript for validation
  //alert(theway +"You must enter a credit card number!");
}
return false;
}
else
if (num!="") {
  theway+= "The credit card number \""+ num +"\" is valid but it looks like it is: "+ txtcard+"!";
} else {
  // Need to enable this line if only using Javascript for validation
  //alert(theway +"You must enter a credit card number!");
}
}
//alert(theway);
return true;
}

//***********************************************************************************
// Checks for Visa..
function CheckFor13(number)
{
if(parseInt(number.charAt(0)) == 4 )
return "Visa";
return invalid;
}

//************************************************************************************
// Check for Diners Club
function CheckFor14(number)
{
if( parseInt(number.charAt(0)) != 3 )
return invalid;
if( (parseInt(number.charAt(1)) == 6) || (parseInt(number.charAt(1)) == 8) )
return "Diners Club/Carte Blanche"
if( !(parseInt(number.charAt(1)) ))
if( (parseInt(number.charAt(2)) >= 0) && (parseInt(number.charAt(2)) <= 5))
return "Diners Club/Carte Blanche"
return invalid;
}

//************************************************************************************
// Check for American Express, enRoute, JCB
function CheckFor15(number, chec)
{
if ( (number.charAt(0) == 3) && ( (number.charAt(1) == 4)||(number.charAt(1) == 7) ) && chec)
return "American Express";
var FirstFour = parseInt(number.charAt(0))*1000;
FirstFour += parseInt(number.charAt(1))*100;
FirstFour += parseInt(number.charAt(2))*10;
FirstFour += parseInt(number.charAt(3));
//alert(FirstFour);
if( (FirstFour == 2014) || (FirstFour == 2149) )
return "enRoute";

if( ((FirstFour == 2131) || (FirstFour == 1800)) && chec )
return "JCB";

return invalid;
}

//************************************************************************************
// Check for Visa, MasterCard, Discover or JCB
function CheckFor16(number)
{
var a = parseInt(number.charAt(0));
var b = parseInt(number.charAt(1));
//alert (a);
switch (a)
{
case 5:
if((b > 0)&& (b < 6))
return "MasterCard";
else
return invalid;
break;
case 4:
return "Visa";
break;
case 6:
if ( (b == 0) && ( parseInt(number.charAt(2)) == 1) && ( parseInt(number.charAt(3)) == 1))
return "Discover";
else
return invalid;
break;
case 3:
return "JCB";
break;
default:
return invalid;
break;
}
}




