var _d=document;

ns4=(_d.layers)?true:false;
ns6=(navigator.userAgent.indexOf("Gecko")!=-1)?true:false;
mac=(navigator.appVersion.indexOf("Mac")!=-1)?true:false;
mac45=(navigator.appVersion.indexOf("MSIE 4.5")!=-1)?true:false;
if(ns6||ns4)mac=false;
opra=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
if(mac&&opra)mac=0;
ns61=(parseInt(navigator.productSub)>=20010726)?true:false;
ie4=(!_d.getElementById&&_d.all)?true:false;
ie55=((navigator.appVersion.indexOf("MSIE 6.0")!=-1||navigator.appVersion.indexOf("MSIE 5.5")!=-1))?true:false;
if(ie55&&opra)ie55=false;
konq=(navigator.userAgent.indexOf("Konqueror")!=-1)?true:false;
mp=(ns6)?"pointer":"hand";

//System Functions


function spos(gm,t_,l_,h_,w_){
/*
	Set position for object gm
	t_ - top
	l_ - left
	h_ - height
	w_ - width
	if dome of parametrs is null - it will not be set
*/
	px="px";
	if(ns4){
		px="";
		gms=gm;
		if(w_!=null)gms.clip.width=w_;
		if(h_!=null)gms.clip.height=h_;
	}else if(opra){
		px="";
		gms=gm.style;
		if(w_!=null)gms.pixelWidth=w_;
		if(h_!=null)gms.pixelHeight=h_
	}else{
		gms=gm.style;
		if(w_!=null)gms.width=w_+px;
		if(h_!=null)gms.height=h_+px;
	}
	if(t_!=null)gms.top=t_+px;
	if(l_!=null)gms.left=l_+px
}

function gpos(gm){
/*	
Input - object
Returns array of positions (in pixels) of an object
	gpa[0]=top;
	gpa[1]=left;
	gpa[2]=height;
	gpa[3]=width;
*/	
	if(ns4){
		t_=gm.top;
		l_=gm.left;
		h_=gm.clip.height;
		w_=gm.clip.width;
	}else if(opra){
		t_=gm.offsetTop;
		l_=gm.offsetLeft;
		h_=gm.offsetHeight;
		w_=gm.offsetWidth;
		
	}else if(ns6){
		t_=gm.offsetTop;
		l_=gm.offsetLeft;
		h_=gm.offsetHeight;
		w_=gm.offsetWidth
	}else{
		if(mac){
			topM=gm.offsetParent.topMargin;
			if(!topM)topM=0;
			leftM=gm.offsetParent.leftMargin;
			if(!leftM)leftM=0;
			t_=parseInt(topM)+gm.offsetTop;
			l_=parseInt(leftM)+gm.offsetLeft;
		}else{
			t_=gm.offsetTop;
			l_=gm.offsetLeft;
		}
		//gm.style.color='rr';
		//alert(gm.style.pixelLeft+";;"+gm.clientWidth);
		h_=gm.offsetHeight;
		w_=gm.offsetWidth;
		//w_=parseInt(gm.width);
		//h_=parseInt(gm.height);
	}
	if(konq){
		w_=parseInt(gm.style.width);
		h_=parseInt(gm.style.height);
	}
	var gpa=new Array();
	gpa[0]=t_;
	gpa[1]=l_;
	gpa[2]=h_;
	gpa[3]=w_;
	return(gpa)
}


function gmstyle(mtxt){
	m=getEl(mtxt);
	if(!ns4){
		if(m)m=m.style;
	}
	return m;
}
function switchVis(el,n){
	el=gmstyle(el);
	if (n){
		el.visibility="visible";
	}else{
		if(ns4){
			el.visibility="hide";
		}else{el.visibility="hidden";}
	}
}

function getEl(e,doc)
{
  if (!doc)doc=document;
  if(typeof(e)!="string") return e;
  if(doc.getElementById) e=doc.getElementById(e);
  else if(doc.all) e=doc.all[e];
  else if(doc.document.getElementById) e=doc.document.getElementById(e);
  else 
  {
    e=null;
  }
  return e;
}

//-------------
function vInt(s){
/*
	converts string s to integer 
	if can not returns '0'
	works only for decimal numbers
*/
	var p=parseInt(s,10);
	if (!p)p=0;
	return p;
}

