var loggedon = "false";

function popUp(URL) {day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300 height=340 left = 372,top = 279');");
}

function mylist() { if(this.document.all.mylist.style.display=="none"){this.document.all.mylist.style.display="block"}
else {this.document.all.mylist.style.display="none"} ; 
}

function showphoto(name,src,horse,w,h) {
    if (document.images)     {   document.images[name].src = src;
       document.images[name].width = w;
       document.images[name].height=h;}
       

    if (document.getElementById){ document.getElementById("cap01").innerHTML=horse;
       document.getElementById("cap01").width=w;}
}

function printerfriendly() { 
    childWin = open("", "childWin","toolbar,scrollbars,menubar,status,innerwidth=500,innerheight=400"); 


 var alltext = document.logstatus.story.value; 
  //   var alltext = parent.textarray[1]; 
    var alltext1 = "";
         arrtext = alltext.split("\n");
          
    for (var i=0; i < arrtext.length; i++) {j=i+1;
        alltext1 = alltext1+arrtext[i]+"<br>"; 
      }
       //var alltext1 = alltext.replace("RACE ","RACERACE ");
//$textstring = ereg_replace("\n", '', $textstring); 
//$textstring = ereg_replace("\r", '', $textstring);
//$textstring = ereg_replace("\t", '', $textstring);

    childWin.document.write("<p><b>TRACKWORK.co.nz.</b></p>"); 
    childWin.document.write(alltext1); 
} 

function scrollToBottom (element) {
  if (document.all)
    element.scrollTop = element.scrollHeight;
}

function pop(){ var newwin;var centerWidth=(screen.width/2)-(600/2);
var centerHeight=(screen.height/2)-(300/2);
newwin=window.open("http://www.trackwork.co.nz/gal/trialssearch.php","hs","location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no,directories=no,width=700,height=260,top="+centerHeight+",left=50")}

function pop1(){ var newwin;
var centerWidth=(screen.width/2)-(600/2);
var centerHeight=(screen.height/2)-(300/2);
newwin=window.open("http://www.trackwork.co.nz/gal/racesearch.php","hs","location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no,directories=no,width=1000,height=500,top="+centerHeight+",left=50")}

function popup1(filename,w,h,top){var centerWidth=(screen.width/2)-(w/2);
var centerHeight=(screen.height/2)-(h/2);
if (top=="top") { centerHeight = 0};
window.open(filename,"","height="+h+",width="+w+",top="+centerHeight+",left="+centerWidth+",location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=yes,toolbar=no,directories=no");}


var idx = 0;
var status_str = "";
var max_len = status_str.length;

function status() {  window.defaultStatus = status_str.substring(0,idx);  
if(idx >= max_len) {idx = 0; window.setTimeout('status();', 2000);  } else {    idx++;    window.setTimeout('status();', 50);  }}status();

function checklogin(no)  { var bWin32IE;if ((navigator.userAgent.indexOf("IE") >
 -1) && (navigator.platform =="Win32")) {     bWin32IE = true;   
if(document.logstatus.loginstatus.value !=="Logged On") 
 {
alert(loggedon+"Reminder ! \nPlease Log On.");
return false
}
if (no==2){
var thelen2 = document.Search2.h.value;
if (thelen2.length < 3 ) {
alert("invalid input");
return false
}
}
if (no==3){
var thelen3 = document.Search3.sire.value;
if (thelen3.length < 3 ) {
alert("invalid input");
return false
}
}
} 
//else {alert("Netscape not supported."); }  
}

function openTarget (form, features, windowName) {
  if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
  form.target = windowName;
  open ('', windowName, features);
}

function ylg(letter) {
parent.cacheframe.location.href='racepicsylg.php?letter='+letter;
}

function catalogue(thelot) {
lot = Search0.lotno.value;
if (lot < 1450) {
if (lot < 495) { sale = 125;}
if (lot > 494)  {sale=130;}
if (lot > 1154) { sale=131;}

window.open("http://www.nzb.co.nz/sales/pedigree.cfm?sale_id="+sale+"&lot="+lot,'','toolbar=no,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=700,left=0,top=0');
}
return false;
}


