var currentlyDimming;
function hideByID(elementName) {
	if (document.getElementById(elementName)) {
		document.getElementById(elementName).style.display='none';
	}
}

function showByID(elementName) {
	if (document.getElementById(elementName)) {
		document.getElementById(elementName).style.display='inline';
	}
}

function showBlockByID(elementName) {
	document.getElementById(elementName).style.display='block';
}

function setFocus(elementName) {
	document.getElementById(elementName).focus();
}


function showHideByID(elementName) {
	if (document.getElementById(elementName).style.display=='inline') {
		hideByID(elementName)
	} else {
		showByID(elementName)
	}
}

function showHideBlockByID(elementName) {
	if (document.getElementById(elementName).style.display=='block') {
		hideByID(elementName)
	} else {
		showBlockByID(elementName)
	}
}


function changeText(elementName,theText) {
	if (document.getElementById(elementName))  {return document.getElementById(elementName).innerHTML=theText};
}

function changePicForGal(picDiv,mainPic,contentDiv,content) {
	changePic(picDiv,mainPic);
	changeText(contentDiv,content);
}

function changeLink(elementName,theLink) {
	return document.getElementById(elementName).href=theLink;
}

function getLink(elementName) {
	if (document.getElementById(elementName)) {
		return document.getElementById(elementName).href;
	}
}

function changeFormAction(formName,actionPage) {
	return document.getElementById(formName).action=actionPage;
}

function getText(elementName) {
	if (document.getElementById(elementName))  {return document.getElementById(elementName).innerHTML};
}


function changePic(elementName,thePic) {
	document.getElementById(elementName).src=thePic;
}

function getPicSrc(elementName) {
	return document.getElementById(elementName).src;
}

function changePicFront(thePic,elementName) {
	document.getElementById(elementName).src=thePic;
}


function makeReadOnly(elementName,theState) {
	document.getElementById(elementName).readOnly=theState;
}

function submitForm(elementName) {
	document.getElementById(elementName).submit();
}


function resetForm(elementName) {
	document.getElementById(elementName).reset();
}

function clearInput(elementName) {
	document.getElementById(elementName).value='';
}

function getFieldValue(elementName) {
	if (document.getElementById(elementName)) {return document.getElementById(elementName).value;}
}

function getFieldText(elementName) {
	if (document.getElementById(elementName)) {
		var x=document.getElementById(elementName);
		return x.options[x.selectedIndex].text;
	}
}

function changeFieldValue(srcField,newValue) {
	if (document.getElementById(srcField)) {
		document.getElementById(srcField).value=newValue
	}
}

function changeFieldValueByName(srcField,newValue) {
	if (document.getElementsByName(srcField)) {
		document.getElementsByName(srcField).value=newValue
	}
}

function changeFieldTitle(srcField,newValue) {
	if (document.getElementById(srcField)) {
		document.getElementById(srcField).title=newValue;
	}
}

function changeClass(elementName,theClassName) {
	if (document.getElementById(elementName)) {
		document.getElementById(elementName).className=theClassName;
	}
}

function changeBackroundImage(elementName,imageName) {
	document.getElementById(elementName).style.backgroundImage="url('"+imageName+"')";
}

function changeBackroundColor(elementName,color) {
	document.getElementById(elementName).style.backgroundColor=color;
}

function changeBackgroundColorMulti(elementName,color1,color2) {
	if (document.getElementById(elementName).style.backgroundColor==color1) {
		document.getElementById(elementName).style.backgroundColor=color2;
	} else {
		document.getElementById(elementName).style.backgroundColor=color1;

	}
}


function enableBtn(btnName) {
	if (document.getElementById(btnName)) {
		document.getElementById(btnName).disabled=false;
	}
}

function disableBtn(btnName) {
	if (document.getElementById(btnName)) {
		document.getElementById(btnName).disabled=true;
	}
}


function searchSuggest(suggestionsDivName,textFieldName,findSolutionsValue,urlParams) {
	showByID(suggestionsDivName);
	changeText(suggestionsDivName,findSolutionsValue);
	url='/ajaxSuggestions.php?'+urlParams+'&searchTerm='+getFieldValue(textFieldName);
	reloadPage(url,'',suggestionsDivName);
}


function deleteItem(deleteTitle,pageName,refreshElem,idField,itemID,theTable,moreParams) {
	var agree=confirm ('האם אתה בטוח שברצונך למחוק את '+deleteTitle+' ?');
	if (agree) {
		pageName = pageName+'?mode=doDelete&adminID=<?=$_REQUEST[adminID];?>&idField='+idField+'&idFieldValue='+itemID+'&theTable='+theTable+'&'+moreParams;
		reloadPage(pageName,'',refreshElem);
	}
}

