function clearTopMenu(){
	L=top.document.getElementById('top_menu_div');
	L.innerHTML='';
}

function trim(s) {
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}
	return s;
}

function preparePN(pnObj) {
	return prepareSN(pnObj);
}

/**
set to upper case and trims the string, if consist of space - stops
*/
function prepareSN(snObj) {
	snObj.value=snObj.value.toUpperCase();
	re = /^[ ]{1,}|[ ]{1,}$/gi;
	snObj.value=snObj.value.replace(re, "");
	re=/[^\/0-9A-Z_-]/gi;
	if(re.test(snObj.value)) {
		alert('Only alphanumerics, "-" and "_" are allowed! ('+snObj.value+') ');
		snObj.value='';
		snObj.focus();
		snObj.select();
		return(false);
	}
	return(true);
}

function checkWo (wo_obj){
	re=/^\d{6}$/;
	if (re.test(wo_obj.value)) {
		return true;
	}else{
		alert('Please enter correct WO (6 digits only)');
		markFormElement(wo_obj);
		wo_obj.focus();
		return false;
	}
};
function arrangeWindow(sizeX,sizeY,posX,posY) {
	if(!sizeX) {
		sizeX=0.7;
	}
	if(!sizeY) {
		sizeY=sizeX;
	}
	self.resizeTo(screen.width*sizeX,screen.height*sizeY);

	if(!posX) {
		posX=(1-sizeX)/2;
		posY=(1-sizeY)/2;
	}
	if(!posY){
		posY=(1-sizeY)/2;
	}
	self.moveTo(screen.width*posX,screen.height*posY);
	self.focus();
}

function showContextMenu(){
	var L=top.document.getElementById('my_context_menu');
	var I=top.document.getElementById('menuShim');
	var htmlSting="<A href='#'  class='orange_button' onclick='hideContextMenu();'>X [Close]</A>";
	var target_t;

	htmlSting+='<TABLE class=x style="margin:10px 0px 0px 0px ">';
	//	htmlSting+='<TR><TD class=x><A class="orange_button" href="#" onclick="top.main.location.href=\'/qms3/sn_module/sn_search.php\';hideContextMenu();" >Search SN</A>';
	//	htmlSting+='<TR><TD class=x><A class="orange_button" href="#" onclick="top.main.location.href=\'/qms3/sn_module/create_list.php?modeofform=show_list\';hideContextMenu();" >Show SN list</A>';

	//	htmlSting+='<TR><TD class=x><hr style="width:100%">';
	
	for(var i=0 ; i<top.lastMovesUrlArray.length ; i++){
		target_t = (top.lastMovesDesArray[i] == 'Search results') ? 'temp' : 'main' ;
		htmlSting+='<TR><TD class=x><A  class="orange_button" href="#" onclick="'+target_t+'.location.href=\''+top.lastMovesUrlArray[i]+'\';hideContextMenu();" >'+top.lastMovesDesArray[i]+'</A></li>';
	}
	htmlSting+="</TABLE>";
	L.innerHTML=htmlSting;

	L.style.left=240*top.factor;
	L.style.top=130*top.factor;

	L.style.visibility = 'visible';
	L.style.display = 'block';
	I.style.left = L.style.left ;
	I.style.top = L.style.top ;
	I.style.width = L.offsetWidth;
	I.style.height = L.offsetHeight;
	I.style.zIndex = L.style.zIndex - 1;
	I.style.visibility = 'visible';
	I.style.display = "block";

	return false;
}

function hideContextMenu() {
	if(top.name=='QMS3') {
		var L=top.document.getElementById('my_context_menu');
		var I=top.document.getElementById('menuShim');
	}else{
		var L=opener.top.document.getElementById('my_context_menu');
		var I=opener.top.document.getElementById('menuShim');
	}
	L.style.visibility = 'hidden';
	L.style.display = 'none';

	I.style.visibility = 'hidden';
	I.style.display = 'none';
}

function hideRemarks() {
	if(top.name=='QMS3') {
		var L=top.document.getElementById('remarks');
	}else{
		var L=opener.top.document.getElementById('remarks');
	}
	L.style.visibility = 'hidden';
	L.style.display = 'none';
}


