function change_imgcaptbtn(dvid){
        fid = "captimgbtn_"; 
        ID1 = document.getElementById(fid + dvid);
        cid = "captimgfrmdv_"; 
        ID2 = document.getElementById(cid  + dvid);
	
	ID1.style.display = "none";
	ID2.style.display = ""; 
                                                 
}
                            
function change_imgctn(dvid){
        fid = "captimgbtn_"; 
        ID = document.getElementById(fid + dvid);
	
        if(ID.style.display == "") 
                ID.style.display = "none";
        else
		ID.style.display = "";                  
}                     
                         


function includeJS(filename)
{
	var head = document.getElementsByTagName('head')[0];
	
	script = document.createElement('script');
	script.src = domain + 'js/' + filename;
	script.type = 'text/javascript';
	
	head.appendChild(script)
}
 

function clear_input(type){ 
     if (type == 'search') {
         lid = "hsb";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            return;
          }
          else if (input.value == 'Search'){
            input.value = '';
            return
          }
          else {
            return;
          }
    }     
     if (type == 'user') {
         lid = "usr";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            return;
          }
          else if (input.value == 'Username'){
            input.value = '';
            return
          }
          else {
            return;
          }
    }   
     if (type == 'pass') {
         lid = "psw";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            return;
          }
          else if (input.value == 'Password'){
            input.value = '';
            return
          }
          else {
            return;
          }
    }   
}
                            
function unclear_input(type){ 
     if (type == 'pass') {
         lid = "psw";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            input.value = 'Password';
            return;
          }
          else if (input.value == 'Password'){
            input.value = 'Password';
            return
          }
          else {
            return;
          }
     }  
     if (type == 'user') {
         lid = "usr";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            input.value = 'Username';
            return;
          }
          else if (input.value == 'Username'){
            input.value = 'Username';
            return
          }
          else {
            return;
          }
     }  
     if (type == 'search') {
         lid = "hsb";
         LID = document.getElementById(lid);
          var input = eval(LID);
          if (!input.value) {
            input.value = 'Search';
            return;
          }
          else if (input.value == 'Search'){
            input.value = 'Search';
            return
          }
          else {
            return;
          }
     } 
}

function submitLogin() {
     //pid = "side_loginform";
     //PID = document.getElementById(pid);
     document.side_loginform.submit(); 
     return true;
}

function confirm_delete(id) {
	var answer = confirm("Are you sure you wish to DELETE listing ID #" + id + "?")
	if (answer){
		alert("Ok your listing will be deleted. If you change your mind, please contact customer service.")
		window.location = "http://www.dallasguns.com/my_listings/?removeid=" + id;
                return false;
	}
	else{
                return false;
	}
}

function submitSearch() {
     pid = "hsb";
     PID = document.getElementById(pid);
     var surl = 'http://www.dallasguns.com/guns_online/?other=' + PID.value;
     window.location = surl
     return true;
}


function searchEnter(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    var charString = String.fromCharCode(charCode);
         
    if (charCode == 13){
        submitSearch();
        return true;
    }
    return true;
}
 
 
function numbersonly(myfield, e, dec){
        var key;
        var keychar;
        
        if (window.event)
           key = window.event.keyCode;
        else if (e)
           key = e.which;
        else
           return true;
        keychar = String.fromCharCode(key);
        
        // control keys
        if ((key==null) || (key==0) || (key==8) || 
            (key==9) || (key==13) || (key==27) )
           return true;
        
        // numbers
        else if ((("0123456789").indexOf(keychar) > -1))
           return true;
        
        // decimal point jump
        else if (dec && (keychar == "."))
           {
           myfield.form.elements[dec].focus();
           return false;
           }
        else
           return false;
}
 
