/* http://www.ocvarsity.com/common/tools/load.php?js=common_poll,common_nav,common_tabBox,common_contentslider,common_freedom,common_ads,common_page */
	function loadPoll(pollid,sitecode)
	{
			var pollwrapper = document.getElementById('pollwrapper');
			var scriptname = "/onsetfeature/pollcap.php?station=" + sitecode;
			getPollResult(pollid,sitecode,pollwrapper,scriptname);
	}
	
	function loadArticlePoll(pollid,sitecode)
	{
		var pollwrapper = document.getElementById('articlepoll_wrapper');
		var scriptname = "/onsetfeature/pollcap.php?pollid=" + pollid;
		getPollResult(pollid,sitecode,pollwrapper,scriptname);
	}
	
	function getPollResult(pollid,sitecode,pollwrapper,scriptname) {
		
		try
		{
			var cookie_value = GetCookie('poll');
		}
		catch(e)
		{}
		if(pollid && cookie_value)
		{
			if(pollwrapper != null) 
				{
					var voted_list_array = cookie_value.split('~');
					var thisPollID = pollid;
					var xmlHttp; 
					for(x=0;x<voted_list_array.length;x++)
					{
						if(voted_list_array[x] == thisPollID)
						{
							scriptname += "&action=results";
							break;
						}
					}
					try {
						xmlHttp = new XMLHttpRequest();
					}
					catch(e) {
						try {
							xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
						}
						catch (e) {
							try {
								xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
							}
							catch (e) {
								alert("not supported");
							} 
						}
					}
					xmlHttp.onreadystatechange=function() {
						if(xmlHttp.readyState == 4) {
							//alert(xmlHttp.responseText);
							pollwrapper.innerHTML = xmlHttp.responseText;
						}
					}
					xmlHttp.open("GET",scriptname, true);
					xmlHttp.send(null);
				}
		}
	}
	function navLoad( id )
{
	if( typeof(id) == 'undefined' )
		id = 'fi_nav_ul';
		
	var nav = document.getElementById(id);
	
	var children = nav.getElementsByTagName("LI");
	for( var i = 0; i < children.length; i++ )
	{
		for( var j = 0; j < children[i].childNodes.length; j++ )
		{
			if( children[i].childNodes[j].nodeName == "UL" && children[i].childNodes[j].className.indexOf('sub') > -1 )
			{
				children[i].setAttribute('ulPos', j);
				
				if( children[i].parentNode == nav )
					children[i].childNodes[j].setAttribute('drop', 'down');
				else
					children[i].className += " hasSub";
				break;
			}
		}
		
		children[i].onmouseover = function() {
			
			if( this.className.indexOf(" over" ) == -1 )
				this.className += " over";
			
			if( this.getAttribute('ulPos') )
				showAndPosition(this);
		}
		
		children[i].onmouseout = function() {
			this.className = this.className == "over" ? "" :  this.className.replace(" over", "");
				
			if( this.getAttribute('ulPos') )
				this.childNodes[this.getAttribute('ulPos')].style.visibility = 'hidden';
		}
	}
}

