
window.onload = function() {

  // Set default status
  window.defaultStatus = document.title;

  // Wire anchors with titleStatus() function
  for (i in anchors = document.getElementsByTagName("a")) {    
    try {
      anchors[i].addEventListener("mouseover", titleStatus, false)
    } catch (exception) {
      anchors[i].onmouseover = titleStatus
    }     
  }   

}


function titleStatus() {
  
  // Set default status to title attribute
  window.status = this.getAttribute("title");
  
  // Return
  return true;
  
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function detectRealPlayer(rv) {

  // Plugin src
  var src = "";
  var param = "";
  if ( rv == 1 || rv == 2 || rv == 3 ) {
    src = "src=\"http://www.rowtoncastle.com/vid/" + rv + ".rv\" ";
    param = "<param name=\"src\" value=\"http://www.rowtoncastle.com/vid/" + rv + ".rv\" />";  
  }
  
  // Flag if found
  var flag = false;
  
  //  Not IE
  if ( navigator.userAgent.indexOf("MSIE") == -1 ) {    
    
    // Get number of plugins
    numPlugins = navigator.plugins.length;    
    
    // Iterate them
    for (i = 0; i < numPlugins; i++) {    
      flag = true;
    }
    
    // Render HTML
    if (!flag) {
      
      document.writeln('<p>To access our video player you need the latest version of Real Player, click the button below to download it for free.</p>');
      document.writeln('<a href="http://switchboard.real.com/links/?btn=en/dwnld_88x31"><img src="/img/dwnld_88x31.gif" width="88" height="31" alt="Download RealPlayer" /></a>');
    
    } else {
      
      document.writeln('<p>                                                              ');
      document.writeln('  Use our video player to view clips of weddings held at Rowton Castle Hotel &amp; Restaurant.                ');
      document.writeln('</p>                                                              ');
      document.writeln('<ul>                                                              ');
      document.writeln('  <li>                                                            ');
      document.writeln('    <a href="/weddings/videos/1.php" title="Video Clip 1">                                  ');
      document.writeln('      The wedding of Susan &amp; Sean Jarvis                                        ');
      document.writeln('    </a>                                                          ');
      document.writeln('  </li>                                                            ');
      document.writeln('  <li>                                                            ');
      document.writeln('    <a href="/weddings/videos/2.php" title="Video Clip 2">                                  ');
      document.writeln('      The wedding of Julie &amp; Ben Houlson                                        ');
      document.writeln('    </a>                                                          ');
      document.writeln('  </li>                                                            ');
      document.writeln('  <li>                                                            ');
      document.writeln('    <a href="/weddings/videos/3.php" title="Video Clip 3">                                  ');
      document.writeln('      The wedding of Paula &amp; Tom Hallam                                        ');
      document.writeln('    </a>                                                          ');
      document.writeln('  </li>                                                            ');
      document.writeln('</ul>                                                              ');
      document.writeln('<div id="player">                                                        ');
      document.writeln('  <object id="playerVideo" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="352" height="288">            ');
      document.writeln('    <param name="autostart" value="true" />                                          ');
      document.writeln('    <param name="controls" value="imageWindow" />                                      ');
      document.writeln('    <param name="console" value="one" />                                          ');
      document.writeln('    ' + param + '                                                       ');
      document.writeln('    <embed ' + src + 'width="352" height="288" autostart="true" controls="imageWindow" console="one" />            ');
      document.writeln('  </object>                                                          ');
      document.writeln('  <object class="center" id="playerControls" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="352" height="26">  ');
      document.writeln('    <param name="autostart" value="true" />                                          ');
      document.writeln('    <param name="controls" value="ControlPanel" />                                      ');
      document.writeln('    <param name="console" value="one" />                                          ');
      document.writeln('    ' + param + '                                                       ');
      document.writeln('    <embed ' + src + 'width="352" height="26" autostart="true" controls="ControlPanel" console="one" />            ');
      document.writeln('  </object>                                                          ');
      document.writeln('</div>                                                            ');
      
    }  
      
  }
  
  // Windows IE
  if ( (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) ) {
    
    document.writeln('<script language="VBScript">                                                                            ');
    document.writeln('                                                                                          ');
    document.writeln('  On Error Resume Next                                                                              ');
    document.writeln('                                                                                          ');
    document.writeln('  Dim flag                                                                                    ');
    document.writeln('  flag = false                                                                                  ');
    document.writeln('                                                                                          ');
    document.writeln('  If (NOT IsNull(CreateObject("rmocx.RealPlayer G2 Control")) ) Then                                                        ');
    document.writeln('    flag = true                                                                                  ');
    document.writeln('  End If                                                                                      ');
    document.writeln('                                                                                          ');
    document.writeln('  Response.Write("Hello")                                                                                        ');
    document.writeln('                                                                                          ');
    document.writeln('<\/script>                                                                                    ');
    
  }

}