﻿// JScript File
function Movie2(movie)
{
	var e = document;
	var ext = movie.substring(movie.length-3,movie.length).toLowerCase(); 
    var width = '352';
    var height = '45'
	
	if (ext == 'mpg' || ext == 'avi' || ext == 'mov' || ext == 'wmv' || ext == 'swf') {
	    width = '352';
	    height = '285';
	}

	if (ext == 'mpg' || ext == 'avi' || ext == 'mov' || ext == 'mp3' || ext == 'mid' || ext == 'wmv' || ext == 'wma') {
        e.write("<object classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' width=" + width + " height=" + height + " style='border: 2px solid #cccccc'>" + "\n");
        e.write("<param name=URL value='" + movie + "'><param name='wmode' value='opaque' />" + "\n");
        e.write('<PARAM name="autoStart" value="false">' + '\n'); 
        e.write('<PARAM name="rate" value="1">' + '\n');
        e.write('<PARAM name="balance" value="0">' + '\n'); 
        e.write('<PARAM name="enabled" value="true">' + '\n');
        e.write('<PARAM name="enabledContextMenu" value="true">' + '\n'); 
        e.write('<PARAM name="fullScreen" value="false">' + '\n');
        e.write('<PARAM name="playCount" value="1">' + '\n');
        e.write('<PARAM name="volume" value="50">' + '\n');
        e.write("<embed src='" + movie + "' quality=high width=" + width + " height=" + height + "  style='border: 2px solid #cccccc'>" + "\n");
        e.write("</embed></object>" + "\n");
	}
	
    else if (ext == 'swf') {
	    e.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width=" + width + " height=" + height + " style='vertical-align: top'>" + "\n");
	    e.write("<param name=movie value='" + movie + "'><param name='wmode' value='opaque' /><param name=quality value=high>" + "\n");
	    e.write("<embed src='" + movie + "' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=" + width + " height=" + height + " style='vertical-align: top'>" + "\n");
	    e.write("</embed></object>" + "\n");
    }

}


function PopImg (which) {
	var url = '/ViewImg2.asp?StyleCode=148361&moreview=&pic='+which;
	showPopup (url, 'ViewPhoto', 550, 520);
}


function DisplayReview(val) {
	if (document.getElementById){
		document.getElementById(val).style.display = 'block';
	}
	else
		return true;
}

function HideReview(val) {
	if (document.getElementById){
		document.getElementById(val).style.display = 'none';
	}
	else
		return true;
}

function HighLight(ID) {
	if (document.getElementById){
        document.getElementById(ID).className = 'HighLight';
        
	}
	else
		return true;


}


//**************************************************************************************************************************
function changeCase(frmObj) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
	for (index = 0; index < strLen; index++)  {
	if (index == 0)  {
	tmpChar = tmpStr.substring(0,1).toUpperCase();
	postString = tmpStr.substring(1,strLen);
	tmpStr = tmpChar + postString;
	}
	else {
	tmpChar = tmpStr.substring(index, index+1);
	if (tmpChar == " " && index < (strLen-1))  {
	tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
	preString = tmpStr.substring(0, index+1);
	postString = tmpStr.substring(index+2,strLen);
	tmpStr = preString + tmpChar + postString;
	         }
	      }
	   }
	}
	frmObj.value = tmpStr;
}

//**************************************************************************************************************************
function ignoreSpaces(string,dlmtr) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(dlmtr);
	for(i = 0; i < splitstring.length; i++)
	temp += splitstring[i];
	return temp;
}

//**************************************************************************************************************************
function trimLeadingSpaces(field){
	while(''+field.value.charAt(0)==' ') 		
		field.value=field.value.substring(1,field.value.length);
}



//**************************************************************************************************************************
function checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { alert(newURL); document.MM_returnValue=false; }
}


//**************************************************************************************************************************
function validate(field) {
	var valid = "0123456789-zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP() ";
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") {
		alert("Phone Number can contain only :\n A-Z \n a-z\n 0-9\n - ( )");
		return true; 
		}
	if( (document.forms[0].country.options[document.forms[0].country.selectedIndex].value!="1231:USA::UNITED STATES"))
	return false;
	usphone=ignoreSpaces(field.value," ");
	usphone=ignoreSpaces(usphone,"-");
	usphone=ignoreSpaces(usphone,")");
	usphone=ignoreSpaces(usphone,"(");
	
	if (field.value.substring(0,1)=="1")
		if (usphone.length==11)
			return false;
		else{
			alert("Phone Number should be a 11 digit Number");
			return true;
		}
	else
		if (usphone.length==10)
			return false;
		else{
			alert("Phone Number should be a 10 digit Number");
			return true;
		}
}



//**************************************************************************************************************************
function CharCheck(field) {
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  var checkStr = field.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    return (false);
  }
  
  return true;
}