function showlinks() {
var rowsize= 0 ;
var textstring = "<br>Click Web Sites with<br> YEARLING PHOTOS.<br><br><a href='http://www.equivision.co.nz' target=_blank>EQUIVISION</a><br><br><a href='http://www.blandfordlodge.co.nz' target=_blank>BLANDFORD LODGE </a><br><br><a href='http://www.brighthillfarm.co.nz' target=_blank>BRIGHTHILL FARM</a> <br><br><a href='http://www.haunuifarm.co.nz' target=_blank>HAUNUI FARM</a><br><br><a href='http://www.javalodge.co.nz' target=_blank>JAVA LODGE</a><br><br><a href='http://www.lastud.co.nz' target=_blank>LITTLE AVONDALE STUD</a><br><br><a href='http://www.theoaksstud.co.nz' target=_blank>THE OAKS STUD</a><br><br> <a href='http://www.westburystud.com' target=_blank> WESTBURY STUD LTD</a><br><br>";
var numrows= 2 ;

 if (document.getElementById){ document.getElementById("a1").innerHTML=textstring;
       document.getElementById("a1").width=10;}

}


function putarea(obj,id) {
var textstring = "<div><form name = 'cmt' onclick='return checklogin()' onSubmit='return makecomment(cmt,id);'> <table><tr><td><div><textarea  rows ='5' cols ='70' name ='comment' id="+id+" style='font-family:sans-serif,arial;font-size:10pt;margin-top:0;margin-left:5;overflow:auto;scrollbar-face-color:#FFDA89;scrollbar-arrow-color:red;scrollbar-track-color:#FAEBD7;border-width:2px;line-height:9pt;border-color:lightgray;background-color:#FFFFEE;'></textarea></div></td></tr><tr><td><input type='hidden' name='id' value ="+id+">Name: <input type='text' size='15' name='name' >&nbsp;&nbsp;&nbsp;<input type='submit' name='Sub"+obj+"' style='border-color:lightgray;background-color:#FFFFEE;' value='Submit'></td></tr></table></form></div><hr />";

document.getElementById(obj).innerHTML=textstring;
//document.getElementById(obj).style.visibility = "visible";
//document.getElementById(r).rows=40;
//document.getElementById(r).cols=10;
}

function topicarea(obj) {
var textstring = "<div style='font-family:Arial,sans-serif;font-size:9pt;'><form name = 'topic' onclick='return checklogin()' onSubmit='return maketopic(topic);'> <table><tr><td>&nbsp;Horses Name&nbsp;&nbsp;&nbsp;<textarea rows='1' cols='20' name='bloghorse' style='font-family:sans-serif,arial;font-size:9pt;border-width:2px;line-height:10pt;border-color:lightgray;background-color:#FFFFEE;'></textarea></td</tr><tr><td>&nbsp;Topic Heading <textarea rows='1' cols='56' name='topictitle' style='font-family:sans-serif,arial;font-size:9pt;border-width:2px;line-height:10pt;border-color:lightgray;background-color:#FFFFEE;'></textarea></td</tr><tr><td><textarea  rows ='7' cols ='78' name ='topx' style='font-family:sans-serif,arial;font-size:9pt;margin-top:0;margin-left:5;overflow:auto;scrollbar-face-color:#FFDA89;scrollbar-arrow-color:red;scrollbar-track-color:#FAEBD7;border-width:2px;line-height:9pt;border-color:lightgray;background-color:#FFFFEE;'></textarea></td></tr><tr><td nowrap><input type='hidden' >&nbsp;Your Name: <input type='text' size='20' name='name' >&nbsp;&nbsp;&nbsp;<input type='submit' name='Sub"+obj+"' style='border-color:lightgray;background-color:#FFFFEE;' value='Submit'></form></td></tr><tr><td><font size='-1'>&nbsp;After submitting you will be asked to attach any photos or audio from your computer.</font></td></tr></table></div><hr />";

document.getElementById(obj).innerHTML=textstring;
//document.getElementById(obj).style.visibility = "visible";
//document.getElementById(r).rows=40;
//document.getElementById(r).cols=10;
}

