// JavaScript Document
<!--
window.onload=function(){
	Nifty("div.component","transparent");
	Nifty("div#navigation","transparent");
	Nifty("div#content", "transparent");
	Nifty("div.post");
	Nifty("div.boxfull","transparent");
	Nifty("div.box","transparent");
	Nifty("div#rightbar","transparent");
	Nifty("div.alert","transparent");
	Nifty("div.postwrapper");
	Nifty("div.profilequick","transparent");
	Nifty("div.profileabout","transparent");
	Nifty("div.profilephotos","transparent");
	Nifty("div.profilepic","transparent");
	Nifty("div.profilefriends","transparent");
	Nifty("div.profilecomment","transparent");
	Nifty("div#pmcon", "bottom tr transparent");
	Nifty("div.pmlinkon a", "top transparent");
	Nifty("div.pmlinkoff a", "top transparent");
	Nifty("div#scoachbottom", "tl");
	Nifty("div#cal_container", "transparent");
	Nifty("div#cal_today", "transparent");
	Nifty("div.alertfull");
}

function openNewWin(item) {
	window.open( item, "myWindow", 
"status = 1, height = 300, width = 300, resizable = 0" );
}

var oXmlHttp
var action
var goalN = 1
var add=false

function doStuff(str)
{
var url="ajaxaction.cfm?action=load&req=" + str
action = str
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}

function stateChanged()
{
if (oXmlHttp.readyState==4 || oXmlHttp.readyState=="complete")
{
	if (add==true){
	document.getElementById(action).innerHTML=document.getElementById(action).innerHTML+oXmlHttp.responseText
	}else{
	document.getElementById(action).innerHTML=oXmlHttp.responseText
	}
}
}

function GetHttpObject(handler)
{
try
{
var oRequester = new XMLHttpRequest();
	oRequester.onload=handler
	oRequester.onerror=handler
	return oRequester
}
catch (error)
{
try
{
var oRequester = new ActiveXObject("Microsoft.XMLHTTP");
oRequester.onreadystatechange=handler
return oRequester
}
catch (error)
{
return false;
}
}
}
function popIn(oid){
	document.getElementById(oid).innerHTML = ""
}
function popOut(str){
	var url="ajaxaction.cfm?action=display&req=" + str
action = "undernav"
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}
function edit(str){
	var url="ajaxaction.cfm?action=marksedit&id=" + str
action = str
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url, true)
oXmlHttp.send(null)
}
function saveNote(title, note)
{
var url="ajaxaction.cfm?action=save&req=note&title=" + title + "&note=" + note
action = "notes"
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}
function expandStuff(str)
{
var url="ajaxaction.cfm?action=loadnote&req=" + str
action = "n" + str
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}
function loadImage(str)
{
var url="ajaxaction.cfm?action=loadimage&req=" + str
action = "bigimage"
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}
function loadAddress()
{
var url="ajaxaction.cfm?action=loadaddress"
action = "address"
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}

function hide(url) {
	window.location = 'close.cfm?id=' + url
}
function editnews(url) {
	window.location = 'admin.cfm?area=news&f=editnews&a=' +url
}

function addNewSubject() {
	//alert("Create Element");
	//var opt = document.createElement("div");
	//alert("Element created, add HTML");
	//opt.innerHTML = "<input type='text' name='subject'><input type='hidden' name='customsubject' value='ok'>";
	//alert("HTML added, set value to 0");
	//opt.value = "0";
	//alert("Value set to 0, append child element to parent");
	//document.getElementByID("sub").appendChild(opt);
	//var ob = document.getElementById("this.sub");
	//ob.parentNode.innerHTML = ob.parentNode.innerHTML;
	//alert("Running getElementById()");
	//document.getElementById("sub").innerHTML = "" + "<input type='text' name='subject'><input type='hidden' name='customsubject' value='ok'>" + "";
	//alert("Passed getElementById()");
	//ob.parentNode.innerHTML = ob.parentNode.innerHTML;
	//alert("Passed setting parentNode.innerHTML to itself");
	document.getElementById("sub").style.display = "none";
	document.getElementById("newsub").style.display = "block";
}

function chooseSubject(){
	document.getElementById("newsub").style.display = "none";
	document.getElementById("sub").style.display = "block";
}

function addSubGoal2() {
	goalN++
	document.getElementById("subgoal").innerHTML = "" + "<p>Hello</p>" + ""
}
function addSubGoal()
{
goalN++
var add=true
var url="ajaxaction.cfm?action=addsubgoal&n=" + goalN
action = "subgoal"
oXmlHttp=GetHttpObject(stateChanged)
oXmlHttp.open("GET", url , true)
oXmlHttp.send(null)
}