function changeTextForOpenClose(elementName,conditionElement,textShow,textHide) {
	var elem = document.getElementById(elementName);
	if (document.getElementById(conditionElement).style.display=='inline') {
		elem.innerHTML=textHide;
	} else {
		elem.innerHTML=textShow;
	}
}

function checkFtpAccuntAdd(errorMessage) {
	var myVal=getFieldValue('userNameStatus');
	if (myVal==1) {
		return true;
	} else {
		alert(errorMessage);
		return false;
	}
}


function doSearchItems(whileSearchCaption) {
	changeText('searchItems',whileSearchCaption);
	var curInputs = new Array(); // to store the textbox objects
	var listOfInputs='';
	curInputs = document.getElementsByTagName('input'); // array of my inputs
	for (i = 0; i<curInputs.length;i++ ) {
		listOfInputs += curInputs[i].id+"="+curInputs[i].value+"&";
	}
	reloadPage('content/contentColectiveSearchItems.php?'+listOfInputs+'searchTerm='+getFieldValue('searchTerm'),'','searchItems');
}


function showBillingDetails() {
	var billingDay=getFieldValue('billingDay');
	var billingMonth=getFieldValue('billingMonth');
	var billingYear=getFieldValue('billingYear');
	var showPlan,showExtraModules,showAdditionalDomains,showTemplates;
	if (checkBoxChecked('showPlan')==1) showPlan='y'; else showPlan='n';
	if (checkBoxChecked('showExtraModules')==1) showExtraModules='y'; else showExtraModules='n';
	if (checkBoxChecked('showAdditionalDomains')==1) showAdditionalDomains='y'; else showAdditionalDomains='n';
	if (checkBoxChecked('showTemplates')==1) showTemplates='y'; else showTemplates='n';
	if (checkBoxChecked('showSms')==1) showSms='y'; else showSms='n';
	var listFranchisers = handleFranchisers();
	var listCustomers = handleCustomers();
	changeText('showBilingInfo','טוען מידע אנא המתן. זמן הטעינה יכול לארוך זמן רב אנא התאזר בסבלנות');
	reloadPage('/ezadmin3/billingSystem/billingIn.php?billingDay='+billingDay+'&billingMonth='+billingMonth+'&billingYear='+billingYear+'&listFranchisers='+listFranchisers+'&listCustomers='+listCustomers+'&showSms='+showSms+'&showPlan='+showPlan+'&showExtraModules='+showExtraModules+'&showAdditionalDomains='+showAdditionalDomains+'&showTemplates='+showTemplates,'','showBilingInfo');
}

function filterFranchisers() {
	var franchiserName=getFieldValue('franchiserName');
	changeText('listOfFranchisers','טוען רשימת זכיינים');
	reloadPage('/ezadmin3/billingSystem/listFranchisers.php?frName='+franchiserName,'','listOfFranchisers');
}

function filterCustomers() {
	var customerName=getFieldValue('customerName');
	var listFranchisers = handleFranchisers();
	changeText('listOfCustomers','טוען רשימת לקוחות');
	reloadPage('/ezadmin3/billingSystem/listCustomers.php?listFranchisers='+listFranchisers+'&crName='+customerName,'','listOfCustomers');
}

function handleFranchisers() {
	if (document.getElementById('franchisers')) {
		var franchisers=document.getElementById('franchisers');
		var listFranchisers='';
		var i;
		for(i=franchisers.options.length-1;i>=0;i--) {
			if(franchisers.options[i].selected) {
				listFranchisers+=franchisers.options[i].value+',';
			}
		}
	} else {
		var listFranchisers='';
	}
	return listFranchisers;
}

function handleCustomers() {
	if (document.getElementById('customers')) {
		var customers=document.getElementById('customers');
		var listCustomers='';
		var i;
		for(i=customers.options.length-1;i>=0;i--) {
			if(customers.options[i].selected) {
				listCustomers+=customers.options[i].value+',';
			}
		}
	} else {
		var listCustomers='';
	}
	return listCustomers;
}



