//------------------- OPEN NEW WINDOW -------------------//



// generic 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();
}

// video window //

function videopop(url) {

	var screenPosX, screenPosY;

	screenPosX = (screen.availWidth - 349) / 2;

	screenPosY = (screen.availHeight - 378) / 2;

  window.open(url,'bna','width=349, height=378, resizable=1,scrollbars=yes,menubar=no,directories=0,status=0,copyhistory=0,minimise=no,maximise=no, screenX=' + screenPosX + ', screenY=' + screenPosY + '');

}


//<![CDATA[

//-----------------------------------------------------
// toggles display style of object w/ specified id
  function toggleDisplay(obj_id,vis)
  {
    if (document.getElementById){
      var obj = document.getElementById(obj_id);
	  if (vis!=null) {
		var state = (vis ? 'block' : 'none');
	  } else {
		  if (obj.style.display == '' || obj.style.display == 'none'){
			var state = 'block';
		  } else {
			var state = 'none';
		  }
	  }
      obj.style.display = state;
    }
  }

//-----------------------------------------------------
// cssjs() - CSS/DOM className interaction function
//   a      - action to perform
//   obj_id - id of object to modify
//   c1     - name of first class
//   c2     - name of second class 
  function cssjs(a,obj_id,c1,c2)
  {
    if (document.getElementById) {
      var obj = document.getElementById(obj_id);
      if (obj) {
        switch (a){
          case 'swap':
            obj.className = (cssjs('check',obj_id,c1) ? obj.className.replace(c1,c2) : obj.className.replace(c2,c1));
          break;
          case 'add':
            if(!cssjs('check',obj_id,c1)){obj.className+=obj.className?' '+c1:c1;}
          break;
          case 'remove':
            var rep=obj.className.match(' '+c1)?' '+c1:c1;
            obj.className=obj.className.replace(rep,'');
          break;
          case 'check':
            return new RegExp('(.*)'+c1+'(.*)').test(obj.className);
          break;
        }
      }
    }
  }

//]]>


//------------------- for clearing and replacing 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 }

}









//------------------- ADD BOOKMARK -------------------//

function addBookmark(title,url) {   

     if (window.sidebar) {   

          window.sidebar.addPanel(title, url,"");   

     } else if( document.all ) {   

          window.external.AddFavorite( url, title);   

     } else if( window.opera && window.print ) {   

          return true;   

     }   

}

//------------------- Expandable DIV -------------------//

function function1Name(idVariable){
//display the section if it's not displayed; hide it if it is displayed
if (idVariable.style.display=="none"){idVariable.style.display=""}
else{idVariable.style.display="none"}
}
function function2Name(idVariable){
//remove the section when user clicks in the opened DIV
if (idVariable.style.display==""){idVariable.style.display="none"}
}

function doSection (secNum){
//display the section if it's not displayed; hide it if it is displayed
if (secNum.style.display=="none"){secNum.style.display=""}
else{secNum.style.display="none"}
}

function noSection (secNum){
//remove the section when user clicks in the opened DIV
if (secNum.style.display==""){secNum.style.display="none"}
}

//------------------- Ene Expandable DIV -------------------//


//------------------- Flash Script -------------------//
function printFlash(source, width, height, id, bg_color) {
	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="movie" value="'+source+'" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="'+bg_color+'" />');
	document.write('<embed src="'+source+'" 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>');
}



function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

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 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();
}