//Opens Custom Windows
//States List Window
var stateswindow;
//Regions List Window
var regionswindow;
//Signup Now Window
var signupnowwindow;
//Terms and Conditions Window
var termswindow;
//Generic Blank Window
var blankwindow;

function popHelp(url) { //Help Window
	helpwindow=window.open(url,'Help','left=40, top=100, width=640, height=480, toolbar=yes, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes');
	if (window.focus) {helpwindow.focus()}
}

function popStates(url) { //State List Window
	stateswindow=window.open(url,'States','left=20, top=80, width=434, height=588, toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no');
	if (window.focus) {stateswindow.focus()}
}

function popRegions(url) { //Regions List Window
	regionswindow=window.open(url,'Regions','left=20, top=80, width=434, height=280, toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no');
	if (window.focus) {regionswindow.focus()}
}

function popSignUp(url) { //Signup Now Window
	signupnowwindow=window.open(url,'Signup','left=140, top=300, width=440, height=145, toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=no');
	if (window.focus) {signupnowwindow.focus()}
}

function popTerms(url) { //Terms Window
	termswindow=window.open(url,'Terms','left=20, top=80, width=640, height=380, toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
	if (window.focus) {termswindow.focus()}
}

function popBlank(url) { //Generic Blank Window
	blankwindow=window.open(url,'Blank','left=0, top=0, width=800, height=600, toolbar=yes, directories=yes, location=yes, status=yes, menubar=yes, resizable=yes, scrollbars=yes');
	if (window.focus) {blankwindow.focus()}
}

// Window Closer
function closeIt() {
  close();
}

// Style Swapper
function swapStyle(id, newClass) {
    ss = document.getElementById(id);
    ss.className = newClass;
}

// On Off Swapper
function onOff(id) {
    oo = document.getElementById(id);
        if (oo.className == 'off') {
        oo.className = 'on';
        }
        else {
        oo.className = 'off';
        }
}

//Confirmation Alert Box
function confirmation() {
    var answer = confirm("Are you sure you want to DELETE ALL?")
     if (answer){
        document.forms.myLoadList.deleteAll.value = 1;
        document.forms.myLoadList.submit();
        return true;
     }
    else
        return false;
}

function confirmationT() {
    var answer = confirm("Are you sure you want to DELETE ALL?")
     if (answer){
        document.forms.myTruckList.deleteAll.value = 1;
        document.forms.myTruckList.submit();
        return true;
     }
    else
        return false;
}

var checkflag = "false";
function check(field) {
  if (checkflag == "false") {
    if (!field.length) {
      field.checked = true;
    }
    for (i = 0; i < field.length; i++) {
      field[i].checked = true;
    }
    checkflag = "true";
    return false;
  }
  else {
    if (!field.length) {
      field.checked = false;
    }
    for (i = 0; i < field.length; i++) {
      field[i].checked = false;
    }
    checkflag = "false";
    return false;
  }
}

// Toggle Select Box
function toggleSubCat() {
        var box = document.forms['postAd'].category;
	var value = box.options[box.selectedIndex].value;

	for (i=0; i < mysub.length; ++i) {
		document.getElementById(mysub[i]).style.visibility = 'hidden';
		document.getElementById(mysub[i]).style.display = 'none';
	}

	if (document.getElementById("subcat_" + value)) {
		document.getElementById("subcat_" + value).style.visibility = 'visible';
		document.getElementById("subcat_" + value).style.display = 'inline';
	}
	
	return
}
