// MW: 25/4/2007
// Reset asp.net form script
function resetForm() {
    // This will reset file field
    document.forms('aspnetForm').reset();
    var str;
    var elem = document.getElementById('aspnetForm').elements;
    // Loop through elements and reset
    for (var i = 0; i < elem.length; i++) {
        if (elem[i].getAttribute("type") == "checkbox" || elem[i].getAttribute("type") == "radio") { document.getElementById(elem[i].name).checked = false; }
        if (elem[i].getAttribute("type") == "select-one" || elem[i].getAttribute("type") == "select-multiple") { document.getElementById(elem[i].name).selectedIndex = 0; }
        if (elem[i].getAttribute("type") == "password" || elem[i].getAttribute("type") == "text" || elem[i].getAttribute("type") == "textarea") { document.getElementById(elem[i].name).innerText = ""; }
        // Output element details if required
        //str += elem[i].name + " - " + elem[i].type + "<br>";
    }
     // Find first input field and set focus
     for (i = 0; i < elem.length; i++) {
        if (elem[i].getAttribute("type") == "checkbox" || elem[i].getAttribute("type") == "select-one" || elem[i].getAttribute("type") == "text" || elem[i].getAttribute("type") == "textarea") {
            document.getElementById(elem[i].name).focus();
            break;           
        }
    }
    // Place <div id="theElements"></div> on page to display elements
    //document.getElementById("theElements").innerHTML = str;
    return true;
}

// Reset asp.net form script
function resetControls() {
    // This will reset file field
    document.forms('aspnetForm').reset();
    var str;
    var elem = document.getElementById('aspnetForm').elements;
    // Loop through elements and reset
    for (var i = 0; i < elem.length; i++) {
        if (elem[i].getAttribute("type") == "checkbox" || elem[i].getAttribute("type") == "radio") { document.getElementById(elem[i].name).checked = false; }
        if (elem[i].getAttribute("type") == "select-one" || elem[i].getAttribute("type") == "select-multiple") { document.getElementById(elem[i].name).selectedIndex = 0; }
        if (elem[i].getAttribute("type") == "password" || elem[i].getAttribute("type") == "text" || elem[i].getAttribute("type") == "textarea") { document.getElementById(elem[i].name).innerText = ""; }
    }
    return true;
}

// MW: 26/4/2007
// Set focus to first text input field on form
function focusForm() {
    var elem = document.getElementById('aspnetForm').elements;
     // Find first input field and set focus
     for (i = 0; i < elem.length; i++) {
        if (elem[i].getAttribute("type") == "text" || elem[i].getAttribute("type") == "text-area") {
            document.getElementById(elem[i].name).focus();
            break;           
        }
    }
}

function popupWindow(referenceHTML, w, h, scroll, resize) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		windowProperties = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",scrollbars=" + scroll + ", resizable=" + resize + "";
		reference = window.open(referenceHTML, 'refName', windowProperties)
		if(parseInt(navigator.appVersion) >= 4){reference.window.focus();} 
	}
	
function showStatus(sMsg) {
    window.status = sMsg;
    return true;
}

function FlashControlSSL(ClsId,Url,Width,Height,AutoStart)
{
	document.write('<object classid="' + ClsId + '" codebase="" width="' + Width + '" height="' + Height + '">')
	document.write('<param name="movie" value="' + Url + '">')							  
	document.write('<param name="wmode" value="Transparent">')
	document.write('<param name="quality" value="High">')
	document.write('<param name="menu" value="false">')
	document.write('<embed src="' + Url + '" quality="high" pluginspage="" width="' + Width + '" height="' + Height + '" wmode="Transparent" ></embed>')
	document.write('</object>')
}

//Play "Deal of the Week" Video Link
function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject("HomeVideo");
	flashMovie.TPlay("/JavaTalk");
}

//Control for embedding flash
function FlashControl(ClsId,Url,Width,Height,AutoStart)
{
	document.write('<object classid="' + ClsId + '" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + Width + '" height="' + Height + '">')
	document.write('<param name="movie" value="' + Url + '">')							  
	document.write('<param name="wmode" value="Transparent">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="menu" value="false">')
	document.write('<embed src="' + Url + '" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '" wmode="Transparent" menu="False"></embed>')
	document.write('</object>')
}

//Control for embedding flash with Javascript communication
function FlashControl2(ClsId,Url,Width,Height,AutoStart,ID)
{
	document.write('<object classid="' + ClsId + '" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + Width + '" height="' + Height + '" id="' + ID + '">')
	document.write('<param name="movie" value="' + Url + '">')							  
	document.write('<param name="wmode" value="Transparent">')
	document.write('<param name="quality" value="high">')
	document.write('<param name="menu" value="false">')
	document.write('<embed src="' + Url + '" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '" wmode="Transparent" menu="False" name="' + ID + '" swLiveConnect="true"></embed>')
	document.write('</object>')
}

//Flash Java communication
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}