var xmlHttp;
function reloadPage(pageName,formName,refreshElem) {
	//changeText(refreshElem,'loading');
	dimm();
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChanged;
	function stateChanged() {
		if (xmlHttp.readyState==4) {
			document.getElementById(refreshElem).innerHTML=xmlHttp.responseText;
			undimm();
		}
	}
	var url='';
	if (formName) {
		var x=document.getElementById(formName);
		for (var i=0;i<x.length;i++) {
			x.elements[i].value = x.elements[i].value.replace(/&/g,"%26");
			url += x.elements[i].name+'='+x.elements[i].value+'&';
		}
	}
	if (url)
	changeFieldValue('txt',url);
	xmlHttp.open("POST",encodeURI(pageName),true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	xmlHttp.send(url);

}


var xmlHttpHistory;
function reloadPageNoDim(pageName,formName,refreshElem) {
	//changeText(refreshElem,'loading');
	xmlHttpHistory=GetXmlHttpObject();
	xmlHttpHistory.onreadystatechange=stateChanged;
	function stateChanged() {
		if (xmlHttpHistory.readyState==4 && xmlHttpHistory.status == 200) {
			document.getElementById(refreshElem).innerHTML=xmlHttpHistory.responseText;
		}
	}
	var url='';
	if (formName) {
		var x=document.getElementById(formName);
		for (var i=0;i<x.length;i++) {
			x.elements[i].value = x.elements[i].value.replace(/&/g,"%26");
			url += x.elements[i].name+'='+x.elements[i].value+'&';
		}
	}
	if (url)
	changeFieldValue('txt',url);
	xmlHttpHistory.open("POST",encodeURI(pageName),true);
	xmlHttpHistory.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	xmlHttpHistory.send(url);

}



function reloadPageWArray(pageName,refreshElem,formName) {
	dimm();
	var refreshTo = new Array();
	var xmlHttp = new Array();
	function stateChanged0() {
		if (xmlHttp[0].readyState==4 && xmlHttp[0].status == 200) {
			document.getElementById(refreshTo[0]).innerHTML=xmlHttp[0].responseText;
			undimm();
		} else {
			undimm();
		}
	}
	function stateChanged1() {
		if (xmlHttp[1].readyState==4 && xmlHttp[1].status == 200) {
			document.getElementById(refreshTo[1]).innerHTML=xmlHttp[1].responseText;
			undimm();
		} else {
			undimm();
		}
	}
	function stateChanged2() {
		if (xmlHttp[2].readyState==4 && xmlHttp[2].status == 200) {
			document.getElementById(refreshTo[2]).innerHTML=xmlHttp[2].responseText;
			undimm();
		} else {
			undimm();
		}

		// changeText('loadingDiv','');
	}
	var url='';
	for (i=0;i<(pageName.length);i++) {
		xmlHttp[i]=new GetXmlHttpObject();
		xmlHttp[i].open("POST",pageName[i],true);
		if (formName[i]) {
			var x=document.getElementById(formName[i]);
			for (var z=0;z<x.length;z++) {
				var myVal = x.elements[z].value;
				myVal = myVal.replace(/&/g,"%26");
				url += x.elements[z].name+'='+myVal+'&';
			}
		}
		xmlHttp[i].onreadystatechange=eval('stateChanged'+i);
		if (url=='') url = pageName[i];
		refreshTo[i] = refreshElem[i];
		xmlHttp[i].setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		xmlHttp[i].send(url);
	}

}



function reloadPageEval(pageName,formName,refreshElem) {

	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChanged;
	function stateChanged() {
		if (xmlHttp.readyState==4) {
			eval(document.getElementById(refreshElem).innerHTML=xmlHttp.responseText);
		}
	}
	var url='';
	if (formName) {
		var x=document.getElementById(formName);
		for (var i=0;i<x.length;i++) {
			url += x.elements[i].name+'='+x.elements[i].value+'&';
		}
	}
	xmlHttp.open("POST",pageName,true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	xmlHttp.send(url)
}


function ajaxEval(pageName,formName) {

	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=stateChanged;
	function stateChanged() {
		if (xmlHttp.readyState==4) {
			eval(xmlHttp.responseText);
		}
	}
	var url='';
	if (formName) {
		var x=document.getElementById(formName);
		for (var i=0;i<x.length;i++) {
			url += x.elements[i].name+'='+x.elements[i].value+'&';
		}
	}
	xmlHttp.open("POST",pageName,true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	xmlHttp.send(url)
}


function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}


function checkEmail(emailField,infoFld,text1,text2) {
	var str = document.getElementById(emailField).value;
	var at="@"
	var dot="."
	var off=""
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1) {off=1;}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)  {off=1;}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)  {off=1;}
	if (str.indexOf(at,(lat+1))!=-1)  {off=1;}
	if (str.indexOf(" ")!=-1) {off=1;}
	if (off==1) {
		//changeText(infoFld,text1);
		changeBackroundColor(emailField,"red");
		return false;
	}  else {
		//changeClass(infoFld,'okayField');
		//changeText(infoFld,text2);
		changeBackroundColor(emailField,"white");
		return true;
	}
}




function checkInputData(elementName,elementCaption,msgField,minimumChars,errorClass,okayClass) {
	//alert(elementName +" "+elementCaption);
	if (minimumChars == 0) {
		if (!document.getElementById(elementName).value) {
			changeBackroundColor(elementName,"red");
			return false;
		} else {
			changeBackroundColor(elementName,"white");
			return true;
		}
	} else {
		if (document.getElementById(elementName).value.length < minimumChars) {
			changeBackroundColor(elementName,"red");
			return false;
		} else {
			changeBackroundColor(elementName,"white");
			return true;
		}
	}
}


