function rowHighlight(rID) {
	if (!gE(rID)) return;
	gE(rID).className += " rowH";
}
function rowUnHighlight(rID) {
	if (!gE(rID)) return;
	gE(rID).className = gE(rID).className.replace(" rowH", "");
}

function gE(eID) {
	return document.getElementById(eID);
}

function toggleHidden(hiddenID) {
	if (!document.getElementById) return;
	el = document.getElementById(hiddenID);
	if (el)
		el.style.display = (el.style.display=='none') ?  'block' : 'none';
}

function vardump(obj) {
            var t = '';
			s=1;
            for (i in obj) {
//				if (obj[i]) {
					t += i + ": " + obj[i] + " - - - - - - - - - ";
					if (s==5) {
						t += "\n";
						s=1;
					}
					s ++;
///				}
			}
//            for (i in obj) t += i + ": " + obj[i] + "<br>"
//			document.write(t);
            alert(t);
}

function addRecordToList(question, fldName, newFldName) {
	var cName = prompt(question, '');
	if (cName) {
		cNameSm = cName.toLowerCase();
		pEl = gE(fldName);
		selectT=0;
		for (i=0; i<pEl.options.length; i++) {
			el = pEl.options[i];
			if (el.text.toLowerCase()==cNameSm) {
				selectT = el.value;
				i = pEl.options.length++;
			}
		}
		if (selectT===0) {
			nEl = document.createElement("option");
			switch (fldName) {
			case "city":
			case "region":
				nEl.value=cName;
				selectT = cName;
				break;
			default:
				nEl.value=9999999;
				selectT = 9999999;
			}
			nEl.text=cName;
			pEl.add(nEl);
			gE(newFldName).value=cName;
		}
		pEl.value=selectT;
	}
}

var arImages=new Array();
function Preload() {
	var temp = Preload.arguments; 
	for(x=0; x < temp.length; x++) {
		arImages[x]=new Image();
		arImages[x].src=Preload.arguments[x];
	}
}

function clearPeriod(stField, endField, theForm) {
	clearCalendarField(stField, theForm);
	clearCalendarField(endField, theForm);
}

function clearCalendarField(field, theForm) {
	if (theForm[field])
		theForm[field].value='';
	if (gE('view' + field))
		gE('view' + field).innerHTML='';
}

// tabs management functions
var curTab=0;
function jumpToTab(tabID) {
	if (curTab) {
		setTabImgs('off', curTab);
		switchInfoTable('none', curTab);
	}
	setTabImgs('on', tabID);
	switchInfoTable('block', tabID);
	curTab = tabID;
	if (setValueOfJumpToTab)
		setValueOfJumpToTab();
}
function setTabImgs(way, tabID) {
	tabsPath = '/adm_pnl/images/tabs/';
	if (gE('leftTab' + tabID))
		gE('leftTab' + tabID).src=tabsPath + way + '_left.gif';
	if (gE('rightTab' + tabID))
		gE('rightTab' + tabID).src=tabsPath + way + '_right.gif';
	if (gE('tab' + tabID))
		gE('tab' + tabID).style.backgroundImage='url(' + tabsPath + way + '_back.gif)';
}
function switchInfoTable(setVl, tableID) {
	if (gE('tabTable' + tableID))
		gE('tabTable' + tableID).style.display=setVl;
}
// end of tabs management functions

/* dropdowns on shopBy top bar */
dropLPshown=0;
function displayDropDown(dropLPid) {
	if (gE('lp' + dropLPid + 'drop')) {
		gE('lp' + dropLPid + 'drop').style.display='block';
		dropLPshown=dropLPid;
	}
}
function hideDropDown(dropLPid) {
	if (gE('lp' + dropLPshown + 'drop')) {
		gE('lp' + dropLPshown + 'drop').style.display='none';
		dropLPshown=0;
	}
}

// this is being used on MouseOver at Features menu
function toggleFeaturesStar(starNum, imgPath, imgSuffix) {
	if (gE('featuresStar' + starNum))
		gE('featuresStar' + starNum).src=imgPath + 'star' + imgSuffix + '.gif';
}

function bookmarksite(title, url){
	if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
	else if (document.all)
		window.external.AddFavorite(url, title);
}

function switchAreaVsPhoneRequiry(el) {
	if (el) {
		theForm = el.form;
		if (theForm) {
			setVl = (el.value) ? 'NO' : 'YES'; //if there is a value - set to OPTIONAL='NO', otherwise - OPTIONAL='YES'
			elNameLen = el.name.length;
			setFld = (el.name.substring(elNameLen-4)=='area') ? el.name.substring(0, elNameLen-4) : el.name + 'area';
			if (theForm[setFld]) {
				theForm[setFld].setAttribute('OPTIONAL', setVl);
				if (!el.value)
					theForm[setFld].value='';
			}
	}	}
}

var XmlHttp;
var curRequest="";
var responseTexts = new Array();
function createXMLHttp(txtURL) {
	var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp","Microsoft.XMLHttp"];
    for (var i = 0; i < aVersions.length; i++) {
		try {
			if (navigator.appName!="Netscape") {
				var oXmlHttp = new ActiveXObject(aVersions[i]);
		    } else {
				var oXmlHttp = new XMLHttpRequest(); 
	    	}
			return oXmlHttp;
        } catch (oError) {
            //Do nothing
        }
    }
//	window.frames['ajaxLegacySupport'].location.href=txtURL;
//	id = window.setTimeout("afterBirksLegacy()",1000);
}

