﻿jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
 $(document).ready(
 function() {
   $("td.ShopWithDesc").mouseover(
        function(event) {
                GetShopDescriptionInitiate(event, $(this).parent().attr("id"),this)
   }).mouseout(function(){CloseShopDescription();});


        });

String.prototype.startsWith = function (str)
{ return (this.match("^" + str) == str) }

$.fn.positionCenter = function(options) {
            var pos = {
              sTop : function() {
                return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||	document.body.scrollTop;
              },
              wHeight : function() {
                return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
              }
            };
            return this.each(function(index) {
              if (index == 0) {
                var $this = $(this);
                var elHeight = $this.outerHeight();
                var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
                $this.css({
                  position: 'absolute',
                  margin: '0',
                  top: elTop,
                  left: (($(window).width() - $this.outerWidth()) / 2) + 'px'
                });
              }
              });
              }

 jQuery.fn.center2 = function(params) {

		var options = {

			vertical: true,
			horizontal: true

		}
		op = jQuery.extend(options, params);

   return this.each(function(){

		//initializing variables
		var $self = jQuery(this);
		//get the dimensions using dimensions plugin
		var width = $self.width();
		var height = $self.height();
		//get the paddings
		var paddingTop = parseInt($self.css("padding-top"));
		var paddingBottom = parseInt($self.css("padding-bottom"));
		//get the borders
		var borderTop = 0;//parseInt($self.css("border-top-width"));
		var borderBottom =0;//parseInt($self.css("border-bottom-width"));
		//get the media of padding and borders
		var mediaBorder = (borderTop+borderBottom)/2;
		var mediaPadding = (paddingTop+paddingBottom)/2;
		//get the type of positioning
		var positionType = $self.parent().css("position");
		// get the half minus of width and height
		var halfWidth = (width/2)*(-1);
		var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
		// initializing the css properties
		var cssProp = {
			position: 'absolute'
		};

		if(op.vertical) {
			cssProp.height = height;
			cssProp.top = '50%';
			cssProp.marginTop = halfHeight;
		}
		if(op.horizontal) {
			cssProp.width = width;
			cssProp.left = '50%';
			cssProp.marginLeft = halfWidth;
		}
		//check the current position
		if(positionType == 'static') {
			$self.parent().css("position","relative");
		}
		//aplying the css
		$self.css(cssProp);


   });

}; 
function reload(arg)
{
    window.location=window.location;
}
var descIsUnderWay=false;
function GetShopDescriptionInitiate(e,id,o)
{
        window.status=e.pageY;
        $("#shopdesc").show();
        
        $("#shopdesc").html("<table width='100%' height='100%'><tr valign='middle'><td align='center'><img src='/ontargo/graphics/icons/waitanimation20.gif' /></td></tr></table>");
        $("#shopdesc").css({ top: e.pageY, left: e.pageX+200 });
        //$get("shopdesc").style.top=e.pageY;
        //$get("shopdesc").style.left=e.pageX+200;
        
        GetShopDescription(id);
        descIsUnderWay=true;
}
function shopCallback(arg)
{
        $get("shopdesc").style.height='';
        $get("shopdesc").style.width='';

    $("#shopdesc").html(arg);



    descIsUnderWay=false;

}
function CloseShopDescription()
{
    $("#shopdesc").html("");
    $("#shopdesc").hide();
    descIsUnderWay=false;


}