function checkPassesEx(passField,passVerField,dontMatchCaption,minimumChars,errBG,okayBG) {
	if ((document.getElementById(passField).value != document.getElementById(passVerField).value)) {
		changeBackroundColor(passField, errBG);
		changeBackroundColor(passVerField, errBG);
		return false;
	} else {
		if ((document.getElementById(passField).value.length < minimumChars)) {
			changeBackroundColor(passField, errBG);
			changeBackroundColor(passVerField, errBG);
			return false;
		} else {
			changeBackroundColor(passField,okayBG);
			changeBackroundColor(passVerField, okayBG);
			return true;
		}
	}
}

function checkPasses(passField,passVerField,dontMatchCaption,minimumChars,errBG,okayBG,text1,text2,text3) {
	if ((document.getElementById(passField).value != document.getElementById(passVerField).value)) {
		changeClass('passFail','errorField');
		//changeText ('passFail',text1);
		return false;
	} else {
		changeClass('passFail','okayField');
		//changeText ('passFail',text3);
		if ((document.getElementById(passField).value.length < 4)) {
			changeClass('passFail','errorField');
			//changeText ('passFail',text2);
			return false;
		} else {
			changeClass('passFail','okayField');
			//changeText ('passFail',text3);
			return true;
		}
	}
}






function checkRadioChecked(elemntName) {
	var colRadio = document.getElementsByName(elemntName);
	for (var i=0;i<colRadio.length;i++) {
		if (colRadio[i].checked) {
			return colRadio[i].value;
		}
	}
	return false;
}

function goToPrev() {
	var prevValue=getFieldValue('curstep');
	var goTo = prevValue-1;
	hideByID('step'+prevValue);
	showByID('step'+goTo);
	changeFieldValue('curstep',goTo);
	if (goTo == 1) {
		hideByID('btnPrev');
		showByID('btnNext');
	}
	if (prevValue != 1) checkStep(prevValue);
}

function goToNext() {
	var nextValue=getFieldValue('curstep');
	nextValue++;
	var prevValue = nextValue-1;
	changeFieldValue('curstep',nextValue);
	hideByID('step'+prevValue);
	showByID('step'+nextValue);
	if (nextValue == 14) {
		showByID('btnPrev');
		hideByID('btnNext');
	} else {
		showByID('btnPrev');
	}
	checkStep(nextValue);
}

function entitySelected(obj){
	myCount = 0;
	for (i=0;i<obj.length;i++){
		if (obj[i].checked){
			myCount++;
		}
	}
	return myCount;
}

function anyCheck(contrlName,minInput,maxInput) {
	var checks = document.getElementsByName(contrlName);
	if ((entitySelected(checks)>maxInput) || (entitySelected(checks)<minInput)) {
		hideByID('btnNext');
	} else {
		showByID('btnNext');
	}
}

function anyCheckEditMulti(contrlName,minInput,maxInput) {
	var checks = document.getElementsByName(contrlName);
	if ((entitySelected(checks)>maxInput) || (entitySelected(checks)<minInput)) {
		return 0;
	} else {
		return 1;
	}
}

function textCounter(field,btnName,counter,maxlimit) {
	var fieldWidth = parseInt(field.offsetWidth);
	var charcnt = field.value.length;
	if (charcnt > maxlimit) {
		return 1;
	} else {
		var percentage = parseInt(100 - ((maxlimit - charcnt) * 100)/maxlimit) ;
		document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
		document.getElementById(counter).innerHTML=" "+percentage+"%"
		setcolor(document.getElementById(counter),percentage,"background-color");
		return false;
	}
}
function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

function checkBoxChecked(elementName) {
	if (document.getElementById(elementName).checked == true) {
		return true;
	} else{
		return false;
	}
}

function checkTerms(elementName,text1) {
	if (document.getElementById(elementName).checked == true) {
		return true;
	} else {
		return false;
	}
}

function textCount(elementName,numChars) {
	if(document.getElementById(elementName).value.length >= numChars) {
		return 1;
	} else {
		return 0;
	}
}