function makecomment(cmt,id) {
var thetext = cmt.comment.value;
//thetext = "kcuyrukyrkuy  til";
//thetext =thetext.replace("x","\n");
//thetext = thetext.replace("\n","xyz");
thetext = thetext.replace(/\r/g,"xyz")


var theid = cmt.id.value;
var name = cmt.name.value;
popup1("http://www.trackwork.co.nz/gal/send_comment.php?entry="+theid+"&name="+name+"&comment="+thetext,400,400,50 );
return false;
}

function maketopic(topic) {
var thetext = topic.topx.value;
//thetext = "kcuyrukyrkuy  til";
//thetext =thetext.replace("x","\n");
//thetext = thetext.replace("\n","xyz");
thetext = thetext.replace(/\r/g,"xyz")


//var theid = topic.id.value;
var name = topic.name.value;
var thetitle = topic.topictitle.value
popup1("http://www.trackwork.co.nz/gal/top_process.php?name="+name+"&title="+thetitle+"&comment="+thetext,600,300,50 );
return false;
}

function setvar() {
var  textarray = new array(2);
textarray[0] = "xx";
}

function deltopics() {
document.getElementById("blogindex").innerHTML="";
document.blog.button1.value = "Horse Blogger";
//if (document.blog.buttonx.value == " Y "){document.blog.buttonx.value = " X ";} else {
//document.blog.buttonx.value = " Y ";
//}
}

function toggle1() {
//document.getElementById("blogindex").innerHTML="";
if (document.blog.button1.value == "Horse Blogger"){document.blog.button1.value = "testing only";
return true} else {if (document.blog.button1.value == "testing only") {deltopics(); return false
}
}
}


function blog_index() {
var textstring = "<b>HORSE BLOG<br> INDEX</b><br>Click a horse<br><br>This is where all blogged horses will  initially listed.<br><br>Any horses entered to race will also show up here just like the photo index.";
document.getElementById("a1").innerHTML=textstring;
}

function showkeywords() {
var rowsize= 0 ;
var textstring = "<br><blockquote><div style='font-family:Arial,Helvetica,sans-serif;font-size:12px;'><b>SEARCH KEYWORDS</b><br>Agistment Farm<br>Auction Sales<br>Bloodstock Agent<br>Breaking and Pre Training<br>Business Announcement<br>Employment Available<br>Employment Wanted<br>Equine Health<br>Farm Equipment<br>Feed & Nutrition<br>For Sale<br>Horse Transport<br>Legal Information<br>New Product<br>New Service<br>Official Announcement<br>Photography<br>Real Estate<br>Sales Preparation<br>Shares Available<br>Stallion Service<br>Stud News<br>Syndicate<br>Tourism<br>Trackwork Rider<br></div></blockquote>";
var numrows= 2 ;

 if (document.getElementById){ document.getElementById("blogindex").innerHTML=textstring;
       document.getElementById("a1").width=10;}

}

function postarea(obj,id) {
var textstring = "<div><form name = 'cmt' action='gal/send_comment_post1.php' method=POST target='cacheframe' > <table><tr><td><div><textarea  rows ='5' cols ='70' name =blogcomment id='comarea' style='font-family:sans-serif,arial;font-size:10pt;margin-top:0;margin-left:5;overflow:auto;scrollbar-face-color:#FFDA89;scrollbar-arrow-color:red;scrollbar-track-color:#FAEBD7;border-width:1px;line-height:9pt;border-color:lightgray; border-width:2px; background-color:#FFFFFF;'></textarea></div></td></tr><tr><td><input type='hidden' name='id' value ="+id+">Name: <input type='text' size='15' name='name' >&nbsp;&nbsp;&nbsp;<input type='submit' name='Sub"+obj+"' style='border-color:lightgray;background-color:#FFFFEE;' value='Submit'></td></tr></table></form></div><hr />";

document.getElementById(obj).innerHTML=textstring;
//document.getElementById(obj).style.visibility = "visible";
//document.getElementById(r).rows=40;
//document.getElementById(r).cols=10;
}

function play_chapter(title,chapter) {
Mediaplayer1.dvd.chapterplay(title,chapter);
}

// goes back to last page
function go_back(){
  if (is_IE){
    history.go(-1);
  }
  else{
    back();
  }
}


