// JavaScript Document

	function writeoldflash(inobj, inmov,width,height){
		d = document.getElementById(inobj);
		flashhtml = "<object data=\""+inmov+"\" width=\""+width+"\" height=\""+height+"\" type=\"application/x-shockwave-flash\"><param name=\"type\" value=\"application/x-shockwave-flash\" /><param name=\"src\" value=\""+inmov+"\" /><param name=\"data\" value=\""+inmov+"\" /><param name=\"codebase\" value=\""+inmov+"\" /><param name=\"movie\" value=\""+inmov+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param value=\"opaque\" name=\"wmode\" /><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /><img src=\"resources/layout_02.jpg\" class=\"rightphoto\" width=\"634\" height=\"162\" alt=\"Banner photo\" /></object>";
		//alert(flashhtml);
		d.innerHTML = flashhtml;
	}
	
	function writeflash(inobj, inmov,width,height){
		d = document.getElementById(inobj);
		flashhtml = "<object data=\""+inmov+"\" width=\""+width+"\" height=\""+height+"\" type=\"application/x-shockwave-flash\"><param name=\"type\" value=\"application/x-shockwave-flash\" /><param name=\"src\" value=\""+inmov+"\" /><param name=\"data\" value=\""+inmov+"\" /><param name=\"codebase\" value=\""+inmov+"\" /><param name=\"movie\" value=\""+inmov+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param value=\"opaque\" name=\"wmode\" /><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /><img src=\"resources/layout_02.jpg\" class=\"rightphoto\" width=\"634\" height=\"162\" alt=\"Banner photo\" /></object>";
		//alert(flashhtml);
		d.innerHTML = flashhtml;
	}
	
	function CreateControl(DivID, CLSID, ObjectID, width, height, inmov){
	var d = document.getElementById(DivID);
	d.innerHTML = "<object data=\""+inmov+"\" id=\""+ObjectID+"\" width=\""+width+"\" height=\""+height+"\" classid=\""+CLSID+"\" type=\"application/x-shockwave-flash\"><param name=\"type\" value=\"application/x-shockwave-flash\" /><param name=\"src\" value=\""+inmov+"\" /><param name=\"data\" value=\""+inmov+"\" /><param name=\"codebase\" value=\""+inmov+"\" /><param name=\"movie\" value=\""+inmov+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param value=\"opaque\" name=\"wmode\" /><param name=\"pluginurl\" value=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
	//<img src=\"resources/layout_02.jpg\" class=\"rightphoto\" width=\"634\" height=\"162\" alt=\"Banner photo\" />
}

$(function(){
		   
	$("a[title^='New Window: ']").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("New Window: ").length);
		$(this).attr('title',newtitle);
		$(this).click(function(){ var newwin = window.open($(this).attr('href'),'newwin'); newwin.focus(); return false; });
	});
	$("a[title^='View Distributor: ']").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("View Distributor: ").length);
		$(this).attr('title',newtitle);
		$(this).click(function(){ var distwin = window.open($(this).attr('href'),'distwin',"toolbar=no, location=no, scrollbars=yes, directories=no, status=no, menubar=no, resizable=yes, width=520, height=480"); distwin.focus(); return false; });
	});
	$("a[title^='View Event: ']").each(function(){
		var newtitle = String($(this).attr('title')).substring(String("View Event: ").length);
		$(this).attr('title',newtitle);
		$(this).click(function(){ var eventwin = window.open("event.php?id="+$(this).attr('name'),"eventwin","toolbar=no, location=no, scrollbars=yes, directories=no, status=no, menubar=no, resizable=no, width=520, height=480"); eventwin.focus(); return false; });
	});
	
	correctPNG();
	processNewsObj();
	processHomeObj();
	
	$("#content div.horse_box a[href*='#images']").each(function(){
		var o = $(this);
		var oldtitle = o.text();
		o.toggle(function(){ o.parents("div.horse_box").find("div.imgs").css({left:30}); o.text("Hide additional photographs"); }, function(){ o.parents("div.horse_box").find("div.imgs").css({left:-4400}); o.text(oldtitle); });
		return false;
	});
	
});


