function change2(rub, usd, id) 

{

	if(document.getElementById('usedprice'+id).value == 'usd') 

	{

		document.getElementById('divusedprice'+id).innerHTML = usd; 

		setCookie('currency','USD');

	}

	else

	{

		document.getElementById('divusedprice'+id).innerHTML = rub;

		setCookie('currency','RUB');

	}

}





function change() 

	{

	var stFlag = document.getElementById('usedprice').value;

	

	var span = document.getElementsByTagName('span');

		for (i = 0; i < span.length; i ++)

		if(span[i].className == 'RUB' || span[i].className== 'USD') 

			span[i].style.display = 'none';

			

		for (i = 0; i < span.length; i ++) {

		if(span[i].className == stFlag) 

			{

				

				//USD показать

				//RUB скрыть

				

				span[i].style.display = 'block';

			}		

		}

		setCookie('currency',stFlag)

	}

	

function setCookie (name, value){

      document.cookie = name + '=' + escape(value) + '; path=/; expires=Fri, 01-Jan-2025 00:00:01 GMT;';

}



function addToCompare() {



    if (!document.getElementById) {

        window.open("/cars/compareCars.screen", "win", "");

    } else {



        boxes = document.getElementById("sForm").elements;



        var str = '';



        for (var i = 0; i < boxes.length; i++) {



            if (boxes[i].type == 'checkbox' && boxes[i].name == 'chk_compare' && boxes[i].checked) {



                str += "add=" + boxes[i].value;



                if (i != boxes.length - 1)

                    str += "&";



            }



        }

        window.open("/cars/compareCars.screen?" + str, "win", "");

    }



}



function vprint (obj){

	var f = document.getElementById(obj);

    f.submit ();

}



function setSort(str) {

    document.searchform.sort.value = str;

//    document.getElementById ('page_sort').value = '1';

    document.searchform.submit();

}



function setPage(page) {

    document.searchform.page.value = page;

    document.searchform.submit();

}



//function setFormParam(sort, page) {

//    document.searchform.sort.value = sort;

//    document.searchform.page.value = page;

//    document.searchform.submit();

//}





/*function refreshDynamicSelectOptions() {



    if (document.getElementById && document.getElementsByTagName) {

        var brand_id = document.getElementById("brand").options[document.getElementById("brand").selectedIndex].value;

        var model = document.getElementById("model");

        var options = document.getElementById("hmodel").getElementsByTagName("option");

        var options_count = 0;

        var selected_option_index =0;



        //удаляем из списка все элементы

        while (model.options.length) {

            model.remove(0);

        }



        for (var i = 0; i < options.length; i++) {

        // Если название класса option эквивалентно "0" (первое, пустое значение)

        // либо эквивалентно brand_id

            if (options[i].className == "0" || options[i].className == brand_id ) {

                // его нужно добавить в динамически создаваемый список

                //cloneNode(true) clones the whole subtree rooted at the node.

                //cloneNode(false) just duplicates the node itself, without its children or its father.

                model.appendChild(options[i].cloneNode(true));



                if (options[i].value == $filter.model_id)

                    selected_option_index = options_count;



                options_count +=1;

            }

        }



        model.options[selected_option_index].selected = true;

    }

} */



  function onLoad() {

            if("$cmpCarsList.size()" == "0")

                window.close();

        }

		

			

startList = function() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById("nav");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="TH") {

				node.onmouseover=function() {this.className+=" over";}

				node.onmouseout=function() {this.className=this.className.replace(" over", "");}

			}

		}

	}

}







function checkSelect (id)

{

	var str1 = 		'ch_' + id;

	var str2 = 		'tr_' + id

	

	var ch =		document.getElementById (str1);

	var tr =		document.getElementById (str2);

	if (ch.checked)

	{

		tr.className = 'selected';

	}

	else

	{

		tr.className = '';	

	}

}





function ChangeFoto(oID, nImg)

{

	var img = document.getElementById(oID);

	img.src = nImg;

}







function changeState(layerRef, state)

{ 

	var blockElement = document.getElementById(layerRef).style;

	blockElement.display = state;

}







function flyout(url,obj) {

	var img = new Image;

	img.src = url;

	img.className="flyout";

	obj.appendChild(img);

}

function flyclear(obj) {

	for (var i=0; i<obj.childNodes.length; i++) {

		if (obj.childNodes[i].className == "flyout") {

			obj.childNodes[i].className = "hide";

		}

	}

}



function wopen3 (obj){

 var wo = window.open("", "abc", "width=10, height=10, scrollbars=0, status=0");

 wo.document.open();

 var win = "";

 win = "<html><head>";

 win += "<title>Image</title>";

 win += "<script>function resizes (obj){";

 win += "var w=obj.width, h=obj.height;";

 win += "window.resizeTo (w+100, h+100);";

 win += "}</"+"script"+">";

 win += "<style type='text/css'> * {margin:0; padding:0; border:0; } </style> </head>"

 win += "<body>";

 win += "<table cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td align='center'>";

 win += "<img src='" + obj + "' alt='' onload='resizes(this)' />";

 win += "</td></tr></table>";

 win += "</body></html>";

 wo.document.write(win);

 wo.window.focus();

 wo.document.close();

}

function wopen4 (obj)

{

 var wo = window.open("", "abc", "width=10, height=10, scrollbars=0, status=0");
 wo.document.open();
 var win = "";
 win = "<html><head>";
 win += "<title>Image</title>";
 win += "<script>function resizes (obj){";
 win += "var w=obj.width, h=obj.height;";
 win += "window.resizeTo (w+8, h+150);";
 win += "}</"+"script"+">";
 win += "<style type='text/css'> * {margin:0; padding:0;} input {margin:10px;} a {font-weight: bold;}</style>";
 win += "<link rel='stylesheet' href='/css/index.css' type='text/css'/> </head>";
 win += "<body>";
 win += "<table cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td align='center'>";
 win += "<img src='" + obj + "' alt='' onload='resizes(this)' />";
 win += "<input type='button' value='Печать' onclick='javascript:window.print();' />";
 win += "</td></tr></table>";
 win += "</body></html>";
 wo.document.write(win);
 wo.window.focus();
 wo.document.close();

}

function showOther (obj){
	var txt = document.getElementById ("other");
	if (obj.checked){
		txt.disabled = false;
	}
	else {
		txt.disabled = true;
		txt.value = "";
	}
}

function openWindow(theURL,winName,features) 
	{ 
		window.open(theURL,winName,features);
	}





