function on3(name)
{
	document[name].src = eval(name + "on.src");
}
function off3(name)
{
	document[name].src = eval(name + ".src");
}
NN3 = true;

function on(name)
{
	if (NN3) on3(name);
}
function off(name)
{
	if (NN3) off3(name);
}

function go_clicked(form)
{
	form.submited.value="yes";
}

function bpressed(el,btn)
{
	el.form.submitted.value=btn;
}

function check_changed(element,text)
{
	if(!element.checked)
	{
		alert(text);
	}
}

function OpenWorkingMessagePopUp(sText) 
	{
	    var height = 80; // Height of popup
	    var width = 450; // Width of popup
	    var attributes = 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,status=no,titlebar=no,width=' + width + ',height=' + height + ',left=' + (screen.availWidth - width) / 2 + ',top=' + (screen.availHeight - height) / 2;
		
	    var WorkingPopup_SITM = window.open('', 'workingPopUp', attributes);
	    if (WorkingPopup_SITM != null) {
			
	        WorkingPopup_SITM.document.write('<html>');
			WorkingPopup_SITM.document.write('<head>');
	        WorkingPopup_SITM.document.write('<title>Please wait...</title>');
			WorkingPopup_SITM.document.write('</head>');
	        WorkingPopup_SITM.document.write('<body onload=\'self.focus();\' onblur=\'self.focus();\' bgcolor=\'#dadada\'>');
	        
	        WorkingPopup_SITM.document.write("<div id='divLoading' style='display:block;");
			
			WorkingPopup_SITM.document.write("background-color: #dadada;");
			WorkingPopup_SITM.document.write("filter:alpha(opacity=80);");
			WorkingPopup_SITM.document.write("-moz-opacity: 0.8;");
			WorkingPopup_SITM.document.write("opacity: 0.8;");
			
			
			
			WorkingPopup_SITM.document.write("width: 98%;");
			WorkingPopup_SITM.document.write("text-align: center;'>");
			
			WorkingPopup_SITM.document.write("<div id='siteDetailLoader' style='");
			WorkingPopup_SITM.document.write("font-family: Verdana, Arial;");
			WorkingPopup_SITM.document.write("font-size: 10px;");
			WorkingPopup_SITM.document.write("color: #5D6064;	");
	    	WorkingPopup_SITM.document.write("text-align: right;  '>");
			
			
			WorkingPopup_SITM.document.write("&nbsp;");
			WorkingPopup_SITM.document.write("</div>");
			WorkingPopup_SITM.document.write("<div id='loadImg' style='");
			WorkingPopup_SITM.document.write("text-align: center;");
			WorkingPopup_SITM.document.write("background-color: #dadada;");
			WorkingPopup_SITM.document.write("width: 100%;'>");
			
			
			
			
			
			WorkingPopup_SITM.document.write("<img src='client_docs/loading11.gif' border='0'>");
			WorkingPopup_SITM.document.write("</div>");
			WorkingPopup_SITM.document.write("<div id='loadText' style='");
			WorkingPopup_SITM.document.write("font-family: Verdana, Arial;");
			WorkingPopup_SITM.document.write("font-size: 17px;");
			
			
			WorkingPopup_SITM.document.write("color: #5D6064;	");
			WorkingPopup_SITM.document.write("text-align: center;  ");
			WorkingPopup_SITM.document.write("vertical-align: bottom;'>");
			WorkingPopup_SITM.document.write(sText);
			WorkingPopup_SITM.document.write("</div>");
			WorkingPopup_SITM.document.write("</div>"); 
	        
	        WorkingPopup_SITM.document.write('</body>');
	        WorkingPopup_SITM.document.write('</html>');
	        WorkingPopup_SITM.document.close();

			
			
	        self.name = 'main';

	        return WorkingPopup_SITM;
	    }
	}
	
function KillWorkingMessagePopup() {

	    var height = 5; // Height of popup
	    var width = 5; // Width of popup
	    var attributes = 'status=0,titlebar=0,left=9999,top=9999,toolbar=0,width=' + width + ',height=' + height+'';

	    var openWin = window.open('', 'workingPopUp', attributes);
	    
	    if (openWin)
	        openWin.close();
		
 	
	
	
}
function copyToList(from,to)
{


	//fromList = eval(form1 + 'category_1');

	//toList = eval(form1 + to);

	fromList=from;
	toList=to;
	if (toList.options.length > 0 && toList.options[0].value == 'temp')
	{
		toList.options.length = 0;
	}
	var sel = false;
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		if (current.selected)
		{
			sel = true;
			if (current.value == 'temp')
			{
				alert ('You cannot move this text!');
				return;
			}
			txt = current.text;
			val = current.value;
			toList.options[toList.length] = new Option(txt,val);
			fromList.options[i] = null;
			i--;
		}
	}
	if (!sel) alert ('You haven\'t selected any options!');

}

