function ShowPage(e)
{
	var s = e.options[e.selectedIndex].value;
	if(s.length > 0 && s != "0")
	{
		document.location.href = s;
	}
}

function CheckPassword(id)
{
	var val = GetMyObjectByID(id).value;
	
	if (val.length < 6 || val.length == 0 ) return false;		
	
    var numbers = '0123456789';
	for (i=0, n=val.length; i<n; i++)
	{
		if (numbers.indexOf(val.charAt(i),0) > -1) return true;
    }            
	return false;
}

function ValidateForm()
{
	return true;
}
/*

Accesible Pop Up Code

This file contains only functions necessary for the article features
The full library code and enhanced versions of the functions present
here can be found at http://v2studio.com/k/code/lib/

MISC CLEANING-AFTER-MICROSOFT STUFF

isUndefined(v)
    returns true if [v] is not defined, false otherwise

    IE 5.0 does not support the undefined keyword, so we cannot do a direct
    comparison such as v===undefined.
*/

// MISC CLEANING-AFTER-MICROSOFT STUFF

function isUndefined(v) {
    var undef;
    return v===undef;
}

function SetSearchIndicator(type)
{
	var indicator = document.getElementById("hdnSearchFlag");
	if(indicator != null)
		indicator.value = type;
}

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = '';
var _HELP_FEATURES = 'width=510, height=530,scrollbars=1, resize=1';
var _COMMENT_FEATURES = 'width=450, height=480,scrollbars=yes,resize=yes';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

var defaultButton=null;




/****************** EMAIL DECRYPTION *********************/
function decrypt_string(crypted_string) {

	var numbers = crypted_string.split(' ');			
	n = numbers[0];	decryption_key = numbers[1];			
	numbers[0] = ""; numbers[1] = "";				
	crypted_string = numbers.join(" ").substr(2);


	var decrypted_string = '';
	var crypted_characters = crypted_string.split(' ');
	var i;
	
	for(i = 0; i< crypted_characters.length; i++) {
		var current_character = crypted_characters[i];
		var decrypted_character = exponentialModulo(current_character,n,decryption_key);
		decrypted_string += String.fromCharCode(decrypted_character);
	}
	
	return decrypted_string;
}


// Finds base^exponent % y for large values of (base^exponent)
function exponentialModulo(base,exponent,y) {
	if (y % 2 == 0) {
		answer = 1;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	} else {
		answer = base;
		for(var i = 1; i <= y/2; i++) {
			temp = (base*base) % exponent;
			answer = (temp*answer) % exponent;
		}
	}
	return answer;
}

function sendEmail(dat)
{
    document.location.href='mailto:' + do_decrypt ( dat );
}


function do_decrypt(dat)
{ 
	return decrypt_string ( dat, 0, 0 ,'');
}



function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode == 13 || charCode == 46 || (charCode >= 96 && charCode <= 105) || (charCode >= 37 && charCode <= 40)) {
        return true;
    } else
        if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}
