<!--
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Updated by: Mike Weiner :: http://www.wearebent.com 
Original author: Eric King (eric_andrew_king@hotmail.com)
Last Updated: May 2006

Usage: The link is written as follows: 
onclick="newWindow(this.href, 'popup', 600, 500, 1, 1, 0, 0, 0, 1, 0);

Usage Description:
"this.href" refers to the URL given in the "a" tag; "'popup'" is the name of the popup window;
600 is the width of the popup window; 500 is the height of the popup window; the numbers that
follow designate whether a property is turned on ("1") or off ("0"), in this order:
scrollbars, resizable, menubar, toolbar, addressbar, statusbar, fullscreen
newWindow(this.href, 'popup', 600, 500, scrollbars, resizable, menubar, toolbar, addressbar, statusbar, fullscreen);
*/

function dod_newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}


function checkText(form_name,field_name,message,min,max){
	var l = eval('document.'+form_name+'.'+field_name+'.value.length');
	if( l > max ){
		alert('"'+message+'" must be up to '+max+' characters long!');
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
	if( l < min ){
		alert('"'+message+'" is invalid or empty!');
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
}

function checkCombo(form_name,field_name,message,error_field_value){
	var l = eval('document.'+form_name+'.'+field_name+'.options[document.'+form_name+'.'+field_name+'.selectedIndex].value');
	if(l == error_field_value){
		alert('Please select "'+message+'" !');
		return false;
	}
}

function comboSelected(form_name,field_name){
	return eval('document.'+form_name+'.'+field_name+'.options[document.'+form_name+'.'+field_name+'.selectedIndex].value');
}

function checkInteger(form_name,field_name,message,min,max){
	var l = eval('document.'+form_name+'.'+field_name+'.value');
	if( l > max ){
		alert('"'+message+'" must be up to '+max+'!');
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
	if( l < min ){
		alert('"'+message+'" is invalid!');
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
}

function checkEmail(form_name,field_name,message){
	var f = eval('document.'+form_name+'.'+field_name+'.value');
	var l = eval('document.'+form_name+'.'+field_name+'.value.length');
	var reg = new RegExp("^[a-z0-9_.-]+@+[a-z0-9_.-]+(.[a-z]{2,4})$","gi");
	if(l < 1){
		alert("'"+message+"' field is empty!");
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
	if (!reg.test(f)){
		alert("'"+message+"' should contain a proper e-mail address!");
		eval('document.'+form_name+'.'+field_name+'.focus();');
		return false;
	}
}

function compareFields(form_name,field_name1,field_name2,message){
	var f1  = eval('document.'+form_name+'.'+field_name1+'.value');
	var f2 = eval('document.'+form_name+'.'+field_name2+'.value');
	if( f1 != f2 ){
		alert('"'+message+'" don`t match!');
		eval('document.'+form_name+'.'+field_name1+'.focus();');
		return false;
	}
}

function isEmpty(form_name,field_name){
	return eval('document.'+form_name+'.'+field_name+'.value') == '' ? true : false;
}

function isNumeric(form_name,field_name){
	   var p = eval('document.'+form_name+'.'+field_name+'.value');
	   if ((isNaN(p)) || (p.length == 0))
	      return false;
	   return true;
}

function getValue(form_name,field_name){
	   return eval('document.'+form_name+'.'+field_name+'.value');
}
function setValue(form_name,field_name,val){
	   return eval('document.'+form_name+'.'+field_name+'.value = \''+val+'\';');
}

function dod_myTerms(){
	dod_newWindow('/terms/', 'terms', 400, 600, 1, 1, 0, 0, 0, 0, 0);
}

function dod_myDODTerms(){
	dod_newWindow('http://www.dodshops.com/privacy/?no_hf=1', 'terms', 400, 600, 1, 1, 0, 0, 0, 0, 0);
}

//div functions
function dod_error_message(){
	alert("Your browser isn't supported!");
}

function dod_getRefToDiv(divID) {
	if( document.layers ) { //Netscape layers
		return document.layers[divID]; }
	if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
		return document.getElementById(divID); }
	if( document.all ) { //Proprietary DOM; IE4
		return document.all[divID]; }
	if( document[divID] ) { //Netscape alternative
		return document[divID]; }
	return false;
}

//Shows the div
function dod_showDiv(divID_as_a_string) {
	//get a reference as above ...
	myReference = dod_getRefToDiv(divID_as_a_string);
	if( !myReference ) {
		dod_error_message();
		return false; //don't go any further
		//return anything would work,
		//but I am using false to show failure
	}
	//now we have a reference to it
	if( myReference.style ) { //DOM & proprietary DOM
		myReference.style.visibility = 'visible';
		myReference.style.display='block';
	} else {
		if( myReference.visibility ) { //Netscape
			myReference.visibility = 'show';
			myReference.style.display='block';
		} else {
			dod_error_message();
			return false; //don't go any further
		}
	}
	return true;
}
//Hides the div
function dod_hideDiv(divID_as_a_string) {
	//get a reference as above ...
	myReference = dod_getRefToDiv(divID_as_a_string);
	if( !myReference ) {
		//window.alert('Nothing works in this browser');
		return false; //don't go any further
		//return anything would work,
		//but I am using false to show failure
	}
	//now we have a reference to it
	if( myReference.style ) { //DOM & proprietary DOM
		myReference.style.visibility = 'hidden';
		myReference.style.display='none';
	} else {
		if( myReference.visibility ) { //Netscape
			myReference.visibility = 'hide';
			myReference.style.display='none';
		} else {
			//window.alert('Nothing works in this browser');
			return false; //don't go any further
		}
	}
	return true;
}

function dod_writeToDiv(div_name,t){
	var menuobj=document.getElementById? document.getElementById(div_name) : document.all? eval('document.all.'+div_name) : document.layers? eval('document.'+div_name+'.document.'+div_name) : "";
	if (document.getElementById||document.all)
		menuobj.innerHTML=t;
	else if (document.layers){
		menuobj.document.write(t);
		menuobj.document.close();
	}
}

function dod_getFromDiv(div_name){
	var menuobj=document.getElementById? document.getElementById(div_name) : document.all? eval('document.all.'+div_name) : document.layers? eval('document.'+div_name+'.document.'+div_name) : "";
	if (document.getElementById||document.all)
		return menuobj.innerHTML;
	//else if (document.layers){
	//	menuobj.document.write(t);
	//	menuobj.document.close();
	//}
}

function dod_appendToDiv(div_name,t){
	dod_writeToDiv(div_name,dod_getFromDiv(div_name)+t);
}
function dod_prependToDiv(div_name,t){
	dod_writeToDiv(div_name,t+dod_getFromDiv(div_name));
}

function shohideDiv(div_name){
	if(document.getElementById(div_name).style.display == 'none')
		dod_showDiv(div_name);
	else
		dod_hideDiv(div_name);
		
}

function dod_checkLogin(v){
	if(document.getElementById(v+'username').value == '' || document.getElementById(v+'password').value == ''){
		alert('Please enter your username and password to continue!');
		document.getElementById(v+'username').value == '' ? document.getElementById(v+'username').focus() : document.getElementById(v+'password').focus();
		return false;			
	}
	return true;
}

function dod_jShowHideDiv(name){
	myReference = dod_getRefToDiv(name);
	if(myReference.style.display == 'none'){
		dod_showDiv(name);
	}else{
		dod_hideDiv(name);
	}
}
//-->