if ('0' == 0)
	var issetsched = 0;
	
else {
	// intialize schedule onload
	var issetsched = 1;
	var Sched = ['','','','','','','',''];
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
 
    return vars;
}
var GET = getUrlVars()

if (GET['wc'])
	var webclip = GET['wc'].charAt(0)
else
	var webclip = 1;

function webClip(foo) {// automate script so that it does not need to be constantly changed
	if(!(foo.name == "on")) {
		var goo = document.getElementById('custwebclip');
		var x=1 ;
			while(x < document.getElementById('custwebclip').childNodes.length) { // all odd values are the important images
				goo.childNodes[x].setAttribute("style", "opacity: 0.65;");
				goo.childNodes[x].setAttribute("name", "off");
				x++;
				x++;
			}
			
		foo.setAttribute("style", "opacity: 1;");
		foo.setAttribute("name", "on");
		path = "iui/webclip_icons/";
		
		if (foo.id == 'wc1')
		path = path + '1.png';
		
		if (foo.id == 'wc2')
		path = path + '2.png';
		
		if (foo.id == 'wc3')
		path = path + '3.png';
		
		if (foo.id == 'wc4')
		path = path + '4.php';
		
		document.getElementById('webclippath').href = path;
		webclip = foo.id.charAt(2);
	}
}
var deviceIphone = "iphone";
var deviceIpod = "ipod";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

// Detects if the current device is an iPhone or iPod Touch.
function DetectIphoneOrIpod()
{
    if (uagent.search(deviceIpod) > -1)
       return true;
    else if (uagent.search(deviceIphone) > -1)
       return true;
    else
       return false;
}


function togglestandalone() {

	if($('standaloneapp').getAttribute('content') == "yes") {
		$('standaloneapp').setAttribute('content', 'no');
		var fullscreen = 0;
	}
		
	else if($('standaloneapp').getAttribute('content') == "no") {
		$('standaloneapp').setAttribute('content', 'yes');
		var fullscreen = 1;
	}
		
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+1460);
	document.cookie = "fullscreen="+fullscreen+"; expires="+exdate.toGMTString();
	
}

function submitwebclipsettings() {
	if (GET['wc'] && webclip == GET['wc'].charAt(0))
		alert("Instructions:\nThe settings have already been saved, simply touch add to home screen from the menu to proceed");
	else {
		var x = window.confirm("Instructions:\nThe page is in the process of refreshing. Once it has done so, you may choose add to home screen from the menu.")
		if(x)
			window.location.href='?wc='+webclip;
	}
}

function alterappearance(foo) {
	var x =1;
	
	var ops = $('appearoptions')
	while (x <= ops.childNodes.length-1) { // turn selected row off
		if (ops.childNodes[x].className == "rowselected") {
			ops.childNodes[x].className = "row"
			ops.childNodes[x].childNodes[1].setAttribute('src','iui/preview.png')
			ops.childNodes[x].setAttribute('style', 'background: none;')
			ops.childNodes[x].childNodes[0].setAttribute('onclick','alterappearance(this)')		
		}
		x=x+1
	}
	
	// take input and convert to selected row
	foo.parentNode.setAttribute('style','background: #FFFFFF url(iui/'+foo.parentNode.getAttribute('theme')+'selection2.png)!important;')
	foo.parentNode.className = "rowselected"
	foo.parentNode.childNodes[1].setAttribute('src','iui/previewwhite.png')
	foo.removeAttribute('onclick')
	
	if (foo.parentNode.getAttribute('theme') != "") { 
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+1460);
		document.cookie = "theme="+foo.parentNode.getAttribute('theme')+"; expires="+exdate.toGMTString();
	}
	
	else {// default theme, no cookie
		var exdate=new Date();
		exdate.setDate(exdate.getDate()-1);
		document.cookie = 'theme=; expires'+exdate.toGMTString();
	}

	
	
}