//alert(11);
//var vvvF=1111;
//alert(navigator.userAgent);
var _d=document;

ns4=(_d.layers)?true:false
ns6=(navigator.userAgent.indexOf("Gecko")!=-1)?true:false
mac=(navigator.appVersion.indexOf("Mac")!=-1)?true:false
ismac=mac;
isie=(navigator.appVersion.indexOf("MSIE")!=-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
opra9=(navigator.userAgent.indexOf("Opera/9")!=-1)?true:false
//alert(navigator.userAgent+'OPERA9=='+opra9);
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;
if(isie&&opra)isie=false;

var konq=(navigator.userAgent.indexOf("Konqueror")!=-1)?true:false
var safari=(navigator.userAgent.indexOf("Safari")!=-1)?true:false
//alert(safari);
var safariBeta=( navigator.userAgent.indexOf("Safari/5")!=-1 )?true:false
//alert (safariBeta);
//alert(navigator.userAgent);
//alert(navigator.appVersion);

IEDtD=0;
if((_d.all&&_d.compatMode=="CSS1Compat")||(mac&&_d.doctype&&_d.doctype.name.indexOf(".dtd")!=-1))IEDtD=1;

//alert(navigator.userAgent);
//alert('safari='+safari);
//alert('konq='+konq);
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;
*/	
//alert(gm.top+',,'+gm.offsetTop+',,'+gm.topMargin+',,'+gm.style.top+',,'+gm.offsetParent.offsetHeight+',,'+gm.offsetHeight);
	if(ns4){
		//alert(11);
		t_=gm.top;
		l_=gm.left;
		h_=gm.clip.height;
		w_=gm.clip.width;
	}else if(opra){
		//alert(12);
		t_=gm.offsetTop;
		l_=gm.offsetLeft;
		h_=gm.offsetHeight;
		w_=gm.offsetWidth;
		
	}else if(ns6&&(!safari)){
		//alert(13);
		t_=gm.offsetTop;
		l_=gm.offsetLeft;
		h_=gm.offsetHeight;
		w_=gm.offsetWidth
	}else{
		//alert(14);
		if(mac||safari){
			//alert(1111);
			//alert(gm);
			//alert(gm.offsetParent);
			//alert(gm.offsetParent.topMargin);
			var topM=0;
			var leftM=0;
			
			if (gm.offsetParent)
			{
				//alert('here');
				var topM=gm.offsetParent.topMargin;
			}
			//alert('1111_1');
			if(!topM)topM=0;
			//alert('1111_2');
			if (gm.offsetParent)
			{
				leftM=gm.offsetParent.leftMargin;
			}
			//alert('1111_3');
			if(!leftM)leftM=0;
			//alert('1111_4');
			t_=parseInt(topM)+gm.offsetTop;
			l_=parseInt(leftM)+gm.offsetLeft;
			//alert('1111_5');
		}else{
			//alert(15);
			t_=gm.offsetTop;
			l_=gm.offsetLeft;
		}
		//gm.style.color='rr';
		//alert(gm.style.pixelLeft+";;"+gm.clientWidth);
		//alert (16);
		h_=gm.offsetHeight;
		w_=gm.offsetWidth;
		//w_=parseInt(gm.width);
		//h_=parseInt(gm.height);
	}
	if(konq){
		//alert (17);
		w_=parseInt(gm.style.width);
		h_=parseInt(gm.style.height);
	}
	//alert (18);
	var gpa=new Array();
	gpa[0]=t_;
	gpa[1]=l_;
	gpa[2]=h_;
	gpa[3]=w_;
	//alert (19);
	return(gpa)
}

function gAbsolutePos(iObj)
{
	var gpa;
	
	var gpa1= gpos(iObj);
	
	//alert(iObj.parentNode+ '@@' + iObj.parentNode.tagName.toLowerCase());
	
	var ttagName=iObj.tagName.toLowerCase();
	if ((ttagName=='tbody')||(ttagName=='tr')||(ttagName=='div'))
	{
		//alert('TBODY1 ^^ '+gpa1[0]+';;'+gpa1[0]);
		
		gpa1[0]=0;
		gpa1[1]=0;
		//alert('TBODY2 ^^ '+gpa1[0]+';;'+gpa1[0]);
	}
	
	if ( (iObj.parentNode) && (iObj.parentNode.tagName.toLowerCase()!='body') && (iObj.parentNode.tagName.toLowerCase()!='html') )
	{
		//alert('here');
		gpa=gAbsolutePos(iObj.parentNode);
		
		//alert(iObj.parentNode+ '@@' + iObj.parentNode.tagName.toLowerCase()+' ## t='+gpa[0]+' ;; l='+gpa[1] +'^^^^' +iObj.tagName+' ## t='+gpa1[0]+' ;; l='+gpa1[1]);
		
		gpa1[0]+=gpa[0];
		gpa1[1]+=gpa[1];
		
		
	}
	
	
	
	
	return(gpa1);
}

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 
  {
    e=null;
  }
  return e;
}
function getFlashEl(e,win,doc){
	if (!win){win=window;}
	if (!doc){doc=document;}
	if(win[e])
	{
		 var oobj=win.document[e];
	}
	
	if(doc[e])
	{
		 var oobj=doc[e];
		 //var oobj=eval('doc.'+e);
	}
	/*
	else
	{
		///alert(3);
		var oobj=null;
	}*/
	
	return oobj;
}