//Forum Components
//Variables for controlling opening and closing tags (function tag)

var b = 2;
var i = 2;
var u = 2;
var q = 2;
var c = 2;
var url = 2;
var img = 2;

//Function for creating non-font tags

function tag(v, tagadd, newbut, tagclose, oldbut, name) {
    if (eval(v)%2 == 0) {
        eval("window.document.editform."+name+".value = newbut;");
        var post = window.document.editform.post.value;
        window.document.editform.post.value = post + tagadd;
        window.document.editform.post.focus();
    } else {
        eval("window.document.editform."+name+".value = oldbut;");
        var post = window.document.editform.post.value;
        window.document.editform.post.value = post + tagclose;
        window.document.editform.post.focus();
    }
    eval(v+"++;");
}
//Function for adding font color and size tags

function font(bbopen, bbclose) {
        var post = document.editform.post;
        post.value += bbopen + bbclose;
        post.focus();
        return;
}
//Function for adding smilies

function smilie (smilie) {
        var post = document.editform.post;
        post.value += smilie;
        post.focus();
        return;
}
//Helpbox messages
bold_help = "Bold text: [b]text[/b]";
italic_help = "Italic text: [i]text[/i]";
underline_help = "Underline text: [u]text[/u]";
quote_help = "Quote text: [quote]text[/quote] or [quote=name]text[/quote]";
code_help = "Code display: [code]code[/code]";
img_help = "Insert image: [img]http://image_url[/img]";
url_help = "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]";
fontcolor_help = "Font color: [color=red]text[/color]  Tip: you can also use color=#FF0000";
fontsize_help = "Font size: [size=50%]small text[/size]";

//Function for displaying help information

// Shows the help messages in the helpline window
function helpline(help) {
        var helpbox = document.editform.helpbox;
        helpbox.value = eval(help + "_help");
}
//Function to confirm reset

function confirm_reset () {
        if(confirm("If you continue you will loose everything you have entered so far. \n \n" +
                "Click OK to proceed and start again.  \n \n Alternatively click cancel to continue " +
                "working on your post.")) {
                        return true;
                                }
                else {
                        return false;
                                }
}
//Check the form submission for errors

function checkForm() {
        var subject = document.editform.subject;
        var post = document.editform.post;

        //Check to make sure post lengths are sensible

        if (subject.value.length < 2 && post.value.length < 2) {
                alert("This is a short post!" + " \n \n " +
                                "We require that each post (and subject) \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                return false;
        }
        else { if (subject.value.length < 2) {
                        alert("We require that the subject  \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                                return false;
                                }
                        else { if (post.value.length < 2) {
                        alert("We require that each post  \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                                return false;
                                }
                                else {
                                        return true;
                                }
                        }
        }
}
function addName(str) {
	document.sendpm.to.value += str;
	return;
}
function closeAB() {
	document.getElementById("address").innerHTML = ""
	return;
}
function accessDenied() {
	window.location="accessdenied.cfm";
}
function deletet(url) {
	var choice = confirm("Are you sure you want to delete this testimonial?");
	if (choice == true) {
		window.location = 'admin_action.cfm?a=deletetestimonial&id=' + url;
	}
}
function loadProduct(id) {
	var url="ajaxaction.cfm?action=loadproduct&id=" + id
	action = "changingbit"
	oXmlHttp=GetHttpObject(stateChanged)
	oXmlHttp.open("GET", url , true)
	oXmlHttp.send(null)
}
function deletethemall() {
	var choice = confirm("Are you sure you want to remove all deleted messages from the database?");
	if(choice == true){
		window.location = 'admin_action.cfm?a=purgemessages';
	}
}
function loginMessage(object) {
	if(object.checked == true)
		alert("By clicking this box you have enabled the auto login feature\nDo not enable this feature unless you are the only person to use this computer\n\nRakeshNet cannot be held responsible for the actions of others accessing your account on this computer");
}


function isDate(dateStr) {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Please enter your birth date as dd/mm/yyyy. Your current selection reads: " + dateStr);
return false;
}

day = matchArray[1]; // p@rse date into variables
month = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!");
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}

function checkForValidDate(){
var ddlVMonth = document.getElementById("_month");
var ddlVDay = document.getElementById("_day");
var ddlVYear = document.getElementById("_year");

if (!isDate(ddlVDay.value + '/' + ddlVMonth.value + '/' + ddlVYear.value))
{ return(false); }

return(true);
}

function showHelp(helpPage) {
 remote = window.open("","remotewin","width=350,height=500,scrollbars=yes");
 remote.location.href = "helpPage.cfm?pageID=" + helpPage;
} 

//-->
