$().ready(function() {
	$('#divforlogin').jqm({modal: true, ajax: '/js/fl.php', trigger: '#loglink'});
	$('#divpolls').jqm({modal: true, ajax: '/js/resultpolls.php', trigger: '#apolls'});
});


function showitem(id){
	$.post("/js/catitem.php",{id: ""+id+""},
	function(msg){
		if(msg){
			$("#cattop").hide().empty().append(msg).fadeIn("slow");
		}
		$("#showcat").click( function() { 
		$("#cattop").hide();
		} );
	});
}

function cartevents(wh,id,param){
	
	$(".price"+id).each(function(i){
  		if(this.checked == true)param = this.value;
	});
	$.post("/js/cart.php",{wh:""+wh+"", id: ""+id+"", p: ""+param+""},
	function(msg){
		if(msg){
			$("#scripts").empty().append(msg);		
		}
		});
}

function diffevents(wh,id){
	$.post("/js/diffs.php",{wh:""+wh+"",id: ""+id+""},
	function(msg){
		if(msg){
			$("#diffdiv").slideDown("slow");
			$("#diffmesg").empty().append(msg);			
		}
	});
}

function show(id){
	if (document.getElementById("div"+id).style.display == "none"){
		$("#div"+id).slideDown("slow");
	}else{
		$("#div"+id).slideUp("slow");
	}
}

function invertAll(headerfield, checkform, mask)
{
	for (var i = 0; i < checkform.length; i++)
	{
		if (typeof(checkform[i].name) == "undefined" || (typeof(mask) != "undefined" && checkform[i].name.substr(0, mask.length) != mask))
		continue;

		if (!checkform[i].disabled)
		checkform[i].checked = headerfield.checked;
	}
}

function addFile(btn)
{
	if(document.getElementById){
		if(document.getElementById('addfield')){
			var template=document.getElementById('addfield').firstChild.nextSibling;
			var resultNode=template.cloneNode(true);
			resultNode.className='';
			resultNode=template.parentNode.appendChild(resultNode)
		}
	}
}

function dropFile(btn)
{
	if(document.getElementById){
		tr=btn;
		while(tr.tagName!='TR')tr=tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast();
	}
}
function checkForLast()
{
	btns=$("#drop").length;
	for(i=0;i<btns;i++){
		if(btns==1)$("#drop")[i].disabled = true;
		else $("#drop")[i].disabled = false;
	}
}

function paramprice(id){
	var forms = document.getElementById("formparam"+id);
	var price = forms.elements['paramselect'].value;
	$("#price"+id).empty().append(price)
}