//-------------
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);
			return dc.document.frames[s];
	}
	else if (safari) { // for Safari
			//alert('safari');
			//alert(window.frames[s]);
			//alert(dc.window.frames[s]);
			var idoc=dc.window.frames[s];
			//alert(idoc);
			return idoc;
			//alert(2);
	}
	else {
		var fv=dc.document.getElementById(s);
		if (fv){
			if(fv.contentWindow){
				idoc=fv.contentWindow.frames;
			}	
		}
		else	{}
	}
	return idoc;
}
//function getDocument(elName) {
//	if (document.all) { // for IE
//		return document.frames[elName].document;
//	} else if (window.frames && window.frames[elName]) { // for Safari
//		return window.frames[elName].document;
//	} else if (document.getElementById) { // for Moz/Nav/FF
//		return document.getElementById(elName).contentWindow.document;
//	}
//	return "";
//}

function getFrame_m(s,dc){
	var idoc="";
	idoc=getFrame1(s,dc);
	//alert(333);
	//alert('idoc='+','+idoc);
	if (!idoc){
		//alert('not 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();
	}
	
var sel_states_or='<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="MS">Mississippi'+
'<OPTION VALUE="MO">Missouri'+
'<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="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';

sel_states='<select name="shiState" class="inp_txt">'+
				sel_states_or+
'</select>';
inp_states='<input name="shiState"  maxlength="30" class="inp_txt" />';
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;
		}
	}
}

//var vWaitSemaphorA=new Array();
//var vWaitSemaphorI=0;
function vWait(msec){
	//vWaitSemaphorA[vWaitSemaphorI]=msec;
	var d = new Date();   
	
	var fTime=0;
	                  
	var lTime=fTime=d.getTime();
	while ((lTime-fTime)<msec){
		d = new Date();   
		lTime=d.getTime();
		//alert(lTime);
	}
	//alert('stop');
}

function setOpacity(el,opacity){
/*	el - object
	opacity: 0-1 (like 0.35)
*/
  var opacity100=opacity*100;
  el.style.filter="alpha(opacity:"+opacity100+")";
  el.style.KHTMLOpacity=opacity;
  el.style.MozOpacity=opacity;
  el.style.opacity=opacity;
}

function openMailWindow(){
	//alert('openMailWindow');
	//index.php_;_admin_type=snew_,_multi=1
	//alert(top.vMailWindowObj.toString());
	//alert(top.vMailWindowObj.length);
	//alert(top.vMailWindowObj.window);
	try {
		var val=top.vMailWindowObj.window;
		top.vMailWindowObj.vvLoad();
		
	}catch(e){
		top.vMailWindowObj=window.open("index.php?admin_type=snew&multi=1",null,"toolbar=no,menubar=no");
	}
	//if ( (!top.vMailWindowObj)||(!top.vMailWindowObj.window) )
		
}

function alert_r(obj)
{

	//alert('alert_r');
	var obj1=obj;
	var str=getStr_for_alert_r(obj1,1);
	alert (str);
}

function getStr_for_alert_r(obj,level,kkey)
{
	if (level<=0){return;}
	if (obj==null) {return;}
	
	var obj1=obj;
	var level1=level-1;
	var str='';
	var l=obj.length;
	//alert('l='+l);

		str+='\n';
	for (var j=0;j<level;j++){	str+='#'; }
		
	str+='{'+kkey+'}'+'['+obj+']'+' ('+obj.toString()+') '+obj.valueOf();

	for (key in obj1)
	{
		str+='\n';
		//for (var j=0;j<level;$j++){	str+='#'; }
		str+='{'+key+'}';
		if (obj[key])
		{
			str+='['+obj[key]+']'+' ('+obj[key].toString()+') '+obj[key].valueOf();
		}
		//str+='['+obj[i]+']'+' ('+obj[i].toString()+') '+obj[i].valueOf();
		//str+=getStr_for_alert_r(obj1[key],level1,key);
	}
	return str;
}


function enableWinTable(obj)
{
	var table = getEl("winTable");
	var enable = obj.checked;
	/*var selects = table.getElementsByTagName("select");
	var inputs = table.getElementsByTagName("input");
	for(var i in selects)
		selects[i].disabled = !enable;
	for(i in inputs)
		inputs[i].disabled = !enable;*/
		
	var fonts = table.getElementsByTagName("font");
	var l = fonts.length;
	for(var i = 0; i < l; i++)
	{
		if(enable)
			fonts[i].style.visibility = 'visible';
		else 
			fonts[i].style.visibility = 'hidden';
	}
	if(enable)
		table.className = "";
	else
		table.className = "greyBox";

}


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";
			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";
			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}