$(document).ready(function() {
$('#nav-ul li.hasSubmenu > a').click(function(){
$(this).parents("li.hasSubmenu").toggleClass('expandedSubmenu');
return false;
}); 
$('#top-tabs li').live('mouseover', function() { $(this).addClass('statusHover'); }); 
$('#top-tabs li').live('mouseout', function() { $(this).removeClass('statusHover'); }); 
});
function myCheck(myField, myOption) {
var myOptionsArray = myOption.split('||');
for(i=0;i<myField.form.elements.length;i++) {
if(myField.form.elements[i].name==myField.name && myField.form.elements[i].value==myOption) {
myField.form.elements[i].checked=true;
break; 
} else if(myField.form.elements[i].name==myField.name && myOptionsArray.length>1) {
for(j=0;j<myOptionsArray.length;j++) {
if(myField.form.elements[i].value==myOptionsArray[j]) {
myField.form.elements[i].checked=true;
break; 
}
}
}
}
}
function newMail(mailgif) {
bookWindow = window.open(mailgif, 'mailWin', 'width=301, height=450, left=0, top=0, scrollbars=no, resizable=yes')
bookWindow.focus()
}
function PopupPic(sPicURL) { 
window.open("popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}
function confirmDelete()
{
var agree=confirm("Are you sure?");
if (agree)
return true ;
else
return false ;
}
function formHandler(form){
var URL = document.form.links.options[document.form.links.selectedIndex].value;
window.location.href = URL;
}
function validate(field) {
return true;
var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZ _-[]()abcdefghijklmnopqrstuvwxyz0123456789:.\\/"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";bad=temp;
}
if (ok == "no") {
alert("Invalid entry! You cannot have certain punctuation or symbols in your photos filename. Please rename the photo and try uploading the photo again.");
field.focus();
field.select();
}
}
function openpopup(listingID){
var popurl="/virtualtour2.php?listingID="+listingID
winpops=window.open(popurl,"","width=770,height=495,")
}
function getCookie(Name) {
var search = Name + '='
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
end = document.cookie.indexOf(';', offset)
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
return '';
}
function setCookie(name, value, expire, path) {
var cookieLine = name + "=" + escape(value) ;
if(expire != null) {
cookieLine = cookieLine + "; expires=" + expire.toGMTString();
}
if(path!=null) {
cookieLine = cookieLine + "; path=" + escape(path);
}
document.cookie = cookieLine;
}
function nextCardField(myField, nextField) {
if (myField.value.length == 4) {
nextField.focus();
}
}
function fixCardField(myField) {
myField.value = myField.value.replace(/[^\d]+/,''); 
}
function uncheckAll(myForm) {
for(i=0;i<myForm.elements.length;i++)
{
myElement = myForm.elements[i];
if(myElement.type=="checkbox") {
myElement.checked = false;
} else if(myElement.type=="select-one") {
elementNameFx = myElement.name.replace('[','_');
elementNameFx = elementNameFx.replace(']','_');
if(myForm[elementNameFx+'_default'] && myForm[elementNameFx+'_default'].value)
{
myElement[myForm[elementNameFx+'_default'].value].selected = true;
}
else
{
myElement[0].selected = true;
}
} else if(myElement.type=="select-multiple") {
for(j=0;j<myElement.options.length;j++)
{
myElement.options[j].selected = false;
myElement.options[j].checked = false;
}
} else {
}
}
return false;
}
function newCookie(name,value,days) {
var days = 365;
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 nameSG = name + "=";
var nuller = '';
if (document.cookie.indexOf(nameSG) == -1)
return nuller;
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(nameSG) == 0) return c.substring(nameSG.length,c.length); }
return null; }
function eraseCookie(name) {
newCookie(name,"",1); }
function toMem(a) {
newCookie('user_name', document.login_form.user_name.value);
newCookie('user_pass', document.login_form.user_pass.value);
}
function delMem(a) {
eraseCookie('user_name');
eraseCookie('user_pass');
document.login_form.user_name.value = '';
document.login_form.user_pass.value = ''; }
function toggleDivDisplay() {
var what_chosen = document.myform.photos;
for (i = 0; i < what_chosen.length; i++) {
if (what_chosen[i].checked) {
user_input = what_chosen[i].value;
}
}
if (user_input == 'I_Have_Photos') {
var companyDivToggle = document.getElementById('havePhotos');
companyDivToggle.style.display = 'block';
var personnelDivToggle = document.getElementById('needPhotos');
personnelDivToggle.style.display = 'none';
} else if (user_input == 'Need_Photos') {
var companyDivToggle = document.getElementById('havePhotos');
companyDivToggle.style.display = 'none';
var personnelDivToggle = document.getElementById('needPhotos');
personnelDivToggle.style.display = 'block';
} else {
var companyDivToggle = document.getElementById('havePhotos');
companyDivToggle.style.display = 'block';
var personnelDivToggle = document.getElementById('needPhotos');
personnelDivToggle.style.display = 'block';
}
} // Closes the toggleDivDisplay function
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue)
{
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
}
function deleteOption(theSel, theIndex)
{ 
var selLength = theSel.length;
if(selLength>0)
{
theSel.options[theIndex] = null;
}
}
function moveOptions(theSelFrom, theSelTo)
{
var selLength = theSelFrom.length;
var selectedText = new Array();
var selectedValues = new Array();
var selectedCount = 0;
var i;
for(i=selLength-1; i>=0; i--)
{
if(theSelFrom.options[i].selected)
{
selectedText[selectedCount] = theSelFrom.options[i].text;
selectedValues[selectedCount] = theSelFrom.options[i].value;
deleteOption(theSelFrom, i);
selectedCount++;
}
}
for(i=selectedCount-1; i>=0; i--)
{
addOption(theSelTo, selectedText[i], selectedValues[i]);
}
if(NS4) history.go(0);
}
