﻿$(document).ready(function() {
		

});



function dropdown(varID, varSelected){
			$.post("/php/services/components/dropdown.php", {id: varID, selected: varSelected}, function(xml){	
				varContent = $("item",xml).get(0);
				varOptions = $("options",varContent).text();
				$("#customers").empty( ).append(varOptions);
			});

}

function numbersonly(myfield, e, dec) {
	var key;
	var keychar;

	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if ((("0123456789.,").indexOf(keychar) > -1))
	   return true;

	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
   return false;
}

// Show DIV
// ---------------------------------------------

function show(varSHOW){
	$(varSHOW).css({display: "block"});
}


// Hide DIV
// ---------------------------------------------

function hide(varHIDE){
	$(varHIDE).css({display: "none"});
}

// Tabs deselect
// ---------------------------------------------

function deselect_tabs(varTABS){
	$(varTABS).css({backgroundPosition: '0px -33px'});
}

// Tabs select
// ---------------------------------------------

function select_tab(varTABS){
	$(varTABS).css({backgroundPosition: '0px 0px'});
}

// scroll up
// ---------------------------------------------

function scrollup(varSCROLL){
	varPOSITION = $(varSCROLL).css("top");
	varPOSITION = varPOSITION.replace(/px/i, "");
	if(varPOSITION >= 0){varPOSITION = -50;};
	$(varSCROLL).css({top: varPOSITION-1+51 + 'px'});
}

// scroll down
// ---------------------------------------------

function scrolldown(SCROLL, HEIGHT){
	varPOSITION = $(SCROLL).css("top");
	varPOSITION = varPOSITION.replace(/px/i, "");
	varHEIGHT = $(HEIGHT).css("height");
	varHEIGHT = -(varHEIGHT.replace(/px/i, ""));
	var id = SCROLL.replace(/#/i, "");

	if(varPOSITION >= varHEIGHT){
		$(SCROLL).css({top: varPOSITION-50 + 'px'});
	};
}

function like(varID, varLike){
		$.post("/php/like.php", {id: varID, like: varLike}, function(xml){	
		varContent = $("item",xml).get(0);
		varSwitch = $("like",varContent).text();
		if (varLike == "yes"){
			$('#like').empty().append('<div class="thumb_up" style="background-position: 0 -24px;"></div><div class="thumb_down" style="background-position: 0 0px;"></div>');
		} else {
			$('#like').empty().append('<div class="thumb_up" style="background-position: 0 0px;"></div><div class="thumb_down" style="background-position: 0 -24px;"></div>');
		}
	});
}