function limited_select(elem,sel_limit)
{
	var no_selected=0;

	for (i=0;i<elem.options.length;i++)
	{
		if(elem.options[i].selected)
		{
			no_selected++;

		}
	}

	if(sel_limit>0 && no_selected>sel_limit)
	{
		alert ('You can select only '+sel_limit+' options!');
		for (i=0;i<elem.options.length;i++)
		{
			elem.options[i].selected=false;
		}
	}

}

function copyToList2(from,to,sel_limit)
{
	//copy to list with limit
	//sel_limit=0 no limit
	//sel_limit=i then i is limit

	//fromList = eval(form1 + 'category_1');

	//toList = eval(form1 + to);


	fromList=from;
	toList=to;
	var no_selected=0;

	for (i=0;i<fromList.options.length;i++)
	{
		if(fromList.options[i].selected)
		{
			no_selected++;
		}
	}

	if(sel_limit>0 && no_selected+toList.options.length>sel_limit)
	{
		alert ('You can select only '+sel_limit+' options!');
	}
else
	{
		if (toList.options.length > 0 && toList.options[0].value == 'temp')
		{
			toList.options.length = 0;
		}
		var sel = false;
		for (i=0;i<fromList.options.length;i++)
		{
			var current = fromList.options[i];
			if (current.selected)
			{
				sel = true;
				if (current.value == 'temp')
				{
					alert ('You cannot move this text!');
					return;
				}
				txt = current.text;
				val = current.value;
				toList.options[toList.length] = new Option(txt,val);
				fromList.options[i] = null;
				i--;
			}
		}
		if (!sel) alert ('You haven\'t selected any options!');
	}
}

function phpPrepareForm(form1)
{
	
	for ( i=0; i < form1.length; i++ )
	{
		if (form1.elements[i].type=="select-multiple")
		{
			//if(form1.elements[i].name.indexOf("[]",0) != -1)
			//{
				namebrackets=form1.elements[i].name + "[]";
				form1.elements[i].name=namebrackets;
			//}
		}
	}
}


function allSelect(select1)
{
	List = select1;

	for (i=0;i<List.length;i++)
	{
		List.options[i].selected = true;
	}

}




function resize_img(img ,width,height)
{
	if(img.width > width) img.width =width;
	/*if(img.height > height) img.height=height; */
}
function goprop()
{
	document.forms[0].Prop_Amenities.options[document.forms[0].Prop_Amenities.length++]=new Option(document.forms[0].Add_prop.value,document.forms[0].Add_prop.value);
}

function addoption(selname,iname)
{
	var sel=document.getElementById(selname);
	var inp=document.getElementById(iname);

	sel.options[sel.length++]=new Option(inp.value,inp.value);
	inp.value='';
}

function deloption(selname)
{
	var sel=document.getElementById(selname);

	for (i=0;i<sel.options.length;i++)
	{
		if(sel.options[i].selected)
		{
			sel.options[i] = null;
		}
	}
}
function goroom()
{
	document.forms[0].Room_Amenities.options[document.forms[0].Room_Amenities.length++]=new Option(document.forms[0].Add_room.value,document.forms[0].Add_room.value);
}

function check_form(form)
{
	var ok=true;
	var message='Please fill in the following field(s) ' ;
	go_clicked(form);
	if(form.Name.value=='')
	{
		message+=' Company Name ';
		ok=false;
	}
	if(form.Location.value=='')
	{
		message+=' Location ';
		ok=false;
	}
	if(form.Franchise.value=='')
	{
		message+=' Franchise ';
		ok=false;
	}
	if(form.Email.value=='')
	{
		message+=' Email ';
		ok=false;
	}
	if(form.Login.value=='')
	{
		message+=' Username ';
		ok=false;
	}
	if(form.password.value=='')
	{
		message+=' Password ';
		ok=false;
	}


	if(!ok)
	{
		alert(message);
	}
	return ok;
}

function bpressed(el,btn)
{
	el.form.submitted.value=btn;
}

function setBookmark(id_number, urlAddress, sponsorCategory, pageName)
{
	//alert("Bookmark to: " + urlAddress);
	if(document.all)
	{			
		window.external.AddFavorite(urlAddress,pageName);
	}
	else
	{
		alert("Your Browser Does Not Support Bookmarks From Links. Press CTRL+D To Set Bookmark!");
	}	
	
	//record stat
	http_request = createReq();
	http_request.open('POST', 'bookmark_process.php', true); //process data on the backend
	http_request.onreadystatechange = handleResp;
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send('id_number=' + id_number + '&sponsorCategory=' + sponsorCategory);//'arg1=val1&arg2=val2&arg3=val3'	
}

function handleResp()
{
  //if(http_request.readyState == 4)
  //{
   // var response = http_request.responseText;
   // alert(response);	
  //}
}

function createReq()
{ //creates the object for mozilla/ie respectively
	var requester;
	try{
	 var requester = new XMLHttpRequest();
	}
	catch (error){
	 try{
	   var requester = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 catch (error){
	   return false;
	 }
	}
	return requester;
}