function foldMenu(elementName) {
	if (document.getElementById(elementName).style.display=='inline') {
		hideByID(elementName);
	} else {
		showByID(elementName);
	}
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else  var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function openWin(target,winName,width,height,scrollbars,toolbars) {
	window.open(target,winName,'toolbars='+toolbars+',width='+width+',height='+height+',scrollbars='+scrollbars);
}



var disappeardelay=3000  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=0 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function showhide(obj, e, visible, hidden){
	if (ie5||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (e.type=="click" && obj.visibility==hidden || e.type=="click")
	obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=35
	if (whichedge=="rightedge"){
		var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	} else {
		var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
		if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
		edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		}
	}
	return edgeoffset
}

function clickreturnvalue(){
	if ((ie5||ns6) && !enableanchorlink) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function dynamichide(e){
	if (ie5&&!dropmenuobj.contains(e.toElement)) {
		delayhidemenu()

	} else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhidemenu()
}

function delayhidemenu(){
	delayhide=setTimeout("dropmenuobj.style.visibility='hidden';showByID('srchBar');",disappeardelay);

}

function clearhidemenu(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}



var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
	if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
	cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
	else
	cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
	cross_marquee=document.getElementById("vmarquee")
	cross_marquee.style.top=0
	marqueeheight=document.getElementById("marqueecontainer").offsetHeight

	actualheight=cross_marquee.offsetHeight
	if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
	cross_marquee.style.height=marqueeheight+"px"
	cross_marquee.style.overflow="scroll"
	return
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",40)', delayb4scroll)
}

function runnews() {
	if (window.addEventListener)
	window.addEventListener("load", initializemarquee, false)
	else if (window.attachEvent)
	window.attachEvent("onload", initializemarquee)
	else if (document.getElementById)
	window.onload=initializemarquee
}



function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		return false;
	}
}


function changeCheckBxState(itemID) {
	var selfield = checkBoxChecked('checkbx_'+itemID);
	if (selfield===true) {
		changeFieldValue('verify'+itemID,'on');
	} else {
		changeFieldValue('verify'+itemID,'');
	}
}

function confirmDelete(custID,trashMode,confirmStr) {
	var agree=confirm(confirmStr);
	if (agree) {
		reloadPage('general/customers.php?doFinalDelete=1&trash='+trashMode+'&custID='+custID,'','content');
	}
}


function reloadPageWithParams(sectionID,parentID){
	pageStr = 'content/section.php?sectionID=' + sectionID + '&parentID=' + parentID;
	var pagesNameArray = new Array(pageStr,'dashboard/content.php');
	var refreshElementsArray = new Array ('content','dashboard');
	var formNameArray = new Array();
	reloadPageWArray(pagesNameArray,refreshElementsArray,formNameArray);
}




function makeValue(valuee) {
	changeFieldValue('redirectTo',valuee);
}

function checkGroups() {
	var result = "";
	for (var i = 0; i < sendEmail.sendToGroups.length; i++) {
		if (sendEmail.sendToGroups.options[i].selected) {
			result += "&groupID=" + sendEmail.sendToGroups.options[i].value;
		}
	}
	alert(result);

	return false;
}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)  {
			IsNumber = false;
		}
	}
	return IsNumber;
}

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
		tipobj.style.left="5px"
		else
		//position the horizontal position of the menu where the mouse is positioned
		tipobj.style.left=curX+offsetxpoint+"px"

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
		tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
		tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="0px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=positiontip


function handleCatSerach(catID) {
	if (getFieldValue('fieldItem'+catID)==0) {
		changePic('item'+catID,'images/greenSquare.gif');
		changeFieldValue('fieldItem'+catID,1);
	} else {
		changePic('item'+catID,'images/graySquare.gif');
		changeFieldValue('fieldItem'+catID,0);
	}
	reloadPage('content/sectionTemplateSearch.php','templateSearch','templateList');
}



function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

function getURLVar(urlVarName) {
	//divide the URL in half at the '?'
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1]){
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;
}

function returnShowHide(oid,shortRedirectTo){
	var section = getURLVar('section');
	var fullSection = 'section=' + section ;
	var indx = shortRedirectTo.search(fullSection) ;
	var ret=oid;
	if (indx >= 0 && section){
		ret='';
	}
	return ret;
}


function imgDisplay(oid1,shortRedirectTo1){
	var section1 = getURLVar('section');
	var fullSection1 = 'section=' + section1;
	var indx1 = shortRedirectTo1.search(fullSection1) ;
	if (indx1 >= 0 && section1){
		showByID(oid1);
	}
	else{
		hideByID(oid1);
	}
}


function returnWithHebrew(month,year,myMonth,myYear,returnFormat) {
	var listOfMonth = new Array();
	listOfMonth[0]="";
	listOfMonth[1]="ינואר";
	listOfMonth[2]="פברואר";
	listOfMonth[3]="מרץ";
	listOfMonth[4]="אפריל";
	listOfMonth[5]="מאי";
	listOfMonth[6]="יוני";
	listOfMonth[7]="יולי";
	listOfMonth[8]="אוגוסט";
	listOfMonth[9]="ספטמבר";
	listOfMonth[10]="אוקטובר";
	listOfMonth[11]="נובמבר";
	listOfMonth[12]="דצמבר";

	var newMonth = (myMonth*1)+(month*1);
	if (newMonth>12) {
		newMonth=1;
		myYear++;
	} else if (newMonth<1) {
		newMonth=12;
		myYear--;
	}

	var whattoreturn=eval(returnFormat);
	return whattoreturn;

}

