 function OpenWindow(page,name,w,h,scroll)
 {
  setari = 'height='+h+',width='+w+',scrollbars='+scroll+',resizable';
  win = window.open(page,name,setari);
 }
function changemodel(selected_model_id) {

myArray=modelsArray;
myForm=document.formarticle;
var arrayLength = modelsID.length;
var selMakeIndex = document.formarticle.category.selectedIndex;
var selMake = document.formarticle.category.options[selMakeIndex].value;
var modelIndex=0;
document.formarticle.subcategory.options.length = 0;
for (var i=0;i<arrayLength;i++)  //For all makes
{
  var mkSplitArray =  modelsID[i];
  if (selMake == mkSplitArray)  // For the choosen make
  {
    myForm.subcategory.options[modelIndex] =   new Option ('...', 0);
    modelIndex++;
    for (var j=0;j<myArray[mkSplitArray].length;j++) //For all the models within
    {
      var splitArray = myArray[mkSplitArray][j].split("|");
      var modelName = splitArray[1];
      var modelId = splitArray[0];

        myForm.subcategory.options[modelIndex] =   new Option (modelName, modelId);
        if (selected_model_id == modelId)
        {
          myForm.subcategory.selectedIndex = modelIndex;
        }
        modelIndex++;
    } // for j
    break;
  }
} // for i
}

function changecounty() {

          obj = document.formarticle;
        var country_selected  = obj.country.options[obj.country.selectedIndex].value;
        if ( (country_selected != '...') && (country_selected != '0') && (country_selected != '')) {

                var county_array = countyarray[country_selected].split(',');

                obj.county.length=0;
                obj.province.length=0;
                obj.city.length=0;

                for (var i=0; i < county_array.length; i++) {
                        obj.county.options[i] = new Option(county_array[i], county_array[i], 0, 0);
                        obj.county.options[0].selected =  true;
                }
        }else{
                obj.county.length=0;
                obj.province.length=0;
                obj.city.length=0;
        }
}
function changeprovince() {

          obj = document.formarticle;
          var country_selected  = obj.country.options[obj.country.selectedIndex].value;
        var county_selected  = obj.county.options[obj.county.selectedIndex].value;

        if ( (county_selected != '...') && (county_selected != '0') && (county_selected != '')) {

                var province_array = provincearray[country_selected][county_selected].split(',');

                obj.province.length=0;
                obj.city.length=0;

                for (var i=0; i < province_array.length; i++) {
                        obj.province.options[i] = new Option(province_array[i], province_array[i], 0, 0);
                        obj.province.options[0].selected =  true;
                }
        }else{
                obj.province.length=0;
                obj.city.length=0;
        }
}
function changecity() {

          obj = document.formarticle;
          var country_selected  = obj.country.options[obj.country.selectedIndex].value;
        var county_selected  = obj.county.options[obj.county.selectedIndex].value;
        var province_selected  = obj.province.options[obj.province.selectedIndex].value;

        if ( (province_selected != '...') && (province_selected != '0') && (province_selected != '')) {

                var city_array = cityarray[country_selected][county_selected][province_selected].split(',');

                obj.city.length=0;

                for (var i=0; i < city_array.length; i++) {
                        obj.city.options[i] = new Option(city_array[i], city_array[i], 0, 0);
                        obj.city.options[0].selected =  true;
                }
        }else{
                obj.city.length=0;
        }
}





var browserinfos=navigator.userAgent
var ns4=document.layers
var ns6=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var ie=document.all&&!browserinfos.match(/Opera/)
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var opera=browserinfos.match(/Opera/)

function RunSlideShow( imageFiles, imageUrl, imageTitle, imageText, displaySecs)
{
  var imageSeparatorFiles = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparatorFiles);

  var imageSeparatorUrl = imageUrl.indexOf(";");
  var nextUrl = imageUrl.substring(0,imageSeparatorUrl);

  var imageSeparatorTitle = imageTitle.indexOf(";");
  var nextTitle = imageTitle.substring(0,imageSeparatorTitle);

  var imageSeparatorText = imageText.indexOf(";");
  var nextText = imageText.substring(0,imageSeparatorText);

  if (ie || ie5)
  {
    document.getElementById('pictureName').style.filter="blendTrans(duration=2)";
    document.getElementById('pictureName').filters.blendTrans.Apply();

  }

  document.getElementById('pictureName').src = nextImage;
  document.getElementById('pictureUrl').href = nextUrl;
  document.getElementById('pictureUrl1').href = nextUrl;
  document.getElementById('pictureText').innerHTML = nextText;
  //document.getElementById('Title').innerHTML = nextTitle;
  document.getElementById('pictureUrl1').innerHTML = nextTitle;

  if (ie || ie5)
  {
    document.getElementById('pictureName').filters.blendTrans.Play();
  }

  var futureImages= imageFiles.substring(imageSeparatorFiles+1,imageFiles.length)
    + ';' + nextImage;
  var futureUrl= imageUrl.substring(imageSeparatorUrl+1,imageUrl.length)
    + ';' + nextUrl;
  var futureTitle= imageTitle.substring(imageSeparatorTitle+1,imageTitle.length)
    + ';' + nextTitle;
  var futureText= imageText.substring(imageSeparatorText+1,imageText.length)
    + ';' + nextText;
  futureText = futureText.replace("'","`");
  futureText = futureText.replace('"',"`");    
  setTimeout("RunSlideShow('"+futureImages+"','"+futureUrl+"','"+futureTitle+"','"+futureText+"',"+displaySecs+")",
    displaySecs*1000);
}


var xmlHttp
var innerstr;

function funcget1(str,make1,cat1,str1,obj,val1,id1)
{

if (val1!=''){
obj.innerHTML='<font style="font-size:16px;">'+val1+'</font>';
}


xmlHttp=GetXmlHttpObject()
innerstr=str1;
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="index.php"
url=url+"?pp="+str
url=url+"&type="+cat1
url=url+"&category="+make1
url=url+"&id="+id1
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged ;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 



function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(innerstr).innerHTML=xmlHttp.responseText ;

if (innerstr=='category'){
	funcget1('subcategory',document.formarticle.category.value,document.formarticle.type.value,'subcategory',document.getElementById('subcategory'),'Loading...');
}
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}


function goodchars(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
   return true;

// else return false
return false;
}