function textsearch(){
	for( var i = 0; i < document.forms.length; i++ ){
		var aform = document.forms[i];
		for( var k = 0; k < aform.elements.length; k++ ){
			if ( aform.elements[k].name == "itemcode" ){		
				var formno = i;									
			}
		}
	}
	var form = document.forms[formno];
	if( form.searchtxt.value != "" ){
		window.location="/newmail.nsf/engsearch?SearchView&Query=" + form.searchtxt.value + "&SearchFuzzy=TRUE";
	}
}

//***********************************************************itemtrace*************************************************	
var baseurl = "/itemtrace.nsf/trackandtrace?OpenAgent";
var newwinapp = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=820,height=450,top=20,left=30";

//remove given sign from string and return the result
function removesign(	thestring,
						thesign
){
	var newstring = "";
	if( thestring.indexofthesign == -1 ){
		return thestring;
	} else {
		for( i = 0, j = 0; i <= thestring.length; i++ ){
			if( thestring.charAt(i) != thesign ){
				newstring = newstring+thestring.charAt(i);
			}
		}
		return newstring;
	}
}

function gotrace(	itemcode,
					lang,
					location
){
	var urlstr  = "";
	var lg  = "EN";
	for( var i = 0; i < document.forms.length; i++ ){
		var aform = document.forms[i];
		for( var k = 0; k < aform.elements.length; k++ ){
			if ( aform.elements[k].name == "itemcode" ){
				var formno = i;
			}
		}
	}
	var form = document.forms[formno];
	if( itemcode == "" ) itemcode = gVEN("itemcode"); //form.itemcode.value;
	if( lang == "" ) lang = "EN";
	if( location == "" ) location = "HOMPAGE";

	itemcode = itemcode.toUpperCase();

	lang = lang.toUpperCase();

	lg = lang.substring( 0, 2 );

	itemcode = removesign( itemcode, "-" );
	itemcode = removesign( itemcode, " " );

	if( itemcode.length == 13 || itemcode.length == 8 ){
		urlstr = baseurl + "&lang=" + lang + "&location=" + location + "&itemcode=" + itemcode;
		x = window.open( urlstr, "itemcodeinfo", newwinapp );
		x.focus();
	} else {
		traceerror(itemcode);
//			 alert("המספר שהקלדת שגוי יש להקיש את המספר ברציפות ללא רווחים או מקפים בן 8 או 13 ספרות לדוגמא RR99999999IL ");
//			 document.forms[0].ItemCode.value = "RR999999999IL"; 
	}
}	
//*****************************end of itemtrace****************************************************************************
function runtrack(){
	gotrace( '', 'ENG', 'HOMEPAGE' );
}
function traceerror( itemno
){
		var newwinapp2 = "scrollbars=yes width=800 height=410 top=20 left=30";
		x = window.open( "/itemtrace.nsf/trackerror?openform&L=EN&code=" + itemno, "itemcodeinfo", newwinapp2 );
}
//PopUp box
function showPopUp( type
){
	var track = "An Item code contains 8 or 13 characters only. Please enter the number without spaces or any other symbols.<BR>For example - RR123456789IL";
	e = event.srcElement;
	var top1 = '';
	var top2 = '';
	top1 = parseInt( document.body.scrollTop ) - 1;
	top2 = parseInt( event.y );
	var wd = screen.width;
	
	//	popupwin.style.top = (top2+25);
	if( type == "track" ){
			popupwin.style.top = 135;
			the_cell.innerHTML = track;
			if( wd == 800 ){
				popupwin.style.left = 655;
			}
	}
	popupwin.style.display="inline";
}

function closePopUp(){
	popupwin.style.display = 'none';
}

