// JavaScript Document
function SWFDelegate(url,width,height,caption) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   objLink.setAttribute('rel','lightbox');
   objLink.setAttribute('title',caption);
   if(typeof width != 'undefined') {
      objLink.setAttribute('width',width);
   }
   if(typeof height != 'undefined') {
      objLink.setAttribute('height',height);
   }
   Lightbox.prototype.start(objLink);
}

function IncludeJavaScript(jsFile)
{
document.write('<script type="text/javascript" src="'
+ jsFile + '"></script>');
}

function pop_up_file(filename, tall, wide){
    var mywin = window.open(filename,'special','top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
}
function pop_up_file_scroll(filename, tall, wide){
    var mywin = window.open(filename,'special','top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
}
function pop_up_file_name(filename, tall, wide, name, scro){
	if(name != "") 
		pname = name;
	else 
		pname = 'special';
    var mywin = window.open(filename,pname,'top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars='+scro+',location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
}
/* AHAH Functions */
function pop_up_new(filename, tall, wide){
    var mywin = window.open(filename,'special','top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
	return false;
}
function pop_up_new_scroll(filename, tall, wide){
    var mywin = window.open(filename,'special','top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
	return false;
}
function pop_up_new_scroll_name(filename, tall, wide, name){
	if(name != "") 
		pname = name;
	else 
		pname = 'special';
    var mywin = window.open(filename,pname,'top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
	return false;
}
function pop_up_new_name(filename, tall, wide, name, scro){
	if(name != "") 
		pname = name;
	else 
		pname = 'special';
    var mywin = window.open(filename,pname,'top=20,screenx=20,left=20,screeny=20,width=' + wide + ',height=' + tall + ',buttons=no,scrollbars='+scro+',location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
	mywin.focus();
	return false;
}
/* End AHAH */
function emailFriend() { 

	emailWindow = window.open('http://www.scottevest.com/v3_popups/email_friend.shtml', 'emailWin',
	'top=30,screeny=30,left=30,screenx=30,width=620,height=600,resizable=yes,scrollbars=yes');	

	emailWindow.focus();
}

var userAgent = navigator.userAgent.toLowerCase();

// Figure out what browser is being used
var curr_browser = {
	version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
	safari: /webkit/.test( userAgent ),
	opera: /opera/.test( userAgent ),
	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

function do_mover_mout(id,img_url){
 	eval('document.'+id+'.src="'+img_url+'";');
}

 /*
 Pre-Load Image Function
 */
function global_newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 /*
 This is new and modified version of 'change_imgDiv(id)' function
 */
 function switch_div_content(id,idToShow,numOfLoop) {
	var eById = isGetElementByIdDefined();
	var ie4 = (document.all)? true:false;
	var ns6 = (!document.all && document.getElementById) ? true : false;
	var loopCount = parseInt(numOfLoop);
  
  if(eById){
  	document.getElementById(id).style.display = 'none';
	for(var i=2; i<=loopCount; i++){
		document.getElementById(id+i).style.display = 'none';
	}
	if(idToShow!=""){	
  		document.getElementById(idToShow).style.display = 'block';
	}
  }else if (ns6) {
  	document.getElementsByTagName("*").namedItem(id).style.display = 'none';
	for(var i=2; i<=loopCount; i++){
		document.getElementsByTagName("*").namedItem(id+i).style.display = 'none';
	}
	if(idToShow!=""){
    	document.getElementsByTagName("*").namedItem(idToShow).style.display = 'block';
	}
  }else if (ie4) {
  	document.all[id].style.display = 'none';
	for(var i=2; i<=loopCount; i++){
		document.all[id+i].style.display = 'none';
	}
	if(idToShow!=""){
  		document.all[idToShow].style.display = 'block';
	}	
  }
 }// End switch_div_content
 
 /*
 We re-use this function from old version ajax_functions.js
 */
 function isGetElementByIdDefined(){
	 if(typeof document.getElementById != 'undefined')
		return true;
	 else
		return false;
 }
 
 /* Validation */
function Trim(x) {
	var i;
	if (x.length == 0) {return "";};
	i = x.length - 1;
	while (x.substring(i,i+1) == " " && i > 0 )  {
		x = x.substring(0,i);
		i--;
	}
	if (x.length == 0) {return "";};
	while (x.substring(0,1) == " " && x != "" )  {
		x = x.substring(1,x.length);
		i++;
	}
	return x;
}// end Trim

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
}//echeck

// Encoding/Decoding functions
function encode_utf8( s ){  return unescape( encodeURIComponent( s ) );}
function decode_utf8( s ){  return decodeURIComponent( escape( s ) );}

function submitIt(form) {
var checkEmail = "@.";
var checkStr = form.rm_email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
var bad = "";
for (i = 0;  i < checkStr.length;  i++)
{
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkEmail.length;  j++)
     {
        if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
        if (ch == checkEmail.charAt(j) && ch == ".")
           EmailPeriod = true;
          if (EmailAt && EmailPeriod)
                  break;
          if (j == checkEmail.length)
                  break;
        }
      if (EmailAt && EmailPeriod)
      {
            EmailValid = true
            break;
        }
}
if (!EmailValid)
{
bad = bad + "\n    Please enter a valid Email Address.";
}
if (bad != "") {alert("Please fill in the following fields:"+bad +"\n"); return (false);}
return (true);
}

//CLEAR TEXT INSIDE FIELD
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
		theText.value = ""
	}
}

IncludeJavaScript('/media_new/javascripts/prototype.js');
IncludeJavaScript('/media_new/javascripts/effects.js');
IncludeJavaScript('/media_new/javascripts/lightwindow.js');
