jQuery.fn.fadeBG = function(params) {
		
		var options = {

			opacity: 40,
			setID:''


		}
		op = jQuery.extend(options, params);
		this.each(function(){
			$(this).prepend("<div class=\"fadeBG\" id=\""+op.setID+"\" style=\"top:0px; left:0px;margin:0px;padding:0px;width:100%;	height:100%;background:url('/images/"+op.opacity+"-opacity-bl.png');	position:absolute;	text-align:center;display:block;	z-index:1000;margin:0px;	padding:0px;\"></div>");
		});
}

jQuery.fn.center = 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 = parseInt($self.css("border-top-width"));
		var borderBottom = 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 showPhoto(src)
		{
			var dest= document.getElementById('lightbox');
			var image= document.getElementById('image');
			image.src='<?=$base?>/images/imageLoading.gif';
			
			
			image.src=src;
			$('.page').fadeBG();
			$('#lightbox').show();
			$('.fadeBG').click(hideme);
			$('#lightbox').center();
			
		}
	function hideme(target)
		{
			$('.fadeBG').hide(); $('#lightbox').hide();
		}
function show(id)
	{	
		
		var product=document.getElementById(id).style;
		var element=document.getElementById(id).style;
		//product.position="absolute";
		//product.zIndex="105";
		element.display="block";
		
		
	}
function hide(id)
	{	
		var product=document.getElementById(id).style;
		var element=document.getElementById(id).style;
		element.display="none";
		//product.zIndex="1";
		//product.position="relative";

	}

function confirmSubmit(msg,submitit)
	{
	var agree=confirm(msg);
	if (agree)
		{
			if(submitit)
				{
					document.getElementById(submitit).submit();
	
				}
			return true ;
		}
	else
		{
		return false ;
		}
	}

//AJAX
   var http_request = false;
   function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
	  //stop cache
	  var date = new Date();
	  var timestamp = date.getTime();
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters + "&" + timestamp, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj,url) {
      var getstr = "?";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "hidden") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }			
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeRequest(url, getstr);
   }