function trim12 (str) {
	var	str = str.replace(/^\s\s*/, ''),
	ws = /\s/,
	i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}


function addToCollectiveBasket(elementName,extraValue,itemID,active,category,actionCase) {
	var curValue = getText(elementName);
	var tbl = document.getElementById(elementName);
	if (actionCase=='a') {
		//curValue += '<tr id="row"'+itemID+'"><td>'+itemID+'</td><td>'+extraValue+'</td></tr>';
		//changeText(elementName,curValue);
		var lastRow = tbl.rows.length;
		var row = tbl.insertRow(lastRow);
		row.id = "basketRow"+itemID;

		// insert show order value
		var showOrderCell = row.insertCell(0);
		var textFieldShowOrder = document.createElement('input');
		var nextOrder = getFieldValue('nextMaxOrder');
		textFieldShowOrder.type = 'text';
		textFieldShowOrder.style.width = '30px';
		textFieldShowOrder.name = 'showOrder'+itemID;
		textFieldShowOrder.id = 'showOrder'+itemID;
		textFieldShowOrder.value = nextOrder;
		showOrderCell.appendChild(textFieldShowOrder);

		nextOrder++;
		changeFieldValue ('nextMaxOrder',nextOrder);

		// insrert id and the hidden field
		var idCell = row.insertCell(1);
		var idNode = document.createTextNode(itemID);
		var textFieldHidden = document.createElement('input');
		textFieldHidden.type = 'hidden';
		textFieldHidden.name = 'inIntem[]';
		textFieldHidden.id = 'inIntem'+itemID;
		textFieldHidden.value = itemID;
		idCell.appendChild(idNode);
		idCell.appendChild(textFieldHidden);

		//insert active
		var activeCell = row.insertCell(2);
		var activeAvatar = new Image();
		activeAvatar.src='icons/btnActive'+active+'.png';
		activeCell.appendChild(activeAvatar);

		//insert title
		var titleCell = row.insertCell(3);
		var titleNode = document.createTextNode(extraValue);
		titleCell.appendChild(titleNode);

		//insert category
		var categoryCell = row.insertCell(4);
		var categoryNode = document.createTextNode(category);
		categoryCell.appendChild(categoryNode);

		// remove from list link
		var removeLinkCell = row.insertCell(5);
		var removeLink = document.createElement('a');
		//removeLink.setAttribute('href', "javascript:getStringReturnWithExtra('"+elementName+"','"+extraValue+"','"+itemID+"','"+active+"','"+category+"','r')");
		removeLink.setAttribute('href', "javascript:deleteTableRowFromCollective('"+elementName+"',getRowIndex('basketRow"+itemID+"'),"+itemID+");");
		removeLink.innerHTML='<<';
		removeLinkCell.appendChild(removeLink);
		changeClass('row'+itemID,'collectiveItemInUse');
		//hideByID('cell1'+itemID);hideByID('cell2'+itemID);hideByID('cell3'+itemID);hideByID('cell4'+itemID);hideByID('cell5'+itemID);
	}

	if (actionCase=='r') {
		changeClass('row'+itemID,'collectiveItemNotInUse');
		document.getElementById(elementName).deleteRow(i);
	}
}

function getRowIndex(elementName) {
	return  document.getElementById(elementName).rowIndex;
}

function deleteTableRowFromCollective(elementName,i,itemID) {
	document.getElementById(elementName).deleteRow(i);
	changeClass('row'+itemID,'collectiveItemNotInUse');
}

function dimm(){
	if (currentlyDimming==0) {
		if ($('dimmer')){
			document.body.removeChild($('dimmer'));
			return false;
		}
		//var width = document.body.offsetWidth + "px";
		var height = document.body.offsetHeight +"px";
		var el = document.createElement('div');
	
		el.appendChild(document.createTextNode(' '));
		el.className = 'dimmer';
		el.id = 'dimmer';
		//el.style.width = width;
		el.style.height = height;
		document.body.appendChild(el);
		currentlyDimming=1;
	}
}

function undimm() {
		if (currentlyDimming==1) {
		if ($('dimmer')){
			document.body.removeChild($('dimmer'));
		}
		currentlyDimming = 0;
		return false;
	}
}

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
	if (ie5&&dragapproved&&event.button==1){
		document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
		document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
	}
	else if (ns6&&dragapproved){
		document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
		document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
	}
}