function send(txtURL, runFunction) {
	XmlHttp = createXMLHttp(txtURL);
	if (runFunction) {
		XmlHttp.onreadystatechange = eval(runFunction);
		XmlHttp.open("GET", txtURL);
	}
	XmlHttp.send(null);
}

function nothingDone(){
}
function validateRadioButton(theFld) {
	found = false;
	var thCounter=0;
	for (thCounter=0; thCounter<theFld.length && !found; thCounter++)
		if (theFld[thCounter].checked)
			found=true;
	if (found)
		res = thCounter;
	else
		res = -1;
	return res;
}

// IE flash activation workaround
function showflash(fileName, w, h, container, objname)
{
	if (objname==undefined)
		objname = 'myFlash';
	var html = '	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  style="z-index:-100;"'+
	'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '+
	'width="'+w+'" height="'+h+'" id="'+objname+'" align="middle"> ' +
	'<param name="allowScriptAccess" value="sameDomain" />' +
	'<param name="movie" value="'+fileName+'" />' +
	'<param name="quality" value="high" />' +
	'<param name="bgcolor" value="#000000" />' +
	'<param name="wmode" value="transparent" />' +
	'<embed src="' + fileName + '" quality="high"  width="'+w+'" height="'+h+'" ' +
	'name="'+objname+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" '+
	'pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />' +
	'</object>';
	if (container==undefined)
		document.body.innerHTML = html;
	else
		gE(container).innerHTML = html;
}





var __isIE =  navigator.appVersion.match(/MSIE/);
var __userAgent = navigator.userAgent;
var __isFireFox = __userAgent.match(/firefox/i);
var __isFireFoxOld = __isFireFox && (__userAgent.match(/firefox\/2./i) || __userAgent.match(/firefox\/1./i));
var __isFireFoxNew = __isFireFox && !__isFireFoxOld;


function __parseBorderWidth(width) {
    var res = 0;
    if (typeof(width) == "string" && width != null && width != "" ) {
        var p = width.indexOf("px");
        if (p >= 0) {
            res = parseInt(width.substring(0, p));
        }
        else {
     		//do not know how to calculate other values (such as 0.5em or 0.1cm) correctly now
    		//so just set the width to 1 pixel
            res = 1; 
        }
    }
    return res;
}


//returns border width for some element
function __getBorderWidth(element) {
	var res = new Object();
	res.left = 0; res.top = 0; res.right = 0; res.bottom = 0;
	if (window.getComputedStyle) {
		//for Firefox
		var elStyle = window.getComputedStyle(element, null);
		res.left = parseInt(elStyle.borderLeftWidth.slice(0, -2));  
		res.top = parseInt(elStyle.borderTopWidth.slice(0, -2));  
		res.right = parseInt(elStyle.borderRightWidth.slice(0, -2));  
		res.bottom = parseInt(elStyle.borderBottomWidth.slice(0, -2));  
	}
	else {
		//for other browsers
		res.left = __parseBorderWidth(element.style.borderLeftWidth);
		res.top = __parseBorderWidth(element.style.borderTopWidth);
		res.right = __parseBorderWidth(element.style.borderRightWidth);
		res.bottom = __parseBorderWidth(element.style.borderBottomWidth);
	}
   
	return res;
}

//returns absolute position of some element within document
function getAbsolutePos(element) {
	var res = new Object();
	res.x = 0; res.y = 0;
	if (element !== null) {
		res.x = element.offsetLeft;
		res.y = element.offsetTop;
    	
		var offsetParent = element.offsetParent;
		var parentNode = element.parentNode;
		var borderWidth = null;

		while (offsetParent != null) {
			res.x += offsetParent.offsetLeft;
			res.y += offsetParent.offsetTop;
			
			var parentTagName = offsetParent.tagName.toLowerCase();	

			if ((__isIE && parentTagName != "table") || (__isFireFoxNew && parentTagName == "td")) {		    
				borderWidth = __getBorderWidth(offsetParent);
				res.x += borderWidth.left;
				res.y += borderWidth.top;
			}
		    
			if (offsetParent != document.body && offsetParent != document.documentElement) {
				res.x -= offsetParent.scrollLeft;
				res.y -= offsetParent.scrollTop;
			}

			//next lines are necessary to support FireFox problem with offsetParent
   			if (!__isIE) {
    			while (offsetParent != parentNode && parentNode !== null) {
					res.x -= parentNode.scrollLeft;
					res.y -= parentNode.scrollTop;
					
					if (__isFireFoxOld) {
						borderWidth = _getBorderWidth(parentNode);
						res.x += borderWidth.left;
						res.y += borderWidth.top;
					}
    				parentNode = parentNode.parentNode;
    			}    
			}

   			parentNode = offsetParent.parentNode;
    		offsetParent = offsetParent.offsetParent;
		}
	}
    return res;
}



