
//<!-- Begin
function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function CheckCSS(){

	if(location.hostname.match('singlesource') || location.search.match('singlesource')) {
		//document.getElementsByTagName("head")[0].appendChild('<link media="screen" href="styles/screen_singlesource.css" rel="stylesheet" type="text/css" />')
		//$('head').append('<link media="screen" href="../../styles/screen_singlesource.css" rel="stylesheet" type="text/css" />');
		loadjscssfile('../../styles/screen_singlesource.css', 'css');
	}else{
		//document.getElementsByTagName("head")[0].appendChild('<link media="screen" href="styles/screen_bds.css" rel="stylesheet" type="text/css" />')
		//$('head').append('<link media="screen" href="../../styles/screen_bds.css" rel="stylesheet" type="text/css" />');
		loadjscssfile('../../styles/screen_bds.css', 'css');
	}
}

	function wclose(){
		window.top.close();
		window.close();
	}

	function closedoc () {
		parent.close() ; 
		return;
	}
	function printWindow(){
	   bV = parseInt(navigator.appVersion)
	   if (bV >= 4) window.print()
	}
	function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=460,height=400,left = 290,top = 262');");
	}
// End -->

//<!-- Begin
	function openWindow(theURL, theName, width, height)
	{
		var theWindow = window.open(theURL , ""+theName+"" ,"width=" + width + ",height="+ height + ",toolbar=no,directories=0,menubar=no,status=no,resizable=1,location=0,scrollbars=1,copyhistory=0,alwaysRaised=yes");
		this.title = theName;
		
	}
	
// End -->

//<!-- Begin
function addOption(){
	// allows arguments to be string or select box
	//second argument if exists contains existing string for appending
	var strList = "";
	if (arguments[1])
		strList = arguments[1] + ' ';	
	if (arguments[0].options) {
		for (i=0;i<arguments[0].options.length;i++){
			if (arguments[0].options[i].selected){
				if (!String(strList).match(arguments[0] + ' '))
				strList = strList + arguments[0].options[i].value + ' '
				}
		}
	}	
	else{
		if (!String(strList).match(arguments[0] + ' '))
		strList = strList + arguments[0] + ' ';
	}
	var intLen = String(strList).length
	if (String(strList).substring(intLen,intLen-1)==' ')
		strList = String(strList).substring(0,intLen-1);
	return strList;
}
// End -->

//<!-- Begin
function SetDates(){
	// puts date range in order of txt box list supplied
	//ie yyyymmdd ; yyyymmdd
	var s= '';
	if (arguments.length == 5){
		s = arguments[0].value + arguments[1].value + ':' + arguments[2].value + arguments[3].value;
		arguments[4].value = s;
	}
	else if(arguments.length == 3) {
		s = arguments[0].value + ':' + arguments[1].value ;
		arguments[2].value = s;
	}
}

// End -->

//<!-- Begin Highlighting code...
	var times = 0;
	var regex = false;
	var phrase = false;
	var cases = false;
	function hex( n ) { return ( n<16 ? '0' : '' ) + n.toString(16); }
	function highlight( s, o ) {
	  if( !s ) { return 0; }
	  s = s.replace(/\s\w\s/g, ' ');
	 var d = document;
	  if( !regex ) { s = s.replace( /([\\|^$()[\]{}.*+?])/g, '\\$1' ); }
	  if( /^\s*$/.test(s) ) { return 0; }
	  if( !phrase ) { s = s.split( /\s+/ ).join( '|' ); }
	  o = [ o || d.documentElement || d.body ];
	  var r = new RegExp( s, cases ? 'g' : 'gi' ),
	    h = d.createElement('span'), i = 0, j, k, l, m, n=0, t;
	  h.style.color = '#000';
	  h.style.backgroundColor = '#cfcfcf';
	
	  times++;
	  do {
	    m = o[i];
	    if( m.nodeType===3 ) {
	      r.lastIndex = 0;
	      l = r.exec(m.nodeValue);
	      if( l !== null ) {
	        k = l[0].length;
	        if( r.lastIndex > k ) {
	          m.splitText( r.lastIndex - k );
	          m = m.nextSibling;
	        }
	        if( m.nodeValue.length > k ) {
	          m.splitText(k);
	          o[i++] = m.nextSibling;
	        }
	        t = h.cloneNode( true );
	        t.appendChild( d.createTextNode( l[0] ) );n++;
	        m.parentNode.replaceChild( t, m );
	      }
	    } else {
	      j = m.childNodes.length;
	      while (j) { o[i++] = m.childNodes.item(--j); }
	    }
	  } while(i--); return n;
	}

	function unhighlight( s, o ) {
	 var d = document;
	 o = o || d.documentElement || d.body;
	 s = s.replace(/([\\|^$()[\]{}.*+?])/g, '\\$1');
	 var a = o.getElementsByTagName('span'), i = a.length, j,
	  re = new RegExp( '^' + s + '$', 'i' );
	 while(i--) {
	  j = a[i].firstChild;
	  if( j ) {
	   if( j.nodeType===3 && re.test( j.nodeValue ) ) {
	    a[i].parentNode.replaceChild( document.createTextNode( j.nodeValue ), a[i] );
	   }
	  }
	 }
	 return false;
	}
// End -->

//<!-- Begin Validation code...
function svalidate() {
	var x = document.forms[1].elements;
	var blob = '';
	// loop through everything and check it
	for (var i=0;i<x.length;i++)
	{
		var sreg = /author|contributor/ig;
		if (sreg.test(x[i].value)){
			var reg = /\,/g;
			x[i+1].value = x[i+1].value.replace(reg, '');
		}
		var sreg = /dewey/ig;
		if (sreg.test(x[i].value)){
			var reg = /\W/g;
			x[i+1].value = x[i+1].value.replace(reg, '');
		}
	}
	//alert(blob);	
}
// End -->

//<!-- Imitate carrige Return
function checkEnter(e){ 
	
	var characterCode = '';
	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}
	if(characterCode == 13){ 
		document.frmSearch.submit();
		return false;
	}
	else{
		return true;
	}
}

// End -->

//<!-- 

function hov(loc,cls){
   if(loc.className){
      loc.className=cls;
	  }
}
// End -->

function ToggleThis(MyId){

	if(document.getElementById(MyId).style.display == 'none'){ 
		new Effect.BlindDown(MyId, {duration: 0.6});
	}else{
		new Effect.BlindUp(MyId, {duration: 0.1});
	}
}

function copy(text2copy) {
	alert("Copying the following text to the Clipboard:\n\n" + text2copy + "\n");
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="/artism/admin/include/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	document.getElementById(flashcopier).innerHTML = divinfo;
  }
}

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=(xpos-400)+"px"
subobj.style.top=(ypos-115)+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}