// Flash embedding for validation
// -----------------------------------------------------------------
//medis-center and news-ticker flashVar variables
var mediaCenter = "bandwidth=<?=$bandwidth?>&video=<?=$video?>"
var newsTicker = "location="+ window.location
//media-center and news-ticker flashVar variables
function printFlash(source, width, height, id, bg_color, flashVars) {
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
document.write('width="'+width+'" height="'+height+'" id="'+id+'" align="middle" />');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name=flashVars value="'+flashVars+'" />');
document.write('<param name="movie" value="'+source+'" />');
document.write('<param name="menu" value="false" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="'+bg_color+'" />');
document.write('<embed src="'+source+'" flashVars="'+flashVars+'" wmode="transparent" menu="false" quality="high" bgcolor="'+bg_color+'" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" ');
document.write('allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}

// opens new window
// -----------------------------------------------------------------
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin()
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=yes,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	if (type == "console") tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}


// use this function when popping up a media-center or media-center-lite instead of popUpWIn
function popUpSWF(url, type, Width, Height, arg1, arg2){
	tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+Width+",height="+Height+",left=0,top=0";
	if(type == "mcl"){
		newWindow = window.open(url+"?bandwidth="+arg1+"&video="+arg2, 'newWin', tools);
	}
	if(type == "bna"){
		newWindow = window.open(url+"?proceedure="+arg1+"&case="+arg2, 'newWin', tools);
	}
	newWindow.focus();
}


// clears and replaces text in form input fields and textareas
// -----------------------------------------------------------------
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}


// Son-Of-Sucker-Fish IE Hack
// -----------------------------------------------------------------
sfHover = function() {
  var sfEls = document.getElementById("nav").getElementsByTagName("LI");
  for (var i=0; i < sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
      this.className+=" sfhover";
    }
    sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    }
  }
 }
 if (window.attachEvent) window.attachEvent("onload", sfHover);



 // Form Validation Start
function Validate(){
	var bitErr = false;
	var bitErrEmail = false;
	var reqField = "";
	var radio_choice = false;
	
	for (counter = 0; counter < document.contact_main.order.length; counter++) {
		if (document.contact_main.order[counter].checked) radio_choice = true; 
	}
	
	if (!radio_choice){ bitErr = true; reqField += "- Loose Change VCD Edition\n";}
	if (document.contact_main.name.value == "") { bitErr = true; reqField += "- Name\n"; }
	if (document.contact_main.address.value == "") { bitErr = true; reqField += "- Shipping Addres\n"; }
	if (document.contact_main.city.value == "") { bitErr = true; reqField += "- City\n"; }
	if (document.contact_main.zip.value == "") { bitErr = true; reqField += "- Zip Code\n"; }
	if (document.contact_main.state.value == "") { bitErr = true; reqField += "- State/Province\n"; }
	if (document.contact_main.country.value == "") { bitErr = true; reqField += "- Country\n"; }
	if (document.contact_main.details.value == " email") { bitErr = true; bitErrEmail = true; }
	if (document.contact_main.details.value.indexOf("@") == -1) { bitErr = true; bitErrEmail = true; }
	if (document.contact_main.details.value.indexOf(".") == -1) { bitErr = true; bitErrEmail = true; }
	
	if (bitErrEmail){
		reqField += "- Email (Use a valid email address.)\n";
	}
	if (bitErr){
		alert("Please fill out the following required information:\n"+reqField);
		return false;
	}
	
	document.contact_main.submit();
}
// Form Validation End