function showAndPosition( li )
{
	var subMenu = li.childNodes[li.getAttribute('ulPos')];
	
	if( subMenu.getAttribute('noPos') )
	{
		subMenu.style.visibility = 'visible';
	}
	else
	{
		if( subMenu.getAttribute('drop') == "down" )
		{
			subMenu.style.left = '0px';
			subMenu.style.top = li.offsetHeight + 'px';
			if(subMenu.offsetWidth < li.offsetWidth )
				subMenu.style.width = li.offsetWidth + 'px';
		}
		else
		{
			subMenu.style.left = 'auto';
			subMenu.style.right = (-subMenu.offsetWidth) + 'px';
			subMenu.style.top = '3px';
		}
		
		subMenu.setAttribute('noPos', true);
	}
}function showTab( tab, tabContentID )
{
	// figure out the id of the tab box being worked with
	// and the number of the tab that was clicked on
	var tboxID = getTabBoxID(tab);
	var tabNum = getTabNum(tab);
	
	// get the tab box and read the values on it
	var tabBox = getEl(tboxID);
	var lastTabNum = tabBox.getAttribute('lastTab');
	var baseName = tabBox.getAttribute('baseName');
	var tabSelected = baseName + "Selected";
	
	// get the last tab and it's content container
	var lastTab = getEl(tboxID+"_"+lastTabNum+"_tab");
	var lastTabContent = getEl(tboxID+"_"+lastTabNum+"_content");
	
	// get the current tab and it's content container.
	var currTab = getEl(tboxID+"_"+tabNum+"_tab");
	var currTabContent = getEl(tboxID+"_"+tabNum+"_content");
	
	// unselect the last tab and hide it's content container
	lastTab.className = lastTab.className.replace(tabSelected, "");
	lastTabContent.style.display = 'none';
	
	// select the current tab and show it's content container
	currTab.className = currTab.className + " " + tabSelected;
	currTabContent.style.display = '';
	
	// set the last tab to the current tab
	tabBox.setAttribute('lastTab', tabNum);
}

function getTabBoxID(tab)
{
	var tabID = tab.id;
	var first = tabID.indexOf("_");
	var second = tabID.indexOf("_", (first+1));
	return tabID.substr(0, first);
}

function getTabNum(tab)
{
	var tabID = tab.id;
	var first = tabID.indexOf("_");
	var second = tabID.indexOf("_", (first+1));
	return tabID.substr((first+1), (second-first-1));
}

function highlightTab(tab, highlight)
{
	var tboxID = getTabBoxID(tab);
	var tabBox = getEl(tboxID);
	var baseName = tabBox.getAttribute('baseName');
	var style = baseName+"Highlighted";
	
	if (highlight == true)
		tab.className += " "+style;
	else
		tab.className = tab.className.replace(style, "");
}

function getEl( id )
{
	return document.getElementById(id);
}//** Featured Content Slider script- (c) Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: Feb 28th- 07- Added ability to customize pagination links' text
//** Updated 20090429 - Only display nav if slideCount (alldivs) > 1

////Ajax related settings
var csbustcachevar=0 //bust potential caching of external pages after initial Ajax request? (1=yes, 0=no)
var csloadstatustext="<img src='http://common.onset.freedom.com/images/loading.gif' /> Requesting content..." //HTML to indicate Ajax page is being fetched
var csexternalfiles=[] //External .css or .js files to load to style the external content(s), if any. Separate multiple files with comma ie: ["cat.css", dog.js"]

////NO NEED TO EDIT BELOW////////////////////////
var enablepersist=false
var slidernodes=new Object() //Object array to store references to each content slider's DIV containers (<div class="contentdiv">)
var csloadedobjects="" //Variable to store file names of .js/.css files already loaded (if Ajax is used)

