// JavaScript Document
function show_box(boxid,frame_name,srcfile,w,h,scrolling){    
    var iframer = "<center><iframe name=" + frame_name + " src='" + srcfile + "' width=" + w + " height=" + h + " frameborder=0 scrolling=" + scrolling + " allowautotransparency=false></iframe></center>";
	parent.window.document.getElementById(boxid).innerHTML = iframer;}

function showthis(spanid,msgtoshow,spanclass){parent.window.document.getElementById(spanid).innerHTML ="<span class=" + spanclass + ">" + msgtoshow + "</span>";}
function showlocal(spanid,msgtoshow,spanclass){document.getElementById(spanid).innerHTML ="<span class=" + spanclass + ">" + msgtoshow + "</span>";}
function Replacer(spanid,msgtoshow){document.getElementById(spanid).innerHTML = msgtoshow;}
function Replace_in_parent(spanid,msgtoshow){parent.window.document.getElementById(spanid).innerHTML = msgtoshow;}
function change_value(this_id,thisvalue){document.getElementById(this_id).value = thisvalue;}
function change_value_in_parent(this_id,thisvalue){parent.window.document.getElementById(this_id).value = thisvalue;}
function get_value(this_id){return removeHTMLTags(document.getElementById(this_id).value);}
function toTop(thislayer, action, z){var lref;if(parent.window.document.getElementById && (lRef=parent.window.document.getElementById(thislayer))){lRef.style.visibility=action?'visible':'hidden'; lRef.style.zIndex=z;}
if(action=="false")parent.window.document.getElementById(thislayer).style.visibility='hidden';}
function Closeall_showone(div_name,last_div,show_this_one){
var temp =''; for(var i=1;i<=last_div;i++){temp = div_name + i; toTop(temp,'false',0);}toTop(show_this_one,'true',1);}
function change_image(this_id,to_this_image){parent.window.document.getElementById(this_id).src = to_this_image;}
function Closeall_showone_new(div_name,starter,last_div,show_this_one){
var temp =''; for(var i=starter;i<=last_div;i++){temp = div_name + i; toTop(temp,'false',0);}toTop(show_this_one,'true',1);}
function wait_open(thiswindow){toTop('Waiting','true',1); setTimeout("toTop('Waiting','false',0); toTop('Domains','true',1)",3000); window.scrollTo(200,100);}
function change_over(thisframe,tothis){document.getElementById(thisframe).src=tothis;}
function checkbox_checked(thisid){if(!parent.window.document.getElementById(thisid).checked){return 'N';}else{return 'Y';};}
function change_over_in_parent(thisframe,tothis){parent.window.document.getElementById(thisframe).src=tothis;}
function changedimension(thisframe,w,h) {parent.window.document.getElementById(thisframe).width=w; parent.window.document.getElementById(thisframe).height=h;}
function fetch_dropdown_value(thisid){var temp = parent.window.document.getElementById(thisid).selectedIndex; temp = parent.window.document.getElementById(thisid).options[temp].value; return temp;}
function moveit(thislayer,tohere,showhide){window.document.getElementById(thislayer).style.left=tohere;if(showhide > 0){toTop(thislayer, true, 1);}else{toTop(thislayer, false, 0);}}
function moveheight(thislayer,tohere,showhide){window.document.getElementById(thislayer).style.top=tohere;if(showhide > 0){toTop(thislayer, true, 1);}else{toTop(thislayer, false, 0);}}
function checbox(thisid){if(document.getElementById(thisid).checked){return "Y"}}

function removeHTMLTags(thisstuff){var strInputCode = thisstuff;
 	 	processed = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
 		 	return (p1 == "lt")? "" : "";
 		});
 		processed = processed.replace(/<\/?[^>]+(>|$)/g, " ");
		processed = replaceAll(processed,"'", ""); processed = replaceAll(processed,'"', '');processed = replaceAll(processed,'(', '');
		processed = replaceAll(processed,'&', ''); processed = replaceAll(processed,')', '');
		return processed;
 	}	
	
function replaceAll(fromthis, search_for, replace_with) {  var idx = fromthis.indexOf(search_for);
  while ( idx > -1 ) {
  fromthis = fromthis.replace(search_for,replace_with); 
  idx = fromthis.indexOf(search_for);}return fromthis;}

//call the next function to check if selected file is .jpg or not
function fileselected()
{ var temp = document.getElementById('Photo').value;
		if (temp.match(/\.(jpeg|jpg)$/i, "")){
			//selected file is okay so show submit button (since we cannot autosubmit multi-part form)
			/*if (browsername.indexOf("Microsoft")!=-1) {
			var tempb = "<input type=submit value=\"Submit \" class=textbox onclick=\"javascript:showLayer('working');\">"
			document.getElementById('buttcell').innerHTML = tempb;}*/
			document.getElementById('buttcell').style.visibility = "visible";
			showlocal('showmsg','<span id=showmsg class=Blueheader><img src=Images/lbulb.gif alt=\'Observe max image size\' width=17 height=19>Max size: 10Mb each. Select only .jpg images</span>','Blueheader');}
		else{document.getElementById('buttcell').style.visibility = "hidden"; showlocal('showmsg','<span id=showmsg class=Blueheader><img src=Images/Rbulb.gif alt=\'Only .jpg or .jpeg files please\' width=17 height=19> Only .jpg or .jpeg files please!</span>','Blueheader');}
}

//call next function to change opacity of individual image
function changeOpac(opacity, id) {
	var object = parent.window.document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

//call next function to switch the style sheet for the page
function switch_style (css_title)
{ var i, link_tag ;
  for (i = 0, link_tag = document.getElementsByTagName("link") ;
    i < link_tag.length ; i++ ) {
    if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) &&
      link_tag[i].title) {
      link_tag[i].disabled = true ;
      if (link_tag[i].title == css_title) {
        link_tag[i].disabled = false ;
      }
    }
  }
}

function wininvisible(){
	//tiny invisible window
	self.moveTo(9000,9000);
	self.resizeTo(1,1);
	self.focus(); }
	
function winclose(){
	self.moveTo(0,0);
	self.resizeTo(screen.availWidth,screen.availHeight);
	self.focus(); window.close(); }
		
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function browsername(){var browsername=navigator.appName; if (browserName=="Microsoft Internet Explorer") {browsername = "Microsoft"}else{browsername = "NS"} return browsername;}

function browsercheck(writethis,thisbrowser,else_write_this){
	browsername=navigator.appName;
	if (browsername.indexOf(thisbrowser)!=-1) {window.document.write(writethis)}else{window.document.write(else_write_this);}}

function cursorPosition(e) { e = e || window.event; var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) { cursor.x = e.pageX;  cursor.y = e.pageY; } 
    else { var de = document.documentElement; var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    } return cursor; }
	
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);
  window.document.MM_returnValue = (errors == '');
}
//the three are required by the message center
function deletethis(thisone,displayer){
	var thismail = "Delete-Message.asp?id=" + thisone;
	window.open (thismail,"Deleter");
	window.document.getElementById(displayer).innerHTML = "** Message deleted **"
}
  
function openWindow(winName,width,height) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

    window.open('Blank.htm',winName,'resizable=1,scrollbars=1,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}
function opentheWindow(filename,winName,width,height) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

    window.open(filename,winName,'resizable=1,scrollbars=1,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}
	function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);}
