var Site = {
	start: function() {
		Site.textSize.load({'id':'txtSize', 'cookieName':'textSize'});

	},
	textSize: {
		cName: null,
		opts: { duration: 60 },
		scale: ['100%','110%','120%', '130%'],
		myScale: null,
		els: null,
		curr: 0,
		load: function(obj) {
			if (!$(obj.id)) return
			
			this.cName = obj.cookieName
			//if doesnt exist, set to 0
			if (!$chk(Cookie.read(this.cName))) Cookie.write(this.cName, 0, this.opts)
			
			this.myScale = parseInt(Cookie.read(this.cName))
			
			this. els = $(obj.id).getElements('a')
						
			this.els.each(function(el, i) {
				el.set('href', 'javascript:void(0);')
				el.store('size', i)
				el.addEvent('click', function() {
					this.processScale(el)
				}.bind(this))
			}, this)
			
			$(document.body).setStyle('font-size', this.scale[this.myScale])			
		},
		setCookie: function() {
			Cookie.write(this.cName, this.myScale, this.opts)
		},
		processScale: function(el) {
			var size = el.retrieve('size')
			size = (size == 0) ? 'plus' : 'minus'
			switch (size) {
				case 'plus':
					this.myScale = (this.myScale + 1 > this.scale.length - 1) ? this.scale.length - 1 : this.myScale + 1				
					break;
				case 'minus':
					this.myScale = (this.myScale - 1 < 0) ? 0 : this.myScale - 1
					break;
			}
			
			this.setCookie()
			$(document.body).setStyle('font-size', this.scale[this.myScale])	
		}		
	}
		
}


window.addEvent('domready', function() {
	Site.start();	
})

function submitSearchForm() {
    var searchTerm = "ctl00_Top1_SearchText";
    if (validateSearchForm(searchTerm)) {
        window.location = window.root + 'Search_Results.aspx?q=' + document.getElementById(searchTerm).value;
    }
    return false;
}
function validateSearchForm(searchTerm) {
    var valid = true;
    if (document.getElementById(searchTerm).value == "Search" ||
    document.getElementById(searchTerm).value.length == 0) {
        window.alert("Please enter a search text.");
        valid = false;
    }
    else {
        var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
        for (var i = 0; i < document.getElementById(searchTerm).value.length; i++) {
            if (iChars.indexOf(document.getElementById(searchTerm).value.charAt(i)) != -1) {
                window.alert("Your search text has special characters. \nThese are not allowed.\nPlease remove them and try again.");
                valid = false;
                break;
            }
        }
    }
    return valid;
}

function setRightColumnDisplay()
	{
		var rightCol = document.getElementById('GreenWrapCol');		
		if(rightCol.childNodes.length < 1)
		{
			rightCol.style.display = 'none';
		}
		else if(rightCol.childNodes.length == 1)
		{
			if(rightCol.childNodes[0] == "Text" && rightCol.childNodes[0].value == 'undefined');
				rightCol.style.display = 'none';
		}
	}
	
function submitSearchFormHCP() {
    var searchTerm = "ctl00_Top1_SearchText";
    if (validateSearchForm(searchTerm)) {
        window.location = window.root + 'hcp/Search_Results.aspx?q=' + document.getElementById(searchTerm).value;
    }
    return false;
}

function confirmHCP()
{
	var bln = confirm('Please certify that you are a healthcare professional licensed and practicing in the United States.');
	if (bln)
	{
		window.location.href= window.root+'hcp/Default.aspx';
	}
}

function printGraph()
{
    var printWin = window.open(window.root+"images/hcpgraph_2.1_large.gif", "_blank");
    printWin.print();
}
    