﻿/// <reference path="jquery-1.4.4.min.js" />
$(document).ready(function () {
	//set default enter key
	$("form input").keypress(function (e) {
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
			$('.default-button').click();
			return false;
		}
	});

	//function for table list
	$('.list-table tr').slice(1).mouseover(function () {
		$(this).css("background-color", "#f0f8ff");
	});

	$('.list-table tr').slice(1).mouseout(function () {
		$(this).css("background-color", "#ffffff");
	});

	//replace url template {ApplicationURL} in <a />
	var applicationPath = $('.app-url').val();
	$('a[href*="ApplicationURL"').each(function () {
		var newPath = $(this).attr("href").replace("ApplicationURL", applicationPath);
		$(this).attr("href", newPath);
	});

	//open the popup how-to-order popup page
	$('.how-to-order.link').click(function () {
		var appFullPath = $('.app-url').val();
		var url = "http://" + appFullPath + "/popup_how_to_order.aspx";
		var win = 'toolbar=0,directories=0,menubar=0,scrollbars=1,resizable=1,width=750,height=550';
		window.open(url, '', win, '');
	});

});

//function to select selection of characters

$.fn.selectRange = function (start, end) {
	return this.each(function () {
		if (this.setSelectionRange) {
			this.focus();
			this.setSelectionRange(start, end);
		} else if (this.createTextRange) {
			var range = this.createTextRange();
			range.collapse(true);
			range.moveEnd('character', end);
			range.moveStart('character', start);
			range.select();
		}
	});
};