//----------------------------------------------------getFrame------------------------------------------------

function getFrame1(s,dc){
	var idoc="";
	if (document.all){
			var fv=dc.document.getElementById(s);
			idoc=dc.document.frames[s];
	}
	else {
		var fv=dc.document.getElementById(s);
		if (fv){
			if(fv.contentWindow){
				idoc=fv.contentWindow.frames;
			}	
		}
		else	{}
	}
	return idoc;
}

function getFrame_m(s,dc){
	var idoc="";
	idoc=getFrame1(s,dc);
	if (!idoc){
		var ifA=dc.window.frames;
		var i=0;
		for (i=0;i<ifA.length;i++){
			if (ifA[i].id) alert (ifA[id]);
			idoc=getFrame_m(s,ifA[i]);
			if (idoc){
				break;
			}
		}
	}	
	
	return idoc;
}
function getFrame(s){
	var dc=top;
	return getFrame_m(s,dc);
	
}

function selectAll(el) {
			el.select();
	}
	
sel_states='<select name=shiState>\
<OPTION VALUE="AL">Alabama\
<OPTION VALUE="AK">Alaska\
<OPTION VALUE="AZ">Arizona\
<OPTION VALUE="AR">Arkansas\
<OPTION VALUE="CA">California\
<OPTION VALUE="CO">Colorado\
<OPTION VALUE="CT">Connecticut\
<OPTION VALUE="DE">Delaware\
<OPTION VALUE="DC">District of Columbia\
<OPTION VALUE="FL">Florida\
<OPTION VALUE="GA">Georgia\
<OPTION VALUE="HI">Hawaii\
<OPTION VALUE="ID">Idaho\
<OPTION VALUE="IL">Illinois\
<OPTION VALUE="IN">Indiana\
<OPTION VALUE="IA">Iowa\
<OPTION VALUE="KS">Kansas\
<OPTION VALUE="KY">Kentucky\
<OPTION VALUE="LA">Louisiana\
<OPTION VALUE="ME">Maine\
<OPTION VALUE="MD">Maryland\
<OPTION VALUE="MA">Massachusetts\
<OPTION VALUE="MI">Michigan\
<OPTION VALUE="MN">Minnesota\
<OPTION VALUE="MT">Montana\
<OPTION VALUE="NE">Nebraska\
<OPTION VALUE="NV">Nevada\
<OPTION VALUE="NH">New Hampshire\
<OPTION VALUE="NJ">New Jersey\
<OPTION VALUE="NM">New Mexico\
<OPTION VALUE="NY">New York\
<OPTION VALUE="NC">North Carolina\
<OPTION VALUE="ND">North Dakota\
<OPTION VALUE="OH">Ohio\
<OPTION VALUE="OK">Oklahoma\
<OPTION VALUE="ON">Ontario\
<OPTION VALUE="OR">Oregon\
<OPTION VALUE="PA">Pennsylvania\
<OPTION VALUE="RI">Rhode Island\
<OPTION VALUE="SC">South Carolina\
<OPTION VALUE="SD">South Dakota\
<OPTION VALUE="TN">Tennessee\
<OPTION VALUE="TX">Texas\
<OPTION VALUE="UT">Utah\
<OPTION VALUE="VT">Vermont\
<OPTION VALUE="VA">Virginia\
<OPTION VALUE="WA">Washington\
<OPTION VALUE="WV">West Virginia\
<OPTION VALUE="WI">Wisconsin\
<OPTION VALUE="WY">Wyoming\
<OPTION VALUE="YT">Yukon\
</select>\
';
inp_states='<input name=shiState>';
st='';

function checkStates(elv,thisState) {
	if ((elv=='United States of America') && (st!='us')) {
		document.getElementById('td_state').innerHTML=sel_states;
		st='us';
		if (thisState){
			var tobj=getEl("shiState");
			for (i=0;i<tobj.options.length;i++){
				var opt=tobj.options[i];
				if (opt.value==thisState)opt.selected=1;
			}
		}
	}
	else if (st!='for') {
		document.getElementById('td_state').innerHTML=inp_states;			
		st='for';
		if (thisState){
			getEl("shiState").value=thisState;
		}
	}
}