function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.adminForm;
	var c = f.toggle.checked;

	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}

	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}

}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

function submitbutton(pressbutton) {
	submitform(pressbutton);
}
function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

function trim(a){
return a.replace(/(^ +| +$)/, "");
}


// JS Calendar
var calendar = null; // remember the calendar object so that we reuse
// it and avoid creating another

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
	cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
	cal.hide();			// hide the calendar

	// don't check mousedown on document anymore (used to be able to hide the
	// calendar when someone clicks outside it, see the showCalendar function).
	Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null; el = el.parentNode)
	// FIXME: allow end-user to click some link without closing the
	// calendar.  Good to see real-time stylesheet change :)
	if (el == calendar.element || el.tagName == "A") break;
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		calendar.callCloseHandler(); Calendar.stopEvent(ev);
	}
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.



function showCalendar(id) {
	var el = document.getElementById(id);
	if (calendar != null) {
		// we already have one created, so just update it.
		calendar.hide();		// hide the existing calendar
		calendar.parseDate(el.value); // set it to a new date
	} else {
		// first-time call, create the calendar
//selected
		var cal = new Calendar(true, null, selected, closeHandler);
		calendar = cal;		// remember the calendar in the global
		cal.setRange(1900, 2070);	// min/max year allowed
		calendar.create();		// create a popup calendar
	}
	calendar.sel = el;		// inform it about the input field in use
	calendar.showAtElement(el);	// show the calendar next to the input field

	// catch mousedown on the document
	Calendar.addEvent(document, "mousedown", checkCalendar);
	return false;
}




function getElementsById(sId)
 {
var outArray = new Array();	
	if(typeof(sId)!='string' || !sId){return outArray;};
	if(document.evaluate){var xpathString = "//*[@id='" + sId.toString() + "']"
		var xpathResult = document.evaluate(xpathString, document, null, 0, null);
		while ((outArray[outArray.length] = xpathResult.iterateNext())) { }
		outArray.pop();
	}
	else if(document.all)
	{
		
		for(var i=0,j=document.all[sId].length;i<j;i+=1){
		outArray[i] =  document.all[sId][i];}
		
	}else if(document.getElementsByTagName)
	{var aEl = document.getElementsByTagName( '*' );for(var i=0,j=aEl.length;i<j;i+=1){if(aEl[i].id == sId ){outArray.push(aEl[i]);};};};
	return outArray;
 }

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
	if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
	for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function exp_submit(a,b){
  document.adminForm.fullscreen.value=a;
  document.adminForm.compare.value=b;
  document.adminForm.submit();
}

function coll_submit(a,b,d,e){
  document.adminForm.fullscreen.value=a;
  document.adminForm.compare.value=b;
  document.adminForm.mode.value=d;
  document.adminForm.size.value=e;
  document.adminForm.submit();
}

function coll_find(a){
var form = document.adminForm;
  form.task.value='find';
  form.size.value='full';
  document.adminForm.submit();
//  if(form.sizea.value)
}

function coll_request(){
var form = document.adminForm;
  form.task.value='req';
  document.adminForm.submit();
//  if(form.sizea.value)
}

function coll_reject(){
var form = document.adminForm;
  form.task.value='reject';
  document.adminForm.submit();
//  if(form.sizea.value)
}

function submit_req(){
var form = document.adminForm;
  form.task.value='send';
  document.adminForm.submit();
//  if(form.sizea.value)
}

function popupWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function zoom(a){
        var w = 500;
        var h = 510;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no'
	win = window.open('popup/zoom.php?mdl='+a, 'win1', winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}

function getheight() {

MM_preloadImages('tpl/default_user/button6.gif',
                 'tpl/default_user/button6a.gif',
                 'tpl/default_user/button0.gif', 
                 'tpl/default_user/button0a.gif', 
                 'tpl/default_user/button1.gif', 
                 'tpl/default_user/button1a.gif', 
                 'tpl/default_user/button2.gif', 
                 'tpl/default_user/button2a.gif', 
                 'tpl/default_user/button3.gif', 
                 'tpl/default_user/button3a.gif', 
                 'tpl/default_user/button4.gif', 
                 'tpl/default_user/button4a.gif', 
                 'tpl/default_user/button5.gif', 
                 'tpl/default_user/button5a.gif', 
                 'tpl/default_user/button7.gif', 
                 'tpl/default_user/button7a.gif', 
                 'tpl/default_user/button8.gif', 
                 'tpl/default_user/button8a.gif', 
                 'tpl/default_user/button9.gif', 
                 'tpl/default_user/button9a.gif', 
                 'tpl/default_user/button10.gif', 
                 'tpl/default_user/button10a.gif', 
                 'tpl/default_user/about.gif', 
                 'tpl/default_user/abouta.gif' 
);

document.body.style.scrollbarBaseColor = '#000000';

 if(document.getElementById('about_text')){ document.getElementById('about_text').style.height =(document.documentElement.clientWidth*34/100)+"px";}
 if(document.getElementById('about_text12')){ document.getElementById('about_text12').style.height =(document.documentElement.clientWidth*35.6/100)+"px";}
 if(document.getElementById('about_text121')){ document.getElementById('about_text121').style.height =(document.documentElement.clientWidth*34/100)+"px";}
 if(document.getElementById('about_text34')){ document.getElementById('about_text34').style.height =(document.documentElement.clientWidth*35.6/100)+"px";}
 if(document.getElementById('test')){ 
   document.getElementById('test').style.height =(document.documentElement.clientHeight)+"px";
   document.getElementById('test').style.width =(document.documentElement.clientWidth)+"px";
 }
//  alert((document.getElementById('winter_new').style.height)+"px");
 if(document.getElementById('winter_new_1')){ document.getElementById('winter_new_1').style.height = document.getElementById('winter_new').style.height;}
// if(document.getElementById('winter_new_1')){ document.getElementById('winter_new_2').style.height =(document.documentElement.clientHeight)+"px";}
  i=(document.documentElement.clientHeight/42)+2;
 if(document.getElementById('reqtext')){ document.getElementById('reqtext').style.height =(document.documentElement.clientWidth*35.8/100)+"px";}
  i=(document.documentElement.clientHeight/42)+2;
 if(document.getElementById('about_text1')){ document.getElementById('about_text1').style.height =(document.documentElement.clientWidth*36/100)+"px";}
  i=(document.documentElement.clientHeight/37)+1; if(i>22){i=22};
 if(document.getElementById('caption')){document.getElementById('caption').style.font =" "+i+"px  tahoma";}
  i=(document.documentElement.clientHeight/65)+1; if(i>13){i=13};
  for(var k=0,j=getElementsById('capt_mini').length;k<j;k+=1){getElementsById('capt_mini')[k].style.font ="bold "+i+"px  arial";}
 if(document.getElementById('purpose')){
  i=(document.documentElement.clientHeight/75)+1; if(i>14){i=14};
  for(var k=0,j=getElementsById('purpose').length;k<j;k+=1){getElementsById('purpose')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('capt_middle')){
  i=(document.documentElement.clientHeight/55)+1;  if(i>16){i=16};
  for(var k=0,j=getElementsById('capt_middle').length;k<j;k+=1){getElementsById('capt_middle')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('capt_none_white')){
  i=(document.documentElement.clientHeight/56)+2; if(i>17){i=17};
  for(var k=0,j=getElementsById('capt_none_white').length;k<j;k+=1){getElementsById('capt_none_white')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('capt_none_white_d')){
  i=(document.documentElement.clientHeight/56)+2; if(i>17){i=17};
  for(var k=0,j=getElementsById('capt_none_white_d').length;k<j;k+=1){getElementsById('capt_none_white_d')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('capt_model1')){
  i=(document.documentElement.clientHeight/70)+1;
  for(var k=0,j=getElementsById('capt_model1').length;k<j;k+=1){getElementsById('capt_model1')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('capt_model')){
  i=(document.documentElement.clientHeight/90)+1;
  for(var k=0,j=getElementsById('capt_model').length;k<j;k+=1){getElementsById('capt_model')[k].style.font ="bold "+i+"px  arial";}
 }
 if(document.getElementById('type_od')){
  i=(document.documentElement.clientHeight/78)+1;
  for(var k=0,j=getElementsById('type_od').length;k<j;k+=1){getElementsById('type_od')[k].style.font ="bold "+i+"px  lucida,verdana,arial,helvetica";}
 }
 if(document.getElementById('made_by')){
  i=(document.documentElement.clientHeight/78)+1;
  for(var k=0,j=getElementsById('made_by').length;k<j;k+=1){getElementsById('made_by')[k].style.font ="bold "+i+"px  lucida,verdana,arial,helvetica";}
 }
 if(document.getElementById('capt_huge')){
  i=(document.documentElement.clientHeight/40);   if(i>22){i=22};
  for(var k=0,j=getElementsById('capt_huge').length;k<j;k+=1){getElementsById('capt_huge')[k].style.font ="bold "+i+"px  lucida,verdana,arial,helvetica";}
 }
 }


function show_path(){
        var w = 510;
        var h = 398;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no'
	win = window.open('popup/path.php', 'win2', winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}

function show_letter(){
        var w = 420;
        var h = 350;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no'
	win = window.open('popup/letter.php', 'win2', winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}