function ContentSlider(sliderid, autorun, customPaginateText, customNextText, cycles){
	var prevText
	var slider=document.getElementById(sliderid)
	if (typeof customPaginateText!="undefined" && customPaginateText!="") //Custom array of pagination links text defined?
		slider.paginateText=customPaginateText
	if (typeof customNextText!="undefined" && customNextText!="") //Custom HTML for "Next" link defined?
		slider.nextText=customNextText
	slidernodes[sliderid]=[] //Array to store references to this content slider's DIV containers (<div class="contentdiv">)
	ContentSlider.loadobjects(csexternalfiles) //Load external .js and .css files, if any
	var alldivs=slider.getElementsByTagName("div")
	for (var i=0; i<alldivs.length; i++){
		if (alldivs[i].className=="contentdiv"){
			slidernodes[sliderid].push(alldivs[i]) //add this DIV reference to array
			if (typeof alldivs[i].getAttribute("rel")=="string") //If get this DIV's content via Ajax (rel attr contains path to external page)
				ContentSlider.ajaxpage(alldivs[i].getAttribute("rel"), alldivs[i])
		}
	}
	ContentSlider.buildpagination(sliderid)
	var loadfirstcontent=true
	if (enablepersist && getCookie(sliderid)!=""){ //if enablepersist is true and cookie contains corresponding value for slider
		var cookieval=getCookie(sliderid).split(":") //process cookie value ([sliderid, int_pagenumber (div content to jump to)]
		if (document.getElementById(cookieval[0])!=null && typeof slidernodes[sliderid][cookieval[1]]!="undefined"){ //check cookie value for validity
			ContentSlider.turnpage(cookieval[0], parseInt(cookieval[1])) //restore content slider's last shown DIV
			loadfirstcontent=false
		}
	}
	if (loadfirstcontent==true) //if enablepersist is false, or cookie value doesn't contain valid value for some reason (ie: user modified the structure of the HTML)
		ContentSlider.turnpage(sliderid, 0) //Display first DIV within slider
	if (typeof autorun=="number" && autorun>0 && alldivs.length>1) //if autorun parameter (int_miliseconds) is defined, fire auto run sequence
		window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorun, cycles || 0)}, autorun)
	if (alldivs.length<2) {
		document.getElementById('paginate-slider1').innerHTML='&#160;';
	}
}

ContentSlider.buildpagination=function(sliderid){

	var slider=document.getElementById(sliderid)
	var paginatediv=document.getElementById("paginate-"+sliderid) //reference corresponding pagination DIV for slider
	var pcontent=""
	
	if(typeof (imgInfo)!="undefined")
		{
		pcontent+='<a href="#" style="font-weight: bold;" onclick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.prevText || "<img src=\"http://common.onset.freedom.com/images/arrow_prev.gif\">")+'</a>'
		pcontent+= '<span id="cur_page" style="margin:0px 8px;">' + 1 + ' of '+ imgInfo.length +' </span>'
		//for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link
		//	pcontent+='<a href="#" onclick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a> '
		pcontent+='<a href="#" style="font-weight: bold;" onclick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.nextText || "<img src=\"http://common.onset.freedom.com/images/arrow_next.gif\">")+'</a>'
	} else {
		for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link
			pcontent+='<a href="#" onclick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a> '
		pcontent+='<a href="#" style="font-weight: bold;" onclick=\"ContentSlider.turnpage(\''+sliderid+'\', parseInt(this.getAttribute(\'rel\'))); return false\">'+(slider.nextText || "Next")+'</a>'
		}

	paginatediv.innerHTML=pcontent
	paginatediv.onclick=function(){ //cancel auto run sequence (if defined) when user clicks on pagination DIV
	if (typeof window[sliderid+"timer"]!="undefined")
		clearTimeout(window[sliderid+"timer"])
		}
}

ContentSlider.turnpage=function(sliderid, thepage){
	
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //gather pagination links
	var nFrames;
	if(typeof (imgInfo)!="undefined")
		{
		for (var i=0; i<imgInfo.length; i++){ //For each DIV within slider
			//paginatelinks[i].className="" //empty corresponding pagination link's class name
			slidernodes[sliderid][i].style.display="none" //hide DIV
			}
		nFrames=imgInfo.length;
		document.getElementById("cur_page").innerHTML = '' + (thepage + 1) + ' of '+ nFrames +''
	} else {
		for (var i=0; i<slidernodes[sliderid].length; i++){ //For each DIV within slider
			paginatelinks[i].className="" //empty corresponding pagination link's class name
			slidernodes[sliderid][i].style.display="none" //hide DIV
			}
		nFrames=slidernodes[sliderid].length;
		}
	//paginatelinks[thepage].className="selected" //for selected DIV, set corresponding pagination link's class name
	try{
	slidernodes[sliderid][thepage].style.display="block" //show selected DIV

	}catch(err){}
	// Set "Prev" link
	paginatelinks[0].setAttribute("rel", theprevpage=(thepage>0)? thepage-1 : (nFrames-1))
	//Set "Next" pagination link's (last link within pagination DIV) "rel" attribute to the next DIV number to show
	paginatelinks[paginatelinks.length-1].setAttribute("rel", thenextpage=(thepage<(nFrames-1))? thepage+1 : 0)
	if (enablepersist)
		setCookie(sliderid, sliderid+":"+thepage)
	
}