function alterCalendarAnchors(){
	as = document.getElementsByTagName('a');
	var returnstr;
	if(as.length>0){
		for(var i = 0; i<as.length;i++){
			atitle = String(as[i].title);
			if(atitle.indexOf("View Event: ")==0){
				as[i].onclick= function() { openevent(this.name); return false; };
			}
		}
	}
	//alert(returnstr);
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version < 8) && (document.body.filters)){
      for(var i=0; i<document.images.length; i++){
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if(imgName.substring(imgName.length-3, imgName.length) == "PNG"){
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}

function processNewsObj(){
	target_objs = document.getElementById("content").getElementsByTagName("div");
	var group = "news_container";
	//FIND NEWS CONTAINERS
	for(var i = 0; i<target_objs.length;i++){
		current_obj = target_objs[i];
		current_obj_id = String(current_obj.id);
		current_obj_cn = String(current_obj.className);
		if(current_obj_cn==group){
			//FIND NEWS YEARS
			newsitem_y_all = current_obj.getElementsByTagName("div");
			newsitems_years = new Array();
			newsitems_found = 0;
			for(var i_niy = 0; i_niy<newsitem_y_all.length;i_niy++){
				if(newsitem_y_all[i_niy].className=='news_year'){
					newsitems_found++;
					newsitems_years.push(newsitem_y_all[i_niy].id);
					if(newsitems_found!==1){ newsitem_y_all[i_niy].style.display = 'none'; }
				}
			}
			//FIND NEWS CONTROL BOXES
			controlboxes = current_obj.getElementsByTagName("div");
			for(var i_c = 0; i_c<controlboxes.length;i_c++){
				if(controlboxes[i_c].className=='news_control'){
					//CREATE CONTROLS
					if(newsitems_years.length>0){
						//controlboxes[i_c].innerHTML += "<ul>";
						controlboxes_ul = document.createElement('ul');
						controlboxes[i_c].appendChild(controlboxes_ul);
						for(var i_y = 0; i_y<newsitems_years.length;i_y++){
							getYearstr = String(newsitems_years[i_y]);
							getYearstr_a = getYearstr.split("_");
							
							//controlboxes[i_c].innerHTML += "<li><a href=\"#\" name=\""+current_obj_id+"\">"+getYearstr_a[2]+"</a></li>";
							controlboxes_ul_li = document.createElement('li');
							controlboxes_ul.appendChild(controlboxes_ul_li);
							controlboxes_ul_li_a = document.createElement('a');
							controlboxes_ul_li_a.setAttribute('href','#');
							controlboxes_ul_li_a.setAttribute('name',current_obj_id);
							controlboxes_ul_li_a.innerHTML = getYearstr_a[2];
							controlboxes_ul_li.appendChild(controlboxes_ul_li_a);
							
							
						}
						//controlboxes[i_c].innerHTML += "</ul>";
						//PROGRAM CONTROLS
						newstabs = controlboxes[i_c].getElementsByTagName("a");
						for(var i_nt = 0; i_nt<newstabs.length;i_nt++){
							//WRITE FUNCTION
							newstabs[i_nt].onclick = function(){
								target_n_objs = document.getElementById(this.name).getElementsByTagName("div");
								for(var i_target = 0; i_target<target_n_objs.length;i_target++){
									target_n_objs_id = String(target_n_objs[i_target].id);
									if(target_n_objs_id.indexOf('news_year_')==0){
										if(target_n_objs_id=="news_year_"+this.innerHTML){
											target_n_objs[i_target].style.display = 'block';
										}else{
											target_n_objs[i_target].style.display = 'none';
										}
									}
								}
								return false;
							}
							//END FUNCTION
						}
						//END PROGRAM CONTROLS
					}
					//END CREATE CONTROLS
				}
			}
		}else{
			//current_obj.style.display = "none";
		}
	}
}



function processHomeObj(){
	if(target_home_objs = document.getElementById("homebox_container")){
	//var target_home_objs = document.getElementById("content").getElementsByTagName("div");
	var home_group = "homebox_container";
	//FIND SUB CONTAINERS
	
//	for(var i = 0; i<target_home_objs.length;i++){
		var current_home_obj = target_home_objs//[i];
		var current_home_obj_id = String(current_home_obj.id);
		var current_home_obj_cn = String(current_home_obj.className);
//		if(current_home_obj_cn==home_group){
			//FIND TABS
			var home_items = current_home_obj.getElementsByTagName("div");
			var home_items_tempa = new Array();
			var home_items_found = 0;
			for(var i_hiy = 0; i_hiy<home_items.length;i_hiy++){
				if(home_items[i_hiy].className=='homebox_item'){
					home_items[i_hiy].id = "homebox_item-"+home_items_found;
					home_items[i_hiy].className='homebox_item_p'
					var hi_h3 = home_items[i_hiy].getElementsByTagName("h3");
					var hi_h3_a =  hi_h3[0].getElementsByTagName("a");
					home_items_found++;
					hi_h3[0].style.display = 'none'
					home_items_tempa.push(Array(hi_h3_a[0].innerHTML,hi_h3_a[0].href));
					//alert(hi_h3_a[0].innerHTML);
					if(home_items_found!==1){ home_items[i_hiy].style.display = 'none'; }
				}
			}
			//FIND NEWS CONTROL BOXES
			//alert(current_home_obj.className)
			if(home_items_tempa.length>0){
						controlboxes = document.getElementById("homebox_control"); //current_obj.getElementsByTagName("div");
						//controlboxes.setAttribute('className','home_control');
						controlboxes.className = 'home_control';
						//current_home_obj.appendChild(controlboxes);
						//alert(current_home_obj.className)
						//controlboxes[i_c].innerHTML += "<ul>";
						controlboxes_ul = document.createElement('ul');
						controlboxes.appendChild(controlboxes_ul);
						for(var i_y = 0; i_y<home_items_tempa.length;i_y++){
							//getYearstr = String(newsitems_years[i_y]);
							getYearstr_a = home_items_tempa[i_y][0];
							
							//controlboxes[i_c].innerHTML += "<li><a href=\"#\" name=\""+current_obj_id+"\">"+getYearstr_a[2]+"</a></li>";
							controlboxes_ul_li = document.createElement('li');
							controlboxes_ul.appendChild(controlboxes_ul_li);
							controlboxes_ul_li_a = document.createElement('a');
							controlboxes_ul_li_a.setAttribute('href',home_items_tempa[i_y][1]);
							controlboxes_ul_li_a.setAttribute('name',"homebox_item-"+i_y);
							controlboxes_ul_li_a.innerHTML = getYearstr_a;
							controlboxes_ul_li.appendChild(controlboxes_ul_li_a);
							
							
						}
						//controlboxes[i_c].innerHTML += "</ul>";
						//PROGRAM CONTROLS
						hometabs = controlboxes.getElementsByTagName("a");
						for(var i_nt = 0; i_nt<hometabs.length;i_nt++){
							//WRITE FUNCTION
							hometabs[i_nt].onmouseover = function(){
								target_n_objs = document.getElementById('homebox_container').getElementsByTagName("div");
								for(var i_target = 0; i_target<target_n_objs.length;i_target++){
									target_n_objs_id = String(target_n_objs[i_target].id);
									if(target_n_objs_id.indexOf('homebox_item-')==0){
										if(target_n_objs_id==this.name){
											target_n_objs[i_target].style.display = 'block';
										}else{
											target_n_objs[i_target].style.display = 'none';
										}
									}
								}
								return false;
							}
							//END FUNCTION
						}
						//END PROGRAM CONTROLS
					}
					//END CREATE CONTROLS
			//	}
		//	}
	//	}else{
			//current_obj.style.display = "none";
		//}
	}
}

-->