function initializedrag(e){
	offsetx=ie5? event.clientX : e.clientX
	offsety=ie5? event.clientY : e.clientY
	document.getElementById("dwindowcontent").style.display="none" //extra
	tempx=parseInt(document.getElementById("dwindow").style.left)
	tempy=parseInt(document.getElementById("dwindow").style.top)

	dragapproved=true
	document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
	if (!ie5&&!ns6)
	window.open(url,"","width=width,height=height,scrollbars=1")
	else{
		document.getElementById("dwindow").style.display=''
		document.getElementById("dwindow").style.width=initialwidth=width+"px"
		document.getElementById("dwindow").style.height=initialheight=height+"px"
		document.getElementById("dwindow").style.left="30px"
		document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
		document.getElementById("cframe").src=url
	}
}

function maximize(){
	if (minrestore==0){
		minrestore=1 //maximize window
		document.getElementById("maxname").setAttribute("src","restore.gif")
		document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
		document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
	}
	else{
		minrestore=0 //restore window
		document.getElementById("maxname").setAttribute("src","max.gif")
		document.getElementById("dwindow").style.width=initialwidth
		document.getElementById("dwindow").style.height=initialheight
	}
	document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
	document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
	document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
	dragapproved=false;
	document.getElementById("dwindow").onmousemove=null;
	document.getElementById("dwindowcontent").style.display="" //extra
}

function minisite(pageName){
	dimm();
	if ($('minisiteBox')){
		document.body.removeChild($('minisiteBox'));
		return false;
	}
	iframe = document.createElement('iframe');
	div = document.createElement('div');
	div.id = 'minisiteBox';
	//iframe.src = 'minisite/minisite.htm';
	iframe.src = pageName;
	div.appendChild(iframe);
	document.body.appendChild(div);

}

function showMinisite(pageName){
	var pageName1=pageName;
	minisite(pageName1);
}


function setMiniCookie(value){
	showmini = (value)?value:((document.forms[0].mini.value="")?"off":"on");
	setCookie( 'showmini', showmini, 365, "/", "shopfromisrael.com", false );
}
function getMiniCookie(){
	return getCookie('showmini')
}

function closeMinisite() {
	if (parent) {parent.minisite();return false}
}


function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
		element = document.getElementById(element);
		if (arguments.length == 1)
		return element;
		elements.push(element);
	}
	return elements;
}
// like php $_GET
function $_get(name){
	querystring = window.location.search;
	if (!querystring) return "";
	start = querystring.indexOf(name+"=");
	if (start<0) return "";
	end = querystring.indexOf("&",start);
	if (end<0) end = querystring.length;
	value = querystring.substr(start + name.length + 1,end);
	return value;
}

function submitSectionSettings(){
	var pagesNameArray = new Array('content/section.php','content/categoryTreeList.php');
	var refreshElementsArray = new Array ('content','listOfCats');
	var formNameArray = new Array ('sectionSettingsForm');
	reloadPageWArray(pagesNameArray,refreshElementsArray,formNameArray);
}

function handleApprovalItem(itemID) {
	var countItems = getText('listOfItemsToApprove');
	var currentItems = getFieldValue('itemsToApprove');
	if (getFieldValue('fieldItem'+itemID)==0) {
		currentItems += itemID+',';
		changePic('item'+itemID,'images/greenSquare.gif');
		changeFieldValue('fieldItem'+itemID,1);
		changeFieldValue('itemsToApprove',currentItems);
		countItems++;
		enableBtn('doApproveBtn');
	} else {
		currentItems = currentItems.replace(itemID+',','');
		changeFieldValue('itemsToApprove',currentItems);
		changePic('item'+itemID,'images/graySquare.gif');
		changeFieldValue('fieldItem'+itemID,0);
		countItems--;
		if (countItems==0) disableBtn('doApproveBtn');
	}
	changeText('listOfItemsToApprove',countItems);
}



function handlwWatermarksMultipleSelect(itemID) {
	var countItems = getText('listOfItemsToApprove');
	var currentItems = getFieldValue('itemsToApprove');
	if (getFieldValue('fieldItem'+itemID)==0) {
		currentItems += itemID+',';
		changePic('item'+itemID,'images/greenSquare.gif');
		changeFieldValue('fieldItem'+itemID,1);
		changeFieldValue('itemsToApprove',currentItems);
		countItems++;
		showByID('doApproveBtn');
		hideByID('generalFilter');
	} else {
		currentItems = currentItems.replace(itemID+',','');
		changeFieldValue('itemsToApprove',currentItems);
		changePic('item'+itemID,'images/graySquare.gif');
		changeFieldValue('fieldItem'+itemID,0);
		countItems--;
		if (countItems==0) {
			hideByID('doApproveBtn');
			showByID('generalFilter');
		}
	}
	changeText('listOfItemsToApprove',countItems);
}