ContentSlider.autoturnpage=function(sliderid, autorunperiod, cycles){
	var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //Get pagination links
	var nextpagenumber=parseInt(paginatelinks[paginatelinks.length-1].getAttribute("rel")) //Get page number of next DIV to show
	ContentSlider.turnpage(sliderid, nextpagenumber) //Show that DIV
	if (cycles>0){
	var slider=document.getElementById(sliderid)
	if (nextpagenumber==0)
	slider.cyclecount=(typeof slider.cyclecount!="undefined")? slider.cyclecount+1 : 1
	if (slider.cyclecount && slider.cyclecount==cycles)
	return
	}
	window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod, cycles)}, autorunperiod)
}

function getCookie(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

function setCookie(name, value){
	document.cookie = name+"="+value
}

////////////////Ajax Related functions //////////////////////////////////

ContentSlider.ajaxpage=function(url, thediv){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
		try{
		page_request = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
	else
		return false
	thediv.innerHTML=csloadstatustext
	page_request.onreadystatechange=function(){
		ContentSlider.loadpage(page_request, thediv)
	}
	if (csbustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

ContentSlider.loadpage=function(page_request, thediv){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		thediv.innerHTML=page_request.responseText
}

ContentSlider.loadobjects=function(externalfiles){ //function to load external .js and .css files. Parameter accepts a list of external files to load (array)
	for (var i=0; i<externalfiles.length; i++){
		var file=externalfiles[i]
		var fileref=""
		if (csloadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			csloadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}


// Freedom-specific modifications
var imgCount,htmlOut,imgsSlider,imgMaxWidth,imgMaxHeight,imgMaxTotalHeight;
imgCount=0;
function imageSlide(file,cutline,credit,picturealt,width,height,storyid,storydb)
{
  this.file=file;
  this.cutline=cutline;
  this.credit=credit;
  this.picturealt=picturealt;
  this.width=width;
  this.height=height;
	if (storyid != "")
		this.storyid=storyid;
	if (storydb != "")
		this.storydb=storydb;
}

function writeImageSlider () {
	htmlOut = ''
	htmlOut += '<div id="slider1" class="contentslide1" style="width:230px;">\n';
	for (i=0;i<imgCount;i++) {
		var myWidth = (imageSlide[i].width < 230)?'width="'+imageSlide[i].width+'"':'width=230';
		htmlOut += '<div class="contentdiv">\n';
		htmlOut += '<div class="image_mask" >'	
		htmlOut += '<div class="image_box"><div>'
		
		//if (imageSlide[i].width < 230)
			htmlOut += '<div align="center">';
			
		if (parseInt(imageSlide[i].storyid) > 0) {
			htmlOut += '  <a href="/sections/article/gallery/?pic='+(i+1)+'&amp;id='+imageSlide[i].storyid+'&amp;db='+imageSlide[i].storydb+'">';
		} else {
			htmlOut += '  <a href="'+imageSlide[i].file+'" target="_blank">';			
		}
		htmlOut += '<img src="'+imageSlide[i].file+'" '+myWidth+' style="max-width:230px;" alt="'+imageSlide[i].picturealt+'" border="0" />';
		htmlOut += '</a>';
		//if (imageSlide[i].width < 230)
			htmlOut += '</div>';
	
		htmlOut += '</div></div>' // end image_box and div
		
		htmlOut += '<div class="image_info_box"><div class="enlarge opaque">'
		htmlOut += '<a href="/sections/article/gallery/?pic='+(i+1)+'&amp;id='+imageSlide[i].storyid+'&amp;db='+imageSlide[i].storydb+'">enlarge</a>';
		htmlOut += '</div></div>' // end image_info_box, enlarge
		htmlOut += '</div>' // end image_mask
		
		if ('"'+imageSlide[i].credit+'"' != "") {
			htmlOut += '  <div class="credit">\n';
			htmlOut +=   ' '+imageSlide[i].credit+'&#160;\n';
			htmlOut += '  </div>\n';
		}			 
		if (imageSlide[i].cutline!='') {
			htmlOut += '  <div class="contentdivtxt" style="width:230px;overflow:auto;">\n';
			htmlOut +=     imageSlide[i].cutline+'&#160;';
			htmlOut += '  </div>\n';
		}
		/*
		if (parseInt(imageSlide[i].storyid) > 0) {
			htmlOut += '<br /><a href="/sections/article/gallery/?pic='+(i+1)+'&amp;id='+imageSlide[i].storyid+'&amp;db='+imageSlide[i].storydb+'" style="color:#036;font-size:9pt;font-weight:normal;">Click to Enlarge</a>\n';
		}
		*/
		htmlOut += '</div>\n';
	}
	htmlOut += '<div class="thumbnailpagination" id="paginate-slider1"></div>';
	htmlOut += '</div>';
	
	return htmlOut;
}

var imgCount,htmlOut,imgsSlider,imgMaxWidth,imgMaxHeight;
imgCount=0;

if( typeof(imgInfo) != 'undefined' )
{
	for(x = 0; x < imgInfo.length; x++)
	{
		if (imgInfo[x][0] != "" && imgInfo[x][0] != "medium/" && imgInfo[x][0] != "http://images.onset.freedom.com/"+imgInfo[x][7]+"/") 
		{
			if (imgInfo[x][6] != "")
				imgStoryId = imgInfo[x][6];
			if (imgInfo[x][7] != "")
				imgStoryDb = imgInfo[x][7];
			
			imageSlide[x] = new imageSlide(imagePrefix + imgInfo[x][0],imgInfo[x][1],imgInfo[x][2],imgInfo[x][3],imgInfo[x][4],imgInfo[x][5],imgStoryId,imgStoryDb);
			imgMaxWidth = imgInfo[x][4];
			imgMaxHeight = imgInfo[x][5];
			
			imgCount++;
			imgMaxTotalHeight = parseInt(imgMaxHeight)
			imgMaxTotalHeight += 100 ;
		}
	}
	
	/*
	//if (imgInfo[0][0] != "") 
	if (imgInfo[0][0] != "" && imgInfo[0][0] != "medium/" && imgInfo[0][0] != "http://images.onset.freedom.com/"+imgInfo[0][7]+"/") 
	{
	  if (imgInfo[0][6] != "")
	  	imgStoryId = imgInfo[0][6];
	  if (imgInfo[0][7] != "")
	  	imgStoryDb = imgInfo[0][7];

	  imageSlide[0] = new imageSlide(imagePrefix + imgInfo[0][0],imgInfo[0][1],imgInfo[0][2],imgInfo[0][3],imgInfo[0][4],imgInfo[0][5],imgStoryId,imgStoryDb);
	  imgMaxWidth = imgInfo[0][4];
	  imgMaxHeight = imgInfo[0][5];
	  
	  imgCount++;
		imgMaxTotalHeight = parseInt(imgMaxHeight)
		//if (imageSlide[0].cutline != '') {
			imgMaxTotalHeight += 100 ;
		//}
	}
	//if (imgInfo[1][0] != "")
	if (imgInfo[1][0] != "" && imgInfo[1][0] != "medium/" && imgInfo[1][0] != "http://images.onset.freedom.com/"+imgInfo[0][7]+"/")
	{
	  imageSlide[1] = new imageSlide(imagePrefix + imgInfo[1][0],imgInfo[1][1],imgInfo[1][2],imgInfo[1][3],imgInfo[1][4],imgInfo[1][5],imgStoryId,imgStoryDb);
	  if (imgMaxWidth < parseInt(imgInfo[1][4]))
	    imgMaxWidth=parseInt(imgInfo[1][4]);
	  if (imgMaxHeight < parseInt(imgInfo[1][5]))
	    imgMaxHeight=parseInt(imgInfo[1][5]);

			imgMaxTotalHeight = parseInt(imgMaxHeight)
			//if (imageSlide[1].cutline != '') {
				imgMaxTotalHeight += 100 ;
			//}
	  imgCount++;
	}
	//if (imgInfo[2][0] != "")
	if (imgInfo[2][0] != "" && imgInfo[2][0] != "medium/" && imgInfo[2][0] != "http://images.onset.freedom.com/"+imgInfo[0][7]+"/")
	{
	  imageSlide[2] = new imageSlide(imagePrefix + imgInfo[2][0],imgInfo[2][1],imgInfo[2][2],imgInfo[2][3],imgInfo[2][4],imgInfo[2][5],imgStoryId,imgStoryDb);
	  if (imgMaxWidth < parseInt(imgInfo[2][4]))
	    imgMaxWidth=parseInt(imgInfo[2][4]);
	  if (imgMaxHeight < parseInt(imgInfo[2][5]))
	    imgMaxHeight=parseInt(imgInfo[2][5]);
			imgMaxTotalHeight = parseInt(imgMaxHeight)
			//if (imageSlide[2].cutline != '') {
				imgMaxTotalHeight += 100 ;
			//}
	  imgCount++;
	}
	*/
}

if (imgCount > 1) {
  document.getElementById(articleDivID).innerHTML = writeImageSlider();
  ContentSlider("slider1", 0, "", "", 1);

}
Freedom = function() {
	this.initialize.apply(this, arguments);
};

Freedom.prototype = {
	initialize: function() {
		var args;
		if ((arguments.length == 1) && (typeof(arguments[0]) == 'object')) {
			args = arguments[0];
		}
		else {
			args = {};
			switch(arguments.length) {
				case 1:
					args.domain = arguments[0];
					break;
				case 2:
					args.domain = arguments[0];
					args.taxonomy = arguments[1];
					break;
				case 2:
					args.domain = arguments[0];
					args.taxonomy = arguments[1];
					args.positions = arguments[2];
					break;
				default:
					break;
			}
		}

		if (typeof(args.positions) == 'undefined') { args.positions = 'Top,Right,Right1,Left1,Middle,Middle1'; }

		this.positions = args.positions;
		this.domain = typeof(args.domain) != 'undefined' ? args.domain : 'ocregister.com';
		this.taxonomy = typeof(args.taxonomy) != 'undefined' ? args.taxonomy : '/homepage';

		this.page = new Page(args);
		this.ads = new Ads(args);
	},

	'$': function(id) {
		return document.getElementById(id);
	}
};
Ads = function() {
	this.iframeSource = 'http://common.onset.freedom.com/oas/jx/';
	this.RNS = new String (Math.random()).substring(2, 11);
	this.autoRefresh = false;
	this.refreshTime = 2 * 60 * 1000; // Milliseconds
	this.queryValues = "";
	this.initialize.apply(this, arguments);
};

Ads.prototype = {
	initialize: function() {
		var args;
		if ((arguments.length == 1) && (typeof(arguments[0]) == 'object')) {
			args = arguments[0];
		}
		else {
			args = {};
			switch(arguments.length) {
				case 1:
					args.domain = arguments[0];
					break;
				case 2:
					args.domain = arguments[0];
					args.taxonomy = arguments[1];
					break;
				case 3:
					args.domain = arguments[0];
					args.taxonomy = arguments[1];
					args.positions = arguments[2];
					break;
				default:
					break;
			}
		}

		this.domain = typeof(args.domain) != 'undefined' ? args.domain : 'ocregister.com';
		this.taxonomy = typeof(args.taxonomy) != 'undefined' ? args.taxonomy : '/homepage';
		this.positions = typeof(args.positions) != 'undefined' ? args.positions : '';
	},
	setQuery:function() {
		if (arguments.length) 
			this.queryValues = arguments[0];
	},
	iframe: function () {
		var args;
		var domain;
		var taxonomy;

		if (arguments.length == 1) {
			if (typeof(arguments[0]) == 'object') {
				args = arguments[0];
			}
			else {
				args = {};
				switch(arguments.length) {
					case 1:
						args.position = arguments[0];
						break;
					case 2:
						args.position = arguments[0];
						args.positions = arguments[1];
						break;
					default:
						break;
				}
			}
		}

		if (typeof(args) == 'undefined') { return; }
		if (typeof(args.position) == 'undefined') { return; }

		var width = (typeof(args.width) != 'undefined') ? args.width : this.defaultWidth(args.position);
		var height = (typeof(args.height) != 'undefined') ? args.height : this.defaultHeight(args.position);
		var positions = (typeof(args.positions) != 'undefined') ? args.positions : this.positions;

		var pos = -1;
		if (typeof(args.domain) != 'undefined') {
			domain = args.domain;
		}
		else if (typeof(OAS_sitepage) != 'undefined') {
			pos = OAS_sitepage.indexOf('/');
			if (pos != -1) {
				domain = OAS_sitepage.substr(0, pos);
			}
			else {
				domain = this.domain;
			}
		}
		else {
			domain = this.domain;
		}

		if (typeof(args.taxonomy) != 'undefined') {
			taxonomy = args.taxonomy;
		}
		else if (typeof(OAS_sitepage) != 'undefined') {
			pos = OAS_sitepage.indexOf('/');
			if (pos != -1) {
				taxonomy = OAS_sitepage.substr(pos);
			}
			else {
				taxonomy = this.taxonomy;
			}
		}
		else {
			taxonomy = this.taxonomy;
		}

		document.write('<iframe id="position' + args.position + '" name="position' + args.position + '" width="' + width + '" height="' + height + '" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="' + this.iframeSource + '?domain=' + domain + '&taxonomy=' + taxonomy + '&positions=' + positions + '&position=' + args.position + '&rand=' + this.RNS + '&query=' + this.queryValues + '"></iframe>');

		if (this.autoRefresh) {
			document.write('<scr' + 'ipt type="text/javascript">setInterval("reloadFrame(\\"position' + args.position + '\\")", ' + this.refreshTime + ');<\/scr' + 'ipt>');
		}
	},

	defaultWidth: function (position) {
		var width = 0;
		switch(position) {
			case 'Top':
				width = 728;
				break;
			case 'Right1':
				width = 120;
				break;
			case 'Right':
				width = 160;
				break;
			case 'Left1':
				width = 120;
				break;
			case 'Middle':
			case 'Middle1':
				width = 300;
				break;
			default:
				width = 0;
		}
		return width;
	},

	defaultHeight: function (position) {
		var height = 0;
		switch(position) {
			case 'Top':
			case 'Right1':
				height = 90;
				break;
			case 'Right':
			case 'Left1':
				height = 600;
				break;
			case 'Middle':
			case 'Middle1':
				height = 250;
				break;
			default:
				height = 0;
		}
		return height;
	},

	'$': function(id) {
		return document.getElementById(id);
	}
};

function reloadFrame(frm) {
	var f = document.getElementById(frm);
	if (f) f.src = f.src;
}
Page = function() {
	this.initialize.apply(this, arguments);
};

Page.prototype = {
	initialize: function() {
		var args;
		if ((arguments.length == 1) && (typeof(arguments[0]) == 'object')) {
			args = arguments[0];
		}
		else {
			args = {};
			switch(arguments.length) {
				case 1:
					args.domain = arguments[0];
					break;
				case 2:
					args.domain = arguments[0];
					args.taxonomy = arguments[1];
					break;
				default:
					break;
			}
		}

		this.domain = typeof(args.domain) != 'undefined' ? args.domain : 'ocregister.com';
		this.taxonomy = typeof(args.taxonomy) != 'undefined' ? args.taxonomy : '/homepage';
	},

	onload: function () {
	},

	'$': function(id) {
		return document.getElementById(id);
	}
};
