// Contains General Purpose Javascript routines.
function showSWF (url, width, height) {
	document.write('<embed src="' + url + '" width="' + width + '" height="' + height + '"></embed>');
}

function mmPopup(url, width, height){
	
	var	myWin = "" ;
	var x = screen.width ;
	var y = screen.height ;
		
	if (typeof(width) == 'undefined'){
		width = x;
	}
	
	if (typeof(height) == 'undefined'){
		height = y;
	}
		
	var	top = parseInt( ( y - height ) / 2 ) ;
	var	left = parseInt( ( x - width  ) / 2 ) ;
	var	props = "scrollbars=yes, menubar=no, toolbars=no, status=no, resizable=yes"
		props = props + ", width=" + width + ", height=" + height 			
		props = props + ", left=" + left + ", top=" + top;
			
	window.open(url, 'MyWin', props);		
}

function openNewsletter(url, height, width){
    if (height == '' || height == undefined){
        height = 800;
    }
    
    if (width == '' || width == undefined){
        width = 600;
    }

	if (url != '' && url != undefined){
		window.open (url,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height='+height+',width='+width+',left='+eval((screen.availWidth/2)-234)+',top=50');
	}
}

function loadPage(id){
	switch (id) {
	case 1: // News
		elem ('saccountname').focus();
		break;

	case 5: // My Account
		updateMarquee();
		break;

	case 13: // Micropayments
		toggleButtons();
		break;

	case 26: // Account Details
		new Accordian('basic-accordian',3,'header_highlight');
		toggleBankInfo();
		break;

	case 211: // Admin - Page
		showSiblings();
		break;
	
	case 325: // Account - Settings - Notifications	
		initNotificationPage()
		break;

	case 336: // Micropayment (edit/ add)
		initMicropaymentPage();
		break;
	}
}

function toggle_it(itemID){ 
  // Toggle visibility between none and inline 
  if ((document.getElementById(itemID).style.display == 'none')) 
  { 
    document.getElementById(itemID).style.display = 'inline'; 
  } else { 
    document.getElementById(itemID).style.display = 'none'; 
  } 
} 

function elem (id) {
	// Wrapper function for document.getElementById()
	// Returns the DOM element with the given id.
	return $(id);
}

function $ (id) {
	return document.getElementById(id);
}

function allowcharacters() {
	var argv = allowcharacters.arguments;
	var argc = argv.length;
	var e = argv[0];
	var key = window.event ? e.keyCode : e.which;

	if (argc == 1) {
		// No characters provided, allow only the default set (Latin alphabet, numbers, underscore and minus, backspace, delete, arrows)
		argv = '[blank],0,8,9,45,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122'.split(',');
//		argv = '[blank],45,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122'.split(',');
		argc = argv.length;
	}

	for (var i = 1; i < argc; i++) {
		if (key == argv[i]) {
			return true;
		}
	}

	if (window.event) {
		event.returnValue = false;
	}
	return false;
}

function setAction(action) {elem('action').value = action;}
