function addBookmark(title,url) {

  var msg_netscape = "NetScape message";
  var msg_opera    = "This function does not work with this version of Opera.  Please bookmark us manually.";
  var msg_other    = "Your browser does not support automatic bookmarks.  Please bookmark us manually.";
  var agt          = navigator.userAgent.toLowerCase();


  if (agt.indexOf("opera") != -1) 
  {
    if (window.opera && window.print)
    {
      return true;
    } else 
    {
      alert(msg_other);
    }
  }    
  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
  else alert(msg_other);
  
}
/* 
-------------------------------
*/
function changemake(id) {
var ajax = new Ajax.Request('/auto/getmodel/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('modelselect').innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
}
//dlya dvuh poley
function changemakep(id,p) {
if(p=="1"){
var ajax = new Ajax.Request('/auto/getmodelp1/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('modelselect1').innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
		  if(id=='other1')
		  changemodel(1);
}
if(p=="2")
{
var ajax = new Ajax.Request('/auto/getmodelp2/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('modelselect2').innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
		  if(id=='other2')
	changemodel(2);	
}
}

function changep(id, a) {
if(a=="othermpp1" || a=="othermpp2")
var ajax = new Ajax.Request('/auto/getmodelp/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('modelselect'+id).innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
}

function changemodel(id) {
var ajax = new Ajax.Request('/auto/getmodelpp/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('tdsel'+id).innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
}

function changeloc(id) {
var ajax = new Ajax.Request('/getcity/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('cityspan').innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
}
function changelocat(id) {
var ajax = new Ajax.Request('/getcity/',
          {
               method: 'post', 
               parameters: 'id=' +id,
               onSuccess: function(transport) {
                   document.getElementById('cityspan').innerHTML = transport.responseText;
                        },
               onFailure: function() {
                    alert('Error');
               }
          });
}
/* 
-------------------------------
*/
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
/*
-------------------------------------
*/
function oneMoreFile() {
	var maxFiles = '30';
	var filesCount = Number(document.getElementById('filescount').value);
	if (filesCount < maxFiles) {
		filesCount++;
		document.getElementById('fileslist').insertAdjacentHTML('beforeEnd', '<input type="file" style="width:220px;" name="pic' + filesCount + '" id="uploadfile' + filesCount + '" /><br />');
		document.getElementById('filescount').value = filesCount;
		if (filesCount >= maxFiles) {
			document.getElementById('morefiles').style.display = 'none';
		}
	}
}