function addLastMove(description,url,skip) {
	var temp;
	//	var theSelect=top.document.forms[0].lastMovesSelect;

	for(var i=0 ; i<top.lastMovesUrlArray.length ; i++){
		if( url == top.lastMovesUrlArray[i] && description!=''){
			//alert('found duplicat splice it!!');
			top.lastMovesUrlArray.splice(i,1);
			top.lastMovesDesArray.splice(i,1);
		}
	}

	top.lastMovesUrlArray.unshift(url);
	top.lastMovesDesArray.unshift(description);
	while(top.lastMovesUrlArray.length > 25){
		temp=top.lastMovesUrlArray.pop();
		temp=top.lastMovesDesArray.pop();
	}

	//	while(theSelect.options.length > top.lastMovesUrlArray.length){
	//		temp=theSelect.pop();
	//	}
	//	theSelect.length=top.lastMovesUrlArray.length;
	//	for (var loop=0; loop < top.lastMovesUrlArray.length; loop++){
	//		theSelect.options[loop].text=top.lastMovesDesArray[loop];
	//		theSelect.options[loop].value=loop;
	//	}


	//	theSelect.selectedIndex=0;
	//}
}


function update_all_images() {
	if(top.name=='moon' || top.name=='remark'){
		var wFactor=opener.top.factor;
	}else{
		var wFactor=top.factor;
	}
	for(var i=0;i<document.images.length;i++){
		document.images[i].width*=wFactor;
	}
}

function end_body_load(){
	if(top.name=='QMS3') {
		//top.document.getElementById('remarks').style.visibility='hidden';
		document.body.style.fontSize=top.document.body.style.fontSize;
		top.document.getElementById('waiting').style.visibility='hidden';
	}else{
		//opener.top.document.getElementById('remarks').style.visibility='hidden';
		document.body.style.fontSize=opener.top.document.body.style.fontSize;
		opener.top.document.getElementById('waiting').style.visibility='hidden';
	}
	if(window.name=='main'){
		top.document.getElementById('remarks').style.visibility='hidden';
	}
	if(screen.width >= 1600||screen.width < 1024){
		update_all_images();
	}
	if(document.getElementById('tbl-container')) {
		document.getElementById('tbl-container').style.height = document.documentElement.clientHeight-100;
//		alert(document.getElementById('tbl-container').style.height);
	}
	document.body.style.cursor = "default";
	hideContextMenu();
}


var nn4 = (document.layers) ? true : false;
var dom = (document.getElementById ) ? true : false;
var ie = (document.all&& !dom) ? true : false;

// from http://www.jennifermadden.com/162/examples/dhtml/browserSnif.html
/*
function setOpacity(id,opac){
var agent=navigator.userAgent.toLowerCase();
var layer=browser(id);
if(agent.indexOf("msie") != -1){
layer.style.filter='alpha(opacity='+opac+')';
}else{
layer.style.MozOpacity=opac/100;
}
}

var first_opac = 20;
var sec_opac =100;
var opac = first_opac;
var speed = 6;
var si;
var cleared = true;

function fade(id,doshow){
cleared = false;
(doshow) ? opac+=speed : opac-=speed;
setOpacity(id,opac);
if (opac <= first_opac || opac >= sec_opac) {
clearInterval(si);
cleared = true;
}
}

function ClearInt() {
if (!cleared) clearInterval(si);
}
*/

/*if(nn4){
netscape 4 statements here...
}
else if(ie){
ie statments here...
}
*/

function browser(id){
	if(nn4) {
		path = document.layers[id];
	}else if(ie) {
		path = document.all[id];
	}else {
		path = document.getElementById(id);
	}
	return path ; //return the path to the css layer depending on which browser is looking at the page
}

function hideLayer(id){
	var layer = browser(id) ;// call browser sniffing function, assign variable name to returned value
	if(nn4){
		layer.visibility = "hidden";
		layer.display='none';
	}
	else {
		layer.style.visibility = "hidden";
		layer.style.display='none';
	}
}

function showLayer(id) {
	var layer = browser(id);
	if(nn4){
		layer.visibility = "visible";
		layer.display='block';
	}
	else{
		layer.style.visibility = "visible";
		layer.style.display='block';
	}

	//first_opac = 20;
	//fade(id,true);
}

function hideItem(itemName){
	if(itemName) {
		itemName.style.visibility = "hidden";
		itemName.style.display="none";
	}
}

