﻿

function resize()
{
	var badycssh = document.getElementById("smformbody").clientHeight;
	document.getElementById("smformright").style.height = badycssh + "px";

}

function addCity(){

    var city = $('#partneranketa .city:last');

     city.clone(true).insertAfter(city);

    var num = $('#partneranketa .city');
    var inp = $('#partneranketa .city:last input');
    inp.val(' Город*');    //input_ptn_cityes_
    inp.attr('id','input_ptn_cityes_'+num.length);
	
	var inp2 = $('#partneranketa .city:last .country');
    inp2.val('');    //input_ptn_cityes_
    inp2.attr('id','hidden_ptn_cityes_'+num.length);	
	

    var cssh = $('#partneranketa .smformbody, #partneranketa .smformright');
    var h = cssh.height();
    //alert('H='+city.height()+' h='+cssh.height());
    cssh.css('height',(h+city.height())+'px');


    var fieldcity = $('#partneranketa .city:last .flist');
    fieldcity.attr('id','listop_'+num.length);

}

function selectFList(element, dropid){

     var drop = $(dropid);
     var retname = $(dropid+' #vreturn').text();

     $('#'+retname+' .flistname').text(element);
     var hidden = $('#'+retname+' .country');
	 hidden.val( element );
	 
     drop.css('visibility', 'hidden');
}

function openCloseFList(element, openelement){
        //if(!openCloseList(element, openelement)) return;
		openCloseList(element, openelement);
        $(openelement+' #vreturn').text($(element).attr('id'));
}

function checkButton( elementId, input, n, Status){
var pos = document.getElementById( elementId );

if( input )
{
	var input2 = document.getElementById( input );
        if (Status)
        {
	    input2.checked = Status;
        }
        else
        {
            if (input2.checked && input2.checked.toString().length > 0)
            {
                input2.checked = "";
            } 
            else
            {
                input2.checked = "1";
            }
        }
}

    var pos = document.getElementById( elementId );
    if(!pos) return;
    var val = pos.style.backgroundPosition;

    var ch = "right top";
    var unch = "right -13px";

    //alert("VAL=" + val);

	if( !n )
	{
	    if(!val){
	         var className = " " + pos.className;

	         var foundclass = className.indexOf("uncheck");
	         if(foundclass == -1){
	            pos.style.backgroundPosition = ch;
	         }else{
	            pos.style.backgroundPosition = unch;
	         }
	    }else{
	       var found = val.indexOf('-13px');
	       if(found == -1){
	            pos.style.backgroundPosition = unch;
	       }else{
	            pos.style.backgroundPosition = ch;
	       }
	    }
	}
		else
	{
		if( Status ==true ) pos.style.backgroundPosition = unch;
					   else pos.style.backgroundPosition = ch;
	}

}

function selectList(element, dropid, listid, inputid, id){
     //var list = $(listid);
     //var select = $(element);
     var drop = $(dropid);
	 var input = document.getElementById(inputid);
	 input.value = id;

     //alert("select="+element);

     $(listid+' .listname').text(element);
	 drop.css('visibility', 'hidden');
}

