function whereAreYou(arg) {
    if (arg == 1)
    {
        rad = document.forms["form2"].radRegion;
    }
    else
    {
        rad = document.forms[0].radRegion;
    }
    
    sel = document.getElementById("selSection");
    if (rad && sel) {
        s = sel.value;
        r = "";
        for (i=0;i<rad.length;i++) {
            if (rad[i].checked) {
                r = rad[i].value;
            }
        }

        url = "";

        if (r == "O" && s == "P")
            url = "/Work/InsideOntario/OntarioPhysicians.aspx";
        else if (r == "O" && s == "N")
            url = "/Work/InsideOntario/OntarioNurses.aspx";
        else if (r == "O" && s == "A")
            url = "/Work/InsideOntario/OntarioHealthProfessions.aspx";
        else if (r == "C" && s == "P")
            url = "/Work/OutsideOntario/PhysiciansOutsideOntario/PracticeRequirements/Canada.aspx";
        else if (r == "C" && s == "N")
            url = "/Work/OutsideOntario/NursesOutsideOntario/PracticeRequirements/Canada.aspx";
        else if (r == "C" && s == "A")
            url = "/Work/OutsideOntario/HealthProfessionalsOutsideOntario/PracticeRequirements.aspx";
        else if (r == "U" && s == "P")
            url = "/Work/OutsideOntario/PhysiciansOutsideOntario/PracticeRequirements/UnitedStates.aspx";
        else if (r == "U" && s == "N")
            url = "/Work/OutsideOntario/NursesOutsideOntario/PracticeRequirements/UnitedStates.aspx";
        else if (r == "U" && s == "A")
            url = "/Work/OutsideOntario/HealthProfessionalsOutsideOntario/PracticeRequirements.aspx";
        else if (r == "I" && s == "P")
            url = "/Work/OutsideOntario/PhysiciansOutsideOntario/PracticeRequirements/International.aspx";
        else if (r == "I" && s == "N")
            url = "/Work/OutsideOntario/NursesOutsideOntario/PracticeRequirements/International.aspx";
        else if (r == "I" && s == "A")
            url = "/Work/OutsideOntario/HealthProfessionalsOutsideOntario/PracticeRequirements.aspx";

        if (url != "") {
            window.location.href =  url; 
            return;
        }

    }

    alert("Please select a region and try again.");

}


function createXMLHttpRequest() {
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    }
    try {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
    }
    try {
        return new XMLHttpRequest();
    } catch(e) {
    }
    alert("XMLHttpRequest not supported");
    return null;
}

function isEmailAddress(email) {
    if (email.indexOf("@") < 0)
        return false;
    else
        return true;
}

function getBrowserWidth(){
    //if (window.innerWidth) {
    //    return window.innerWidth;
    //}  
    //else
    if (document.documentElement && document.documentElement.clientWidth != 0) {
        return document.documentElement.clientWidth;
    }
    else if (document.body) {
        return document.body.clientWidth;
    }      
    return 0;
}

function getLeftPosition() {
    var cw = getBrowserWidth();
    var lp = (cw / 2) + 94;
    return lp;
}

function getTagLineLeftPosition() {
    var cw = getBrowserWidth();
    var lp = (cw / 2) - 358;
    return lp;
}

function addLoadEvent(func) {
	// Add to OnLoad (but don't kill what's already in OnLoad)
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		var holdonload = window.onload;
		window.onload = function() { holdonload(); func(); }
	}
}

function addResizeEvent(func) {
	if (typeof window.onresize != 'function') {
		window.onresize = func;
	} else {
		var holdonresize = window.onresize;
		window.onresize = function() { holdonresize(); func(); }
	}
}

function noEnter(e)
{
    if(!e)
        e = window.event;
    if (e.keyCode == 13) {
        submitSearch(window.location.href);
        return false;
    }
    return true;
} 

function noEnterHome(e)
{
    if(!e)
        e = window.event;
    if (e.keyCode == 13) {
        submitSearchHome(window.location.href);
        return false;
    }
    return true;
} 

function $(id)
{
    return document.getElementById(id);
}

function $del(id)
{
    if ($(id))
        $(id).parentNode.removeChild($(id));
} 

function submitSearch(loc)
{
    $del("__VIEWSTATE");
    $del("p");

    var f = document.forms[0];
    f.method = "get";
    f.action = "/SearchResults.aspx";

    f.submit();
}

function submitSearchHome(loc)
{
    $del("__VIEWSTATE");
    $del("selSection");

    var f = document.forms[0];
    f.method = "get";
    f.action = "/SearchResults.aspx";

    f.submit();
}

var qsParm = new Array();
function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0,pos);
            var val = parms[i].substring(pos+1);
            qsParm[key] = val;
        }
    }
}

function multilineValidateLength(oSrc, args){
 args.IsValid = (args.Value.Length <= 1000);
}

var toolkitHandle;
function popUpToolkit(URL) {
if(toolkitHandle != null && !toolkitHandle.closed) toolkitHandle.close();
var posX, posY; //position of popup
var w=750, h=540; //size of popup
var offsetX=50, offsetY=50; //x and y offset relative to the parent window
if (typeof window.screenLeft != "undefined"){ //IE
 posX = window.screenLeft + offsetX;
 posY = window.screenTop + offsetY - 30; 
}
else if (typeof window.screenX != "undefined"){ //NS/Moz
 posX = window.screenX + offsetX;
 posY = window.screenY + offsetY + 100;
}
else { //default - center of screen
 posX = screen.availWidth/2 - w/2;
 posY = screen.availHeight/2 - h/2;
}

toolkitHandle = window.open(URL, "RPNToolkit", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h + ',left=' + posX + ',top=' + posY);
toolkitHandle.focus();
}

function findPosX(obj)
{
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
	
	curleft -= 5;
			
  return curleft;
}

var _isOpen = new Array(0,0,0,0,0,0,0,0,0,0);

function keepPopupOpen(arg) {
    _isOpen[arg] = 1;
	//var lp = getLeftPositionMenu(arg);
	
	var obj = document.getElementById("ctl01_ctl01_smp" + arg);
	var lp = findPosX(obj);
		
	var mn1 = document.getElementById("smt" + arg);
    mn1.style.left = lp + "px";
	mn1.style.display = "block";
    var mn2 = document.getElementById("smb" + arg);
	mn2.style.left = lp + "px";
    mn2.style.display = "block";
}

function delayClosePopup(arg) {
    if (_isOpen[arg] == 1) {
        _isOpen[arg] = 0;
        setTimeout("timerHandler" + arg + "()", 50);
	}
}

function closePopup(arg) {
    if (_isOpen[arg] == 0) {
	    var mn1 = document.getElementById("smt" + arg);
        mn1.style.display = "none";
        var mn2 = document.getElementById("smb" + arg);
        mn2.style.display = "none";
	}					
}	

function timerHandler0() {
	closePopup(0);
}

function timerHandler1() {
	closePopup(1);
}

function timerHandler2() {
	closePopup(2);
}

function timerHandler3() {
	closePopup(3);
}

function timerHandler4() {
	closePopup(4);
}

function timerHandler5() {
	closePopup(5);
}

function timerHandler6() {
	closePopup(6);
}

function timerHandler7() {
	closePopup(7);
}

function timerHandler8() {
	closePopup(8);
}

function timerHandler9() {
	closePopup(9);
}
