var msie6 = (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6);
$(document).ready(function() {
   fun();

	$('#winhfile').change(function() {
		$('#winhfile').each(function() {
				var filename = this.value;
				//reWin = /.*\\(.*)/;
				//var filename = filename.replace(reWin, "$1");
				//reUnix = /.*\/(.*)/;
				//filename = filename.replace(reUnix, "$1");
				$('#winffile').attr("value", filename);
	   });
	});

	$(".winclose").click(function(){$(".win").hide()});
	$(".winopen, #order_link").click(function(){$(".win").show()});

	/*winform */
	$('#winafter').hide();
	$('#order_form').validate();
  	$(".winsub a").click(function() {

  	    $('#order_form').submit();
		// validate and process form
    	return false;
	});
	/**/
});

$(window).bind('resize', function() {
   fun();
});

function fun() {
   var dw = (jQuery.browser.opera)?$(document.documentElement).width():$(document).width();
   if (dw < 1074) {
      $(".tmenu").css("left", ((msie6)?"280px":"0px"));
      $(".tmenu a").css("marginLeft", ((msie6)?"10px":"20px"));
   } else {
      $(".tmenu").css("left", ((msie6)?"320px":"20px"));
      $(".tmenu a").css("marginLeft", "30px");
   }
   if (msie6) {
      if ($(".bwrap").width() > 750) $(".block").css("width", "750px");
      else $(".block").css("width", "98%");
      if (dw < 1074) {
         $(".hrabs").css("right", "185px");
      } else {
         $(".hrabs").css("right", "200px");
      }
   } else {
      if (dw < 1074) {
         $(".wrapr").css("marginLeft", "270px");
      } else {
         $(".wrapr").css("marginLeft", "320px");
      }
   }
   $(".wrapper").css("height", ($(document).height()-((msie6)?20:0))+"px");
}

jQuery.extend({
	random: function(X) {
	    return Math.floor(X * (Math.random() % 1));
	},
	randomBetween: function(MinV, MaxV) {
	  return MinV + jQuery.random(MaxV - MinV + 1);
	}
});