//**************************************************************************************************************************
function emailCheck (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
		
	if (matchArray==null) {
	//alert("Email address seems incorrect (check @ and .'s)");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
		
		
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	//alert("Ths username in email address contains invalid characters.");
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	//alert("Ths domain name in email address contains invalid characters.");
	return false;
	   }
	}
	if (user.match(userPat)==null) {
	//alert("The username in email address doesn't seem to be valid.");
	return false;
	}
		
		
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		
		
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	//alert("Destination IP address in email is invalid!");
	return false;
	   }
	}
	return true;
	}
		
		 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	//alert("The domain name in email address does not seem to be valid.");
	return false;
	   }
	}
		
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	//alert("The email address must end in a well-known domain or two letter " + "country.");
	return false;
	}
		
		
	if (len<2) {
	//alert("The email address is missing a hostname!");
	return false;
	}
		
	return true;
}



//**************************************************************************************************************************
function showDlg(winDlg, DlgName, H, W) {
	// Dialog URL
	var strPage = winDlg;
	strAttr = "status:no;dialogWidth:"+ W +"px;dialogHeight:"+ H + "px;help:no";' '

	// run the dialog that implements this type of element
	var strURL = showModalDialog(strPage, DlgName, strAttr);
	strURL.focus();
 
}

//**************************************************************************************************************************
function showPopup(winDlg, DlgName, H, W, Scroll) {
  var mW = (window.screen.width - W)/2;
  var mH = (window.screen.height - H)/2;
  if (DlgName == 'SO') {
	mH = mH-100;
	}
  
  fs2 = window.open('', DlgName, 'width='+W+',height='+H+',scrollbars='+Scroll+',location=0,status=0,toolbar=0,resizable=1,titlebar=0,left='+mW+',top='+mH);
  if (fs2 != null) {
    if (fs2.opener == null) {
      fs2.opener = self;
      self.location.href=document.location;
   }
   
   fs2.location.href = winDlg;
   fs2.focus();
  
  }
	fs2.creator=self; 
}


//**************************************************************************************************************************
function button_over(eButton)	{
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.border = "darkblue 1px solid";
}

//**************************************************************************************************************************
function button_out(eButton) {
	eButton.style.backgroundColor = "buttonface";
	eButton.style.border = "buttonface 1px solid";
}

//**************************************************************************************************************************
function button_down(eButton) {
	eButton.style.backgroundColor = "#8494B5";
	eButton.style.border = "darkblue 1px solid";
}

//**************************************************************************************************************************
function button_up(eButton) {
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.border = "darkblue 1px solid";
	eButton = null; 
}


//**************************************************************************************************************************
function winopen(URL){
	var targeturl=URL;
	newwin=window.open("","MAIN","scrollbars=0, resizable=0,toolbar=0,top=0,left=0")
	if (document.all)	{
		newwin.resizeTo(screen.width,screen.height-27)
	//	newwin.resizeTo(1024, 764)
	}
	newwin.location=targeturl
}


//**************************************************************************************************************************
function FormatPhone (obj) {
	var str = obj.value;
	var strOut;
	if (str.length == 10) {
		if (isNaN(str)) {
		alert('Please enter numeric characters.');
		obj.select();
		obj.focus();
		}
		else {
			strOut = '('+str.substring(0,3)+')'+str.substring(3,6)+'-'+str.substring(6,10);
			obj.value = strOut;
		}
	}
}







//**************************************************************************************************************************
function CheckField(obj) {
	if (obj.value == '') {
		alert(obj.name+' is missing, enter ' + obj.name + '.');
		obj.focus();
		return false;
	}

	return true;
}



//**************************************************************************************************************************
function FormatCurrency(number) {
    var x = (Math.round(number*100))/100;
    return (x == Math.floor(x)) ? x + '.00' : ((x*10 == Math.floor(x*10)) ? x + '0' : x);
}


//**************************************************************************************************************************
function round(number,X) {
// rounds number to X decimal places, defaults to 2
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

//**************************************************************************************************************************
function replace(originalString,searchText,replaceText) { 
	var strLength = originalString.length; 
	var txtLength = searchText.length; 
	if ((strLength == 0) || (txtLength == 0)) 
	{ return originalString; } 
	var i = originalString.indexOf(searchText); 
	if ((!i) && (searchText != originalString.substring(0,txtLength))) 
	{ return originalString; } 
	if (i == -1) 
	{ return originalString; } 
	var newstr = originalString.substring(0,i) + replaceText; 
	if (i+txtLength < strLength) 
	{ newstr += replace(originalString.substring(i+txtLength,strLength),searchText,replaceText); } 
	return newstr;
} 



//**************************************************************************************************************************
function isDate(dateStr) {

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{2})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Please enter date as either mm/dd/yy or mm-dd-yy.");
return false;
}

month = matchArray[1]; // p@rse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}




//**************************************************************************************************************************
function swap(Cell, Class) {
	//var sel = document.frm.sel.value;
	//if (sel != Cell.id) {
		//alert (Cell.id);
		Cell.className=Class;
	//}
}