function handleCurExtensionList(fieldName,isContentItem) {
	changeFieldValue('curlistid_'+fieldName,getFieldValue('curlist_'+fieldName));
	if (isContentItem==0) {
		var curListText = '';
		curListText=getFieldText('curlist_'+fieldName);
		if (curListText) 	changeFieldValue(fieldName,curListText);
		changeFieldValue('curlisttext_'+fieldName,curListText);
		disableBtn('insert_'+fieldName);
		enableBtn('edit_'+fieldName);
		enableBtn('child_'+fieldName);
		enableBtn('remove_'+fieldName);
		showByID('childs_'+fieldName);
		var subs = getFieldValue('subs_'+fieldName);
		if (subs) {
			var subsArray = subs.split(",");
			for (var i=0;i<subsArray.length;i++) {
				iAdditionalFields=0;
				changeFieldValue(subsArray[i],'%');
				
				handleContentExtensionField(subsArray[i],'0',37,1);
			}
		}
	} else {
		changeFieldValue(fieldName,getFieldValue('curlist_'+fieldName));
	}
}


function handlePermissionsBc(breadCrumbID,mode,permissionType) {
	var newAction;
	if (permissionType=='a' && getFieldValue('bc_permissionField_'+breadCrumbID) != 'a') {
		changeFieldValue('bc_permissionField_'+breadCrumbID,'a');
		changePic('bc_permissions_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');
		changePic('bc_permissions_r_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');
		changePic('bc_permissions_i_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');
		changePic('bc_permissions_u_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');
		changePic('bc_permissions_d_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');
	} else if (permissionType=='a' && getFieldValue('bc_permissionField_'+breadCrumbID) == 'a') {
		changeFieldValue('bc_permissionField_'+breadCrumbID,'');
		changePic('bc_permissions_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		changePic('bc_permissions_r_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		changePic('bc_permissions_i_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		changePic('bc_permissions_u_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		changePic('bc_permissions_d_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
	} else {
		changePic('bc_permissions_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		var currentVal = getFieldValue('bc_permissionField_'+breadCrumbID);
		if (currentVal=='a') { // means the whole actions are allowed for this module!
			if (permissionType=='r') newAction='iud';
			if (permissionType=='i') newAction='rud';
			if (permissionType=='u') newAction='rid';
			if (permissionType=='d') newAction='riu';
			changePic('bc_permissions_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
			changePic('bc_permissions_'+permissionType+'_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
		} else {
			if (currentVal.indexOf(permissionType) == -1) { // means we are adding!
				changePic('bc_permissions_'+permissionType+'_'+breadCrumbID,'/ezadmin3/images/greenSquare.gif');	
				newAction = currentVal+permissionType;
			} else { //means we are removing permission
				changePic('bc_permissions_'+permissionType+'_'+breadCrumbID,'/ezadmin3/images/graySquare.gif');
				newAction = currentVal.replace(permissionType,'');
			}
		}
			changeFieldValue('bc_permissionField_'+breadCrumbID,newAction);
	}

	
	var elem = document.getElementById('authForm').elements;
	for(var i = 0; i < elem.length; i++) {
		if (elem[i].type=='hidden') {
			if (elem[i].id.indexOf('bc_parnt_'+breadCrumbID+'_')!=-1) {
				handlePermissionsBc(elem[i].value,mode,permissionType)
			} 
		}	
	}

}

function expandListOfModules(breadCrumbsID,mode) {
	var listOfRowsBc = getFieldValue('bcfor_'+breadCrumbsID);
	var b;
	listOfRowsBc = listOfRowsBc.split(',');
	for (b in listOfRowsBc) {
		if (document.getElementById('bc_row'+listOfRowsBc[b]).style.display=='') {
			document.getElementById('bc_row'+listOfRowsBc[b]).style.display='none';
		} else {
			document.getElementById('bc_row'+listOfRowsBc[b]).style.display='';	
		}
	}
	
	if (getText('btnExpand_'+breadCrumbsID)=="+") {
		changeText('btnExpand_'+breadCrumbsID,'-');
	} else {
		changeText('btnExpand_'+breadCrumbsID,'+');
	}
}

function handlePermissionForCat(id,newMode) {
	var btn;
	var newModeChange;
	if (newMode=="on") {
		btn='green'; 
		newModeChange='off';
	} else { 
		btn='gray';
		newModeChange='on';
	}
	changeFieldValue('newVal'+id,newModeChange);
	changeFieldValue('verify'+id,newMode);
	
	changePic('checkbx_'+id,'/ezadmin3/images/'+btn+'Square.gif');
	
	var elem = document.getElementById('sectionsListForm').elements;
	for(var i = 0; i < elem.length; i++) {
		if (elem[i].type=='hidden') {
			if (elem[i].id.indexOf('parent_'+id)!=-1) {
				handlePermissionForCat(elem[i].value,newMode);
			} 
		}	
	}
	
}