function showItem(itemName) {
	if(itemName) {
		itemName.style.visibility = "visible";
		itemName.style.display="block";
	}
}

/***********************************************************************************
***********************************************************************************/
//content - self explenatory
//mili - time to be shown
//e - the event

function showTip(content,mili,e){
	var layer= browser('Tip');
	if(nn4){
		layer.document.open();
		layer.document.write(content);
		layer.document.close();
	}else{
		layer.innerHTML = content;
	}
	document.body.style.cursor='wait';
	mainTimer=setTimeout("showLayer('Tip')",mili);
	if(e){
		var x = e.pageX? e.pageX: e.clientX ;
		var y = e.pageY? e.pageY: e.clientY;
		moveLayer('Tip',x-3,y-3);
	}
}


function moveLayer(id,x,y) {
	//alert(x+'/'+y);
	var layer = browser(id) ;// get browser specific path to block element
	if(nn4){
		layer.top=y;
		layer.left=x;
	}else{
		layer.style.top=y;
		layer.style.left=x;
	}
}

function update_date(object_to_update){//returns old value update d/m/y
	_today=new Date();
	_day=_today.getDate();
	_month=_today.getMonth()+1;
	_year=_today.getYear();
	_string=_day+'/'+_month+'/'+_year;
	_old_value=object_to_update.value;
	object_to_update.value=_string;
	return _old_value;
}
function not_empty(object_to_check){
	if (object_to_check.value!=''){
		return true;
	}else{
		alert('Field must be filled!');
		object_to_check.focus();
		return false;
	}
}


function eCheckFloat(sn){
	s= sn.value;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if (!((ch >= "0" && ch <= "9") || ch=="." || ch==","))
		return false;
	}
	return true;
}

function markFormElement(field) {
	//		field.style.color='red';
	//		field.style.backgroundColor='#FFECEC';
	field.className='marked';
	//		alert('Pleae fix the needed entry.');
}

function unMarkFormElement(field) {
	//		field.style.color='red';
	//		field.style.backgroundColor='#FFECEC';
	field.className='';
	//		alert('Pleae fix the needed entry.');
}

function glowField(fieldText,color) { //passed as text
	if(color==undefined) {
		color='lightgreen';
	}
	eval(fieldText+".style.backgroundColor='"+color+"'");
	var the_timeout = setTimeout(fieldText+".style.backgroundColor='';"+fieldText+".className=''",1000);
}



function CheckFloat(theForm){
	for(var i=1; i<CheckFloat.arguments.length; i++)
	if (!eCheckFloat(theForm.elements[CheckFloat.arguments[i]])){
		//alert("Invalid number");
		markFormElement(theForm.elements[CheckFloat.arguments[i]]);
		theForm.elements[CheckFloat.arguments[i]].focus();
		return false;
	}
	return true;
};
function eCheckNum(sn){
	s= sn.value;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if (!(ch >= "0" && ch <= "9"))
		return false;
	}
	return true;
}
function CheckNum(theForm){
	for(var i=1; i<CheckNum.arguments.length; i++)
	if (!eCheckNum(theForm.elements[CheckNum.arguments[i]])){
		//alert("Invalid number");
		markFormElement(theForm.elements[CheckNum.arguments[i]]);
		theForm.elements[CheckNum.arguments[i]].focus();
		return false;
	}
	return true;
}

function eCheckTime(sn) {
	s= sn.value;
	i=0;
	tm= new Array();
	tm[0]= '';tm[1]= '';tm[2]='';tm[3]= '';tm[4]='';
	md = 0 ;

	while (i< s.length) {
		ch= s.substring(i, i + 1);
		if( ch<='9' && ch>='0')
		tm[md] += ch;
		else if(ch==':') md++;
		else if (ch==' ') {
			if(md<2) return false;
			md++;
		}
		else if(md>=2 && md<=3){
			tmp= s.substring(i, i + 2);
			tmp = tmp.toUppercase();
			if ( tmp=='AM' || tmp=='PM')
			{
				tm[3]= tmp;
				++i;
				md++;
			}
			else return false;
		}
		else return false;
		i++;
	}

	if(tm[4]!='') return false;
	if( tm[0].valueOf()<1 || tm[0].valueOf()>23) return false;
	if(tm[0].valueOf()<13 && tm[3]=='') //Specify am/pm
	return false;

	if(tm[0].valueOf()>12 && tm[3]!='') //don't Specify am/pm
	return false;

	if( tm[1].valueOf()<1 || tm[1].valueOf()>59) return false;

	if(tm[2]!='')
	if( tm[2].valueOf()<1 || tm[2].valueOf()>59) return false;

	return (tm[4]=='');
}

