    function getItem(id){
        var itm = false;
        if(document.getElementById)
            itm = document.getElementById(id);
        else if(document.all)
            itm = document.all[id];
        else if(document.layers)
            itm = document.layers[id];

        return itm;
    }

    function toggleSubmit(){
        itm = getItem('submit');


        if(itm.style.display == 'none'){
            itm.style.display = '';
        }else{
            itm.style.display = 'none';
	}

        return false;
    }


	function attach_file(p_script_url) {
      		script = document.createElement('script');
     		script.src = p_script_url;
      		document.getElementsByTagName('body')[0].appendChild(script);
	}




    function vote(id,type){


        itm1_img = getItem('init_'+type+'_img_'+id);

 	itm1_txt = getItem('init_'+type+'_txt_'+id);

	itm2_img = getItem('after_'+type+'_img_'+id);

	itm2_txt = getItem('after_'+type+'_txt_'+id);


        itm1_img.style.display = 'none';

        itm1_txt.style.display = 'none';

        itm2_img.style.display = '';

        itm2_txt.style.display = '';

	
	attach_file('vote.php?id=' + id + '&type=' + type);
	
	attach_file('../vote.php?id=' + id + '&type=' + type);

	
        return false;

    }




function startSearch(){
	var itm = getItem('search');
	var url = "/search/?search="+itm.value;
	window.location = url;
}

function doSearch(){
	var itm = getItem('search');
	var url = "../search/?search="+itm.value;
	window.location = url;
}
function upSearch(){
	var itm = getItem('search');
	var url = "../../search/?search="+itm.value;
	window.location = url;
}

function cut(input,count,main) {


	if (input.value.length >= count) {
		input.value = input.value.substring(0,count);
	}

	var reste = count - input.value.length;

	if(main!=null){
		if(reste==1){
			char = "character";
		}else{
			char = "characters";
		}
		var itm = getItem(main);
		itm.innerHTML = reste + " " + char + " left";
		
	}

}


function swapLink(id){


        itm1 = getItem('init_'+id);

	itm2 = getItem('after_'+id);




        itm1.style.display = 'none';
        itm2.style.display = '';
	return false;

}




function returnLink(id){


        itm2 = getItem('init_'+id);

	itm1 = getItem('after_'+id);


        itm1.style.display = 'none';
        itm2.style.display = '';
	return false;

}

