var imgOn = new Image();
	imgOn.src="images/minus.png"
var imgOff = new Image();
	imgOff.src="images/plus-2.png"

function showHide(arg,imgId) {
// alert("welcome");
  var myObj = returnObject(arg);
  var myImg = document.getElementById(imgId);
  var ID = arg +'style';
  var jId = "#" + arg;

  var myStyle = document.getElementById(ID);

  if (myObj != null) {
	  if(myObj.style.display == "" && myObj.style.display != "none") {
		  //myObj.style.display="none";
		  $(jId).slideUp("slow");
		  if(myImg != null){
			myImg.src = imgOff.src;
		  }
	  } else if(myObj.style.display && myObj.style.display != "none") {
		  //myObj.style.display="none";
		  $(jId).slideUp("slow");
		  if(myImg != null){
			myImg.src = imgOff.src;
		  }
	  } else {
		  $(jId).slideDown("slow");
		  //myObj.style.display="block";
		//   myStyle.className = "dir-here";
		//   alert(myStyle.className);
		  if(myImg != null){
			myImg.src = imgOn.src;
		  }
	  }
   }
}

function toggleButton() {
	$('#login').toggle(function() {
	  this.slideDown('slow');
	}, function() {
  	 this.slideUp('slow');
	});
}

function returnObject(arg, formObj) {
	var myObj = null;
	if (formObj != null) {
		myObj = formObj.elements[arg];
	} else if (typeof arg == 'string') {
		myObj = document.getElementById(arg);
	} else if (typeof arg == 'object') {
		myObj = arg;
	}

	return myObj;
}

// simple function to show a container
function show(arg) {
	var myObj = returnObject(arg);
	if (myObj != null) {
		myObj.style.display = "block";
	}
}

// simple function to hide a container
function hide(arg) {
	var myObj = returnObject(arg);
	if (myObj != null) {
		myObj.style.display = "none";
	}
}

//hide Multiple hideM(field1,field2,...)
function hideM() {
	for (var i = 0; i < arguments.length; i++) {
		hide(arguments[i]);
	}
}
//show Multiple showM(field1,field2,...)
function showM() {
	for (var i = 0; i < arguments.length; i++) {
		show(arguments[i]);
	}
}

function clearInputsWithValue(form, myValue, inputType) {
	// if inputType is not specified, then use 'input' as default
	var type = (inputType == null) ? 'input' : inputType;

	var formObj = returnObject(form);

	var inputs = formObj.getElementsByTagName(type);

	// lets remove the specified value from our input values
	for ( i = 0; i < inputs.length; i++ ) {
		if(inputs[i].value.toLowerCase() == myValue) {
			inputs[i].value = '';
		}
	}
}

function scrollToTop() {
	if (document.body.scrollTop) {
		document.body.scrollTop = 0;
	} else if(document.body.scrollTo) {
		document.body.scrollTo(0,0);
	} else {
		location.href = "#top";
	}
}

//Delay function after a few seconds delay("alert('sample!')",1000);
function delay(functionToCall,delayMill){
	if(functionToCall && delayMill != null){
		window.setTimeout(functionToCall,delayMill);
	}
}

$().ready(function() {
	
	//This line is for getting & displaying the copyright year in the footer
	$("#year").text((new Date).getFullYear());
	
	//method to check if the fields are using default values
	jQuery.validator.addMethod("defaultInvalid", function(value, element){
		if (element.value == element.defaultValue){
			return false;
		}
		return true;
	});

	// validate signup form on keyup and submit
	$("#startForm").validate({
		errorContainer: $("#msgs-error"),

		rules: {
			name: "defaultInvalid",
			city: "defaultInvalid",
			state: "required",
			//years: "required",
			//processor: "required",
			//agents: "required",
			phone: {
				required: "defaultInvalid",
				minlength: 13
			},
			email: {
				required: "defaultInvalid",
				email: true
			}
		}
	});

	$('#currentPartners').toggle(
		function() {
		  $(this).removeClass('plus');
		  $(this).addClass('arrow');
		  $('#login').slideDown('slow');
		},
		function() {
		  $(this).removeClass('arrow');
		  $(this).addClass('plus');
		  $('#login').slideUp('slow');
		}
	);

});