function CheckTime(theForm){
	for(var i=1; i<CheckTime.arguments.length; i++)
	if (!eCheckTime(theForm.elements[CheckTime.arguments[i]])){
		//alert("Invalid Time");
		markFormElement(theForm.elements[CheckTime.arguments[i]]);
		theForm.elements[CheckTime.arguments[i]].focus();
		return false;
	}
	return true;
}
function eCheckDate(sn) {
	s= sn.value;
	var i=0;
	tm= new Array();
	tm[0]= '';tm[1]= '';tm[2]='';tm[3]='';
	sep='';
	md = 0 ;

	while (i< s.length) {
		ch= s.substring(i, i + 1);
		if( ch<='9' && ch>='0')
		tm[md] += ch;
		else if (sep=='') {
			if(ch=='.' || ch=='/' || ch=='-') {
				md++;
				sep=ch;
			}
		}
		else if (ch==sep) {
			md++;
			if(md>2) return false;
		}
		else return false;

		i++;
	}

	if(tm[3]!='') return false;
	if(tm[1].valueOf()<1 || tm[1].valueOf()>12) return false; //Month
	if(tm[0].valueOf()<1 || tm[0].valueOf()>31) return false;
	if(tm[2].valueOf()<100) return false;

	if ((tm[1]==4 || tm[1]==6 || tm[1]==9 || tm[1]==11) && tm[0]==31)
	return false;
	if (tm[1]==2) {
		isleap = (tm[2] % 4 == 0 && (tm[2] % 100 != 0 || tm[2] % 400 == 0));
		if (tm[0]>29 || (tm[0]==29 && !isleap))
		return false;
	}

	return (tm[3]=='');
}

function CheckDate(theForm){
	for(var i=1; i<CheckDate.arguments.length; i++)
	if (!eCheckDate(theForm.elements[CheckDate.arguments[i]])){
		//alert("Invalid Date");
		markFormElement(theForm.elements[CheckDate.arguments[i]]);
		theForm.elements[CheckDate.arguments[i]].focus();
		return false;
	}
	return true;
}
function dMyeCheckDate(sn) {
	tm=sn.value.split(".");

	if(tm[1]!='Jan' && tm[1]!='Feb' && tm[1]!='Mar' && tm[1]!='Apr' && tm[1]!='May' && tm[1]!='Jun' && tm[1]!='Jul' && tm[1]!='Aug' && tm[1]!='Sep' && tm[1]!='Oct' && tm[1]!='Nov' && tm[1]!='Dec' ) return false; //Month
	if(tm[0].valueOf()<1 || tm[0].valueOf()>31|| tm[0].length!=2) return false;
	if(tm[2].valueOf()>100 || tm[2].valueOf()<0 ||tm[2].length!=2) return false;

	if ((tm[1]=='Apr' || tm[1]=='Jun' || tm[1]=='Sep' || tm[1]=='Nov') && tm[0]==31)
	return false;
	if (tm[1]==2) {
		isleap = (tm[2] % 4 == 0 && (tm[2] % 100 != 0 || tm[2] % 400 == 0));
		if (tm[0]>29 || (tm[0]==29 && !isleap))
		return false;
	}

	return true;
}

function dMyCheckDate(theForm){
	for(var i=1; i<dMyCheckDate.arguments.length; i++)
	if (!dMyeCheckDate(theForm.elements[dMyCheckDate.arguments[i]])){
		//alert("Invalid Date");
		markFormElement(theForm.elements[dMyCheckDate.arguments[i]]);
		theForm.elements[dMyCheckDate.arguments[i]].focus();
		return false;
	}
	return true;
}

function eCheckAlphaNum(sn){
	s= sn.value;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
		|| (ch >= "0" && ch <= "9")))
		return false;
	}
	return true;
}
function CheckAlphaNum(theForm){
	for(var i=1; i<CheckAlphaNum.arguments.length; i++)
	if (!eCheckAlphaNum(theForm.elements[CheckAlphaNum.arguments[i]])){
		//alert("Field entry is not valid");
		markFormElement(theForm.elements[CheckAlphaNum.arguments[i]]);
		theForm.elements[CheckAlphaNum.arguments[i]].focus();
		return false;
	}
	return true;
}

function eCheckAlphaField(sn){
	s= sn.value;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
		|| (ch >= "0" && ch <= "9")||(ch==" ")||(ch==".")||(ch=="-")||(ch=="[")||(ch=="]")||(ch=="{")||(ch=="}")||(ch=="(")||(ch==")")
		||(ch=="+")||(ch=="=")||(ch=="^")||(ch=="@")||(ch=="=")||(ch=="!")||(ch=="#")||(ch=="%")||(ch=="$")))
		return false;
	}
	return true;
}
function CheckAlphaField(theForm){
	for(var i=1; i< CheckAlphaField.arguments.length; i++)
	if (!eCheckAlphaField(theForm.elements[CheckAlphaField.arguments[i]])){
		//alert("Field entry must not include \" or ' or | and  ");
		markFormElement(theForm.elements[CheckAlphaField.arguments[i]]);
		theForm.elements[CheckAlphaField.arguments[i]].focus();
		return false;
	}
	return true;
}

function eCheckAlpha(sn){
	s= sn.value;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")))
		return false;
	}
	return true;
}

function CheckAlpha(theForm){
	for(var i=1; i<CheckAlpha.arguments.length; i++)
	if (!eCheckAlpha(theForm.elements[CheckAlpha.arguments[i]])){
		//alert("Field entry is not valid");
		markFormElement(theForm.elements[CheckAlpha.arguments[i]]);
		theForm.elements[CheckAlpha.arguments[i]].focus();
		return false;
	}
	return true;
}

function eCheckEMail(sn){
	s= sn.value;
	if (s.indexOf("@") == -1) return false;
	if (s.indexOf(".") == -1) return false;
	at=false;
	dot=false;
	for (var i = 0; i < s.length; i++) {
		ch = s.substring(i, i + 1)
		if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
		|| (ch == "@") || (ch == ".") || (ch == "_")
		|| (ch == "-") || (ch >= "0" && ch <= "9")) {
			if (ch == "@"){
				if (at) return false;
				else at=true;
			}
			if ((ch==".") && at)
			dot=true;
		}
		else return false;
	}
	return dot;
}

function CheckEMail(theForm) {
	for(var i=1; i<CheckEMail.arguments.length; i++)
	if (!eCheckEMail(theForm.elements[CheckEMail.arguments[i]])) {
		//alert("Field entry is not valid");
		markFormElement(theForm.elements[CheckEMail.arguments[i]]);
		//theForm.elements[CheckEMail.arguments[i]].style.fontWight='bold';
		theForm.elements[CheckEMail.arguments[i]].focus();
		return false;
	}
	return true;
}


function CheckRequiredFields(theForm) {
	for(i=1; i<theForm.elements.length; i++) {
		theForm.elements[i].style.color='black';
		theForm.elements[i].style.backgroundColor='white';
	}

	var isOK=true;
	for(i=1; i<CheckRequiredFields.arguments.length; i++) {
		if(theForm.elements[CheckRequiredFields.arguments[i]].value=="") {
			markFormElement(theForm.elements[CheckRequiredFields.arguments[i]]);
			theForm.elements[CheckRequiredFields.arguments[i]].focus();
			isOK=false;
		}
	}
	return isOK;
}

/************************************************************************
list is a comma separated list of "text|value"
*************************************************************************/
function BuildSelect(list,theSelect){
	if(list!=''){
		var list_array = list.split(",");
		s=list_array.sort();
		theSelect.length=s.length;
		for (var loop=0; loop < s.length; loop++)
		{
			var name_id=s[loop].split('|');
			theSelect.options[loop]=new Option(name_id[0],name_id[1]);
		}
	}else{
		theSelect.length=0;
	}
}
/************************************************************************
list is a comma separated list of "text|value"
*************************************************************************/
function BuildSelectNoSort(list,theSelect){
	if(list!=''){
		var list_array = list.split(",");
		theSelect.length=list_array.length;
		for (var loop=0; loop < list_array.length; loop++)
		{
			var name_id=list_array[loop].split('|');
			theSelect.options[loop]=new Option(name_id[0],name_id[1]);
		}
	}else{
		theSelect.length=0;
	}
}

function SwitchItem(from_select,to_select){
	if(from_select.selectedIndex>=0){
		var the_index = from_select.selectedIndex;
		to_select.length=to_select.length +1;
		to_select.options[to_select.length-1].text=from_select.options[the_index].text;
		/************************* sorting the select *********************/
		var temp_array= new Array();
		temp_array.length=to_select.length;
		for (var loop=0; loop < to_select.length; loop++)
		{
			temp_array[loop]=to_select.options[loop].text;
		}
		temp_array.sort();
		for (var loop=0; loop < to_select.length; loop++)
		{
			to_select.options[loop].text=temp_array[loop];
		}
		/************************* removing the select *********************/
		from_select.options[the_index].text='AAAAAAAAAAA';
		/************************* sorting the select *********************/
		var temp_array= new Array();
		temp_array.length=from_select.length;
		for (var loop=0; loop < from_select.length; loop++)
		{
			temp_array[loop]=from_select.options[loop].text;
		}
		temp_array.sort();
		temp_array=temp_array.slice(1, temp_array.length);
		from_select.length=from_select.length-1;
		for (var loop=0; loop < from_select.length; loop++)
		{
			from_select.options[loop].text=temp_array[loop];
		}
	}
}

/************************************************************************
list is an array of "text|value" used in ItemSwitch
*************************************************************************/
function makeSelect(list,theSelect){
	if(list.length!=0){
		s=list.sort();
		theSelect.length=s.length;
		for (var loop=0; loop < s.length; loop++)
		{
			var name_id=s[loop].split('|');
			theSelect.options[loop].text=name_id[0];
			theSelect.options[loop].value=name_id[1];
		}
	}else{
		theSelect.length=0;
	}
}

/************************************************************************
list is a string saparated with  "|"
*************************************************************************/
function markSelectByValue(list,theSelect){
	if(list.length!=0){
		for (var loop=0; loop < theSelect.length; loop++) {
			if(list.search(theSelect.options[loop].value)!=-1)
			theSelect.options[loop].selected=true;
		}
	}
}

/************************************************************************
list will by a string saparated with  "|"
*************************************************************************/
function getListOfValues(theSelect){
	var str=dlmt='';
	for (var loop=0; loop < theSelect.length; loop++){
		str+=dlmt+theSelect.options[loop].value;
		dlmt='|';
	}
	return str;
}

/************************************************************************
list will by a string saparated with  "|"
*************************************************************************/
function getListOfSelected(theSelect){
	var str=dlmt='';
	for (var loop=0; loop < theSelect.length; loop++){
		if(theSelect.options[loop].selected){
			str+=dlmt+theSelect.options[loop].value;
			dlmt='|';
		}
	}
	return str;
}


function ItemSwitch(fromSelect,toSelect){
	var i=1;
	var fromArraySelected=new Array();
	var fromArrayLeft=new Array();
	var toArray=new Array();
	for (loop=0; loop < fromSelect.options.length; loop++){
		if (fromSelect.options[loop].selected==true){
			fromArraySelected.length++;
			fromArraySelected[fromArraySelected.length-1]=fromSelect.options[loop].text+'|'+fromSelect.options[loop].value;
		}else{
			fromArrayLeft.length++;
			fromArrayLeft[fromArrayLeft.length-1]=fromSelect.options[loop].text+'|'+fromSelect.options[loop].value;
		}
	}
	for (loop=0; loop < toSelect.options.length; loop++){
		toArray.length++;
		toArray[toArray.length-1]=toSelect.options[loop].text+'|'+toSelect.options[loop].value;
	}

	toArray=toArray.concat(fromArraySelected);

	makeSelect(fromArrayLeft,fromSelect);
	makeSelect(toArray,toSelect);

}



/*************************************************************
C O O C K I E S
*************************************************************/
function setCookie(name,value,days,path,domain,secure) {
	var expires, date;
	if (typeof days == "number") {
		date = new Date();
		date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
	}
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
	var nameq = name + "=";
	var c_ar = document.cookie.split(';');
	for (var i=0; i<c_ar.length; i++) {
		var c = c_ar[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
	}
	return null;
}

// from Bill Dortch's Cookie Functions (hidaho.com)
function deleteCookie(name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

