var LOADING_MESSAGE = "<img src='/resources/images/indicator.gif'> Loading ...";

/**************************
/* Marvin 02.05.2010
/* add operating hours
/**************************/
function addOperatingHours(site_id) {
	var data = $("#operating_form").serialize();
    $.ajax({
        type: "post",
		dataType: "json",
		url: "/actions/ajaxAddOperatingHours.php",
		data: data + "&site_id=" + site_id,
		success: function(data) {
            window.location = document.location.href;				
		}
    });
}

/**************************
/* Marvin 02.05.2010
/* delete operating hours
/**************************/
function deleteOperating(id, site_id) {
    $.ajax({
        type: "post",
		dataType: "json",
		url: "/actions/ajaxDeleteOperatingHours.php",
		data: "op_id=" + id + "&site_id=" + site_id,
		success: function(data) {
            window.location = document.location.href;							
		}
    });
}

function deleteImage(el) {
	var option = confirm("Delete this image?");
	
	if (option == false) {
		return false;
	} 

	var image_file = new Image();
	image_file = $(el).children("img").attr("src");
 
	image_file = image_file.substr(image_file.lastIndexOf('/')+1);

	$.ajax({
	   type: "post",
	   dataType: "json",
	   url: "/actions/ajaxDeleteImage.php",
	   data: "filename=" + image_file,
	   success: function(data){
	       if (data.success == 1) {
			   alert(data.message);
               window.location = document.location.href;			   
		   } else {
			   alert(data.message);
		   }
	   }
	});	

}

function EnlargeImage(el) {
	
	var image_size = new Image();
	image_size.src = $(el).children("img").attr("src");
	
	var currentTime = new Date();
	sDialogID = "imageDialog" + currentTime.getTime();
	sImage = $(el).children("img").attr("src").replace("micro", "");
	$('body').after("<div id='" + sDialogID
					+ "' style='padding: 0; margin: 0; display:none;'><img id='popup_img' style='margin: auto;' width='"+image_size.width+"' height='"+image_size.height+"' src='" + sImage + "'></div>");
	
	$('#' + sDialogID).dialog({modal: true, height: image_size.height + 45, width: image_size.width});
	
	/*
	if (image_size.height == 400) {
    	$('#' + sDialogID).dialog({modal: true, height: 400});
	} else {
    	$('#' + sDialogID).dialog({modal: true, width: 400});		
	}
	*/
}

function setReviewHelpful(el, iRating, iHelpful) {
   //v2
	$.ajax({
	   type: "post",
	   dataType: "json",
	   url: "/actions/ajaxRateHelpful.php",
	   data: "review_id=" + iRating + "&helpful=" + iHelpful,
	   success: function(data){
						$(el).parent().html(data.message);
	 				}
	});
}

			var ratings = Array(); 
			ratings [1] = 0;
			ratings[2] = 0;
			ratings[3] = 0;
			ratings[4] = 0;
			function ChangeFeedbackType() {
				$("#external_url").hide();
				$("#content").hide();
				$("#user_rating").hide();
				
				switch($('input[name=feedback_type]:checked').val()) {
					case "review":
						$("#content_label").html("Review Details");
						$("#content").show();
						$("#user_rating").show();
						break;
					case "comment":
						$("#content_label").html("Comment Details");
						$("#content").show();
						break;	
					case "blog":
						$("#content_label").html("Blog Extract");		
						$("#external_url").show();
						$("#content").show();
						break;
				}
				return false;
			}
			
			
			function SelectRating(iType, iRating) {
				if (ratings[iType] == iRating) {
					ratings[iType] = 0;
				} else {
					ratings[iType] = iRating;
				}
				$("#rating" + iType).removeClass("starRating0");
				$("#rating" + iType).removeClass("starRating1");
				$("#rating" + iType).removeClass("starRating2");
				$("#rating" + iType).removeClass("starRating3");
				$("#rating" + iType).removeClass("starRating4");
				$("#rating" + iType).removeClass("starRating5");
				$("#rating" + iType).addClass("starRating" + ratings[iType]);
			}



function SelectOnChange(oSelect) {
   if (oSelect.value == '-99' || oSelect.value == '-88') {
       $('#' + oSelect.id + "_other").show();
   } else {
       $('#' + oSelect.id + "_other").hide();
   }

   if (oSelect.value == '-1') {
       $('#' + oSelect.id + "_Button").hide();
   } else {
	   $('#' + oSelect.id + "_Button").show();
   }
   return false;
}


			function AddBlog() {
			
			    if (document.getElementById('blogContent').value == "") {
			    	alert('Please enter an excerpt.');
					document.getElementById('blogContent').focus();
					return false;
		 		}
	
			    if (document.getElementById('relatedURL').value == "") {
			    	alert('Please enter the link.');
					document.getElementById('relatedURL').focus();
					return false;
		 		}
				
				document.location = "#feedbacksection";
	
	            $("#siteFeedbackList").html( LOADING_MESSAGE );
				$("#siteFeedbackList").load("/actions/ajaxAddReview.php", 
											{sID: $("#siteID").val(), 
											 sComment: $("#blogContent").val(),
											 sURL: $("#relatedURL").val()
											  }, 
											  function() { alert("Blog Posting Added"); });
				
			}
		
		
		
			function AddReview() {
			
		
				switch($('input[name=feedback_type]:checked').val()) {
					case "review":
					    if ($('#review_content').val() == "") {
			    			alert('Please enter a review before you click submit.');
							return false;
				 		}
						break;
					case "comment":
					    if ($('#review_content').val() == "") {
			    			alert('Please enter a comment before you click submit.');
							return false;
				 		}
						break;	
					case "blog":
		    			if ($('#external_url_input').val() == "") {
			    			alert('Please enter the URL of the blog before you click submit.');
							return false;
				 		}
						break;
				}
				
	            $("#siteFeedbackList").html( LOADING_MESSAGE );
				
				$("#siteFeedbackList").load("/actions/ajaxAddReview.php", 
											{sID: $("#siteID").val(), 
											 sComment: $("#review_content").val(),
											 sURL: $("#external_url_input").val(),
											 sFeedbackType: $('input[name=feedback_type]:checked').val(),
											 food: ratings[1],
					                 		  service: ratings[3],
					                  		  decor:ratings[2],
					                          price: ratings[4] }, 
											  function() { alert("Thanks for posting!"); });
				
			}
		
	

		
	
		   function editPromos() {
			   $('#editPromos').show();
    	       $('#editPromos_Cancel').show();
			   $('#editPromos_Display').hide();
			   $(".promoTitle > a.deleteLink").show();
				   $('#promoStart').datepicker();
	   		   $('#promoEnd').datepicker();
	
	}
		
		   function editPromos_Cancel() {
			   $('#editPromos').hide();
	           $('#editPromos_Cancel').hide();
			   $('#editPromos_Display').show();
			   $(".promoTitle > a.deleteLink").hide();
		   
		   }
		
		   function AddPromo(siteID) {
			    if ($("#promoTitle").val() == '' || $("#promoContent").val() == ''
		            || $("#promoStart").val() == '' || $("#promoEnd").val() == '') {
					
					alert("Please complete promo details.");
					return false;
				}
		              $("#promoListing").load("/actions/ajaxPromoAction.php", 
									 { siteID: siteID,
									   promoTitle: $("#promoTitle").val(),
   									   promoContent: $("#promoContent").val(),
									   promoStart: $("#promoStart").val(), 
									   promoEnd: $("#promoEnd").val() 									   
									 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
											    //$("#foodMenu").accordion({header: "a.menuSectionHeading", autoheight: false });
												//editFoodMenu();											
											}
    								 }
									 
									 );	

			   alert('Promo has been added.');
               window.location.reload();			   
		   }
		   
		   function DeletePromo(iPromoID, siteID) {
		              $("#promoListing").load("/actions/ajaxPromoAction.php", 
									 { siteID: siteID, promoID: iPromoID
									 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
											    //$("#foodMenu").accordion({header: "a.menuSectionHeading", autoheight: false });
												//editFoodMenu();
												RefreshUserDetailsAndAccess();
											}
    								 }
									 
									 );	
   			   alert('Promo has been deleted.');
               window.location.reload();					  
		   }
		
	
 		function loadEditSiteContacts(sDivID, sSiteID) {	    	   
			   $(sDivID).show();
	 		   $(sDivID).load('/actions/ajaxGetFormEditSiteContacts.php', {siteID:  sSiteID });		   
		   }
	
		   	   
		   function loadEditSiteDetailsSection(sType, sSiteID) {
	    	   $("#editSiteDetails" + sType).show();
	 		   $("#editSiteDetails" + sType).load('/actions/ajaxGetFormEditSiteDetails.php', 
												  {type: sType, siteID: sSiteID } );		   
		   }
		   	   
		   	
		   function editSiteDetails(iSiteID) {

	           loadEditSiteContacts('#editContactDetails', iSiteID);

		       loadEditSiteDetailsSection(2171, iSiteID);
			   loadEditSiteDetailsSection(2165, iSiteID);
    		   //loadEditSiteDetailsSection('editSiteOperatingDays', 2167);
    		   loadEditSiteDetailsSection(2173, iSiteID);
    		   loadEditSiteDetailsSection(2172, iSiteID);
    		   loadEditSiteDetailsSection(2168, iSiteID);
			   loadEditSiteDetailsSection(2164, iSiteID);
			   loadEditSiteDetailsSection(3000, iSiteID);
			   loadEditSiteDetailsSection(3001, iSiteID);
			   	   loadEditSiteDetailsSection(3005, iSiteID);
	loadEditSiteDetailsSection(3006, iSiteID);
$("#siteLocations a.deleteLink").show();
			   $("#siteFeatures a.deleteLink").show();
			   
			   $('#cancelEditDetailsButton').show();
			   $('#editDetailsButton').hide();	
			   $('#operating').show();
		   }
           		   


		   function cancelEditSiteDetails() {

			   $("#editSiteDetails" + 2171).hide();
			   $("#editSiteDetails" + 2165).hide();
			   $("#editSiteDetails" + 2173).hide();
			   $("#editSiteDetails" + 2172).hide();
			   $("#editSiteDetails" + 2168).hide();
			   $("#editSiteDetails" + 2164).hide();
			   $("#editSiteDetails" + 3000).hide();
			   $("#editSiteDetails" + 3001).hide();
			   $("#editSiteDetails" + 3005).hide();
			   $("#editSiteDetails" + 3006).hide();
	
			   $('#editDetailsButton').hide();		
			   $('#editContactDetails').hide();
			   $("#siteLocations a.deleteLink").hide();
			   $("#siteFeatures a.deleteLink").hide();
			   $('#cancelEditDetailsButton').hide();
			   $('#editDetailsButton').show();		
			   $('#operating').hide();			   
		   }
				   
				   
				   
				   
		
		   function editFoodMenu() {
               //$("#foodMenu").accordion("destroy");void(0);
		       $('.deleteLink').show();		
		       $('.moveMenuItemLink').show();
			   $('#addNewMenuItemPane').show();
     		   $('#editMenuItemButton').hide();
			   
	
		   }
		   function cancelEditFoodMenu() {
               //$("#foodMenu").accordion({header: "a.menuSectionHeading", autoheight: false });
		       $('.deleteLink').hide();
			   $('.moveMenuItemLink').hide();
			   
			   $('#addNewMenuItemPane').hide();
     		   $('#editMenuItemButton').show();
	
		   }
		   
		   var sourceMenuItem;
		   
		   function MoveMenuItem(siteID, itemID) {
			   $('.moveMenuItemLink').hide();	
			   $('.moveMoveHereLink').show();	
	           sourceMenuItem = itemID;
		   }

           function MoveMenuHere(siteID, itemID) {
			   $('.moveMoveHereLink').hide();	
               $("#foodMenu").html(LOADING_MESSAGE);
               $("#foodMenu").load("/actions/ajaxMoveFoodMenuItem.php", 
									 { siteID: siteID,
									   sourceItemID: sourceMenuItem, 
									   destItemID: itemID
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
											    $("#foodMenu").accordion({header: "a.menuSectionHeading", autoheight: false });
												editFoodMenu();
											}
    								 }
									 
									 );	
		   }
		
		   
	


//function AddSiteTag(iSiteID, iTagID) {
	//"/actions/ajaxTagSite.php?sID=" + iSiteID + "&tID=" + iTagID,true);
//}


/*function AddSiteCustomTag(iSiteID, sTagValue) {
	alert('AddSiteCustomTag');
	var oXMLRequest;
    try {
        // this should work for Firefox, Opera 8.0+, and Safari browsers
         oXMLRequest=new XMLHttpRequest();
    } catch (e) {
        try {
          // this should work for IE
	      oXMLRequest=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                oXMLRequest=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("An error occurred while creating the XMLHttpRequest!");
                return false;
            }
        }
    }

    oXMLRequest.onreadystatechange=function() {
		if(oXMLRequest.readyState==4) {
            //alert("Tag Added");
        }
    }
    oXMLRequest.open("GET","/actions/ajaxTagSite.php?sID=" + iSiteID + "&tValue=" + ajaxStripChars(sTagValue),true);
    oXMLRequest.send(null);

}*/

function AddSystemTag(iSiteID, iTagType, sSelectID) {
	var oSelect = document.getElementById(sSelectID);
	var sTagValue = oSelect.value;
	if (sTagValue == '-99') {
		sTagValue = document.getElementById(sSelectID + "_other").value;
	}

	if (sTagValue != "Please Specify" && sTagValue != "") {
	
			   $("#siteDetails" + iTagType).load("/actions/ajaxTagSite.php", 
									 { sID: iSiteID,
									   tValue: sTagValue,
									   tType: iTagType	
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												//$("#reviewContent").val("");
												//$("#relatedURL").val("");
											    //$("#accordianlist").accordion();
											}
    								 }
									 
									 );	
	
	
	
	} else {
	    alert("Please enter a value before clicking 'add'.");
		document.getElementById(sSelectID + "_other").focus();
	}
}

function GetRadioValue(radioObject) {
    rad_val = 0;
    for (var i=0; i < radioObject.length; i++) {
        if (radioObject[i].checked) {
            rad_val = radioObject[i].value;
        }
    }
    return rad_val;
}

function DeleteTag(iSiteID, sTagID) {
	var oXMLRequest;
    try {
        // this should work for Firefox, Opera 8.0+, and Safari browsers
         oXMLRequest=new XMLHttpRequest();
    } catch (e) {
        try {
          // this should work for IE
	      oXMLRequest=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                oXMLRequest=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("An error occurred while creating the XMLHttpRequest!");
                return false;
            }
        }
    }

    oXMLRequest.onreadystatechange=function() {
		if(oXMLRequest.readyState==4) {
            //alert("Tag Added");
        }
    }
    oXMLRequest.open("GET","/actions/ajaxDeleteTag.php?tID=" + sTagID,true);
    oXMLRequest.send(null);

}






function DeleteSiteLocation(iSiteID, iLocationID) {
	if (confirm('Are you sure you want to delete this location?') == true) {
	    $("#siteLocationsContent").load("/actions/ajaxDeleteLocation.php", {locID:  iLocationID, siteID: iSiteID });	
	}
}



function DeleteSiteContact(iSiteID, iItemID) {
	if (confirm('Are you sure you want to delete this?') == true) {
		$("#siteLocationsContent").load("/actions/ajaxDeleteContactDetail.php", {contactID: iItemID, siteID: iSiteID });	
	}
}

function DeleteSiteTag(iSiteID, iTagID, iType, sValue) {
	if (confirm('Are you sure you want to delete this?') == true) {
		$("#siteDetails" + iType).load("/actions/ajaxDeleteTag.php", {tID: iTagID, siteID: iSiteID, tType: iType, tValue: sValue});	
	}
}


function AddNewLocation(iSiteID) {
    var sParams = "";
	
	if (document.getElementById('newLocation').value == "") {
        alert('Please enter an address before you click "add this location".');
        document.getElementById('newLocation').focus();
	    return false;
    }

	if (confirm('Are you sure you want to add "' + document.getElementById('newLocation').value + '" as an address?') == true) {
		   $("#siteLocationsContent").load("/actions/ajaxAddSiteLocation.php", 
									 { siteID: $("#siteID").val(),
									   newLocation: $("#newLocation").val(),
									   newLocality: $("#newLocality").val(),
					                   newLocality_other: $("#newLocality_other").val()
		
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												//$("#reviewContent").val("");
												//$("#relatedURL").val("");
											    //$("#accordianlist").accordion();
											}
    								 }
									 
									 );	
		
		
		
		
		
	}
}



function AddNewPhone(iSiteID) {
    var sParams = "";
	
	if (document.getElementById('newPhoneNumber').value == "") {
        alert('Please enter a phone number before you click "add this phone number".');
        document.getElementById('newPhoneNumber').focus();
	    return false;
    }

    if (confirm('Are you sure you want to add "' + document.getElementById('newPhoneNumber').value + '" as a phone number?') == true) {

			   $("#siteLocationsContent").load("/actions/ajaxAddSiteContact.php", 
									 { siteID: $("#siteID").val(),
									   contactValue: $("#newPhoneNumber").val(),
									   contactType: "phone"	
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												//$("#reviewContent").val("");
												//$("#relatedURL").val("");
											    //$("#accordianlist").accordion();
											}
    								 }
									 
									 );	
	}
}

function AddNewEmail(iSiteID) {
    var sParams = "";
	
	if (document.getElementById('newEmailAddress').value == "") {
        alert('Please enter a Email number before you click "add this Email number".');
        document.getElementById('newEmailAddress').focus();
	    return false;
    }

    if (confirm('Are you sure you want to add "' + document.getElementById('newEmailAddress').value + '" as an email address?') == true) {

			   $("#siteLocationsContent").load("/actions/ajaxAddSiteContact.php", 
									 { siteID: $("#siteID").val(),
									   contactValue: $("#newEmailAddress").val(),
									   contactType: "email"	
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												//$("#reviewContent").val("");
												//$("#relatedURL").val("");
											    //$("#accordianlist").accordion();
											}
    								 }
									 
									 );	
	}
}


function AddNewWebsite(iSiteID) {
    var sParams = "";
	
	if (document.getElementById('newWebsite').value == "") {
        alert('Please enter a phone number before you click "add this phone number".');
        document.getElementById('newWebsite').focus();
	    return false;
    }

	if (confirm('Are you sure you want to add "' + document.getElementById('newWebsite').value + '" as a website?') == true) {
	
			   $("#siteLocationsContent").load("/actions/ajaxAddSiteContact.php", 
									 { siteID: $("#siteID").val(),
									   contactValue: $("#newWebsite").val(),
									   contactType: "website"	
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												//$("#reviewContent").val("");
												//$("#relatedURL").val("");
											    //$("#accordianlist").accordion();
											}
    								 }
									 
									 );	}
}




   function DeleteReview(iSiteID, iReviewID) {
           if (confirm('Are you sure you want to delete this review?') == true) {
			  $("#siteFeedbackList").load("Processing...");
	          $("#siteFeedbackList").load("/actions/ajaxDeleteReview.php", 
									 { sID: iSiteID,
									   iReviewID: iReviewID
									 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
    											//$("#accordianlist").accordion();
												
											}
    								 }
									 
									 );	
	
	
	}
}

   function DeleteRating(iSiteID, iReviewID) {
           if (confirm('Are you sure you want to delete this review?') == true) {
			  $("#siteFeedbackList").load("Processing...");
	          $("#siteFeedbackList").load("/actions/ajaxDeleteRating.php", 
									 { sID: iSiteID,
									   iRatingID: iReviewID
									 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
    											//$("#accordianlist").accordion();
												
											}
    								 }
									 
									 );	
	
	
	}
}
	
	
	
	   
function DeleteComment(iSiteID, iReviewID) {
           if (confirm('Are you sure you want to delete this review?') == true) {
			  $("#siteFeedbackList").load("Processing...");
	          $("#siteFeedbackList").load("/actions/ajaxDeleteComment.php", 
									 { sID: iSiteID,
									   iReviewID: iReviewID
									 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
    											//$("#accordianlist").accordion();
												
											}
    								 }
									 
									 );	
	
	
	}
}
   
	   function AddFoodMenuItem(iSiteID) {
	
		    var timestamp = new Date();
	    	var sSection = document.getElementById('foodItemSection').value;
	     	if (sSection == '-99') {
		    	sSection = document.getElementById("foodItemSection_other").value;
	     	}
		    $("#foodMenu").html("Adding menu item...");
	
            $("#foodMenu").load("/actions/ajaxAddFoodMenuItem.php?t=" + timestamp.getTime(), 
									 { siteID: document.getElementById('siteID').value,
									   section: sSection,
									   name: $("#foodItemName").val(),
					                   desc: $("#foodItemDesc").val(),
					                   size: $("#foodItemSize").val(),
					                   price: $("#foodItemPrice").val()
								 }, function(responseText, textStatus, XMLHttpRequest) {
										    if (textStatus == "success") {
												editFoodMenu();
											}
    								 }
									 
								 );	
		}
	   


function DeleteFoodMenuItem(iSiteID, iItemID) {

	if (confirm('Are you sure you want to delete this item?') == true) {
	
	          $("#foodMenu").load("/actions/ajaxDeleteFoodMenuItem.php", 
									 { siteID: iSiteID,
									   itemID: iItemID
									 }, function(responseText, textStatus, XMLHttpRequest) {

										    if (textStatus == "success") {
												editFoodMenu();
											}
    								 }
									 
									 );	
	}
}
	   
	   
	   
	   
	   
	   
	   
	   function AjaxLogin(sFormID) {
	    	var objForm = document.getElementById(sFormID);
			var sUserName = "";
			var sPassword = ""; 
	    	for (i=0; i<objForm.elements.length; i++){
		        if (objForm.elements[i].id == "u") { sUserName = objForm.elements[i].value };
				if (objForm.elements[i].id == "p") { sPassword = objForm.elements[i].value; objForm.elements[i].value = ""; };
			}
			
			ajaxPOST("/actions/ajaxLogin.php", "u=" + sUserName + "&p=" + sPassword, AjaxLoginCallBack); 	
		}	 
		
		function AjaxLoginCallBack(readyState, status, responseText) {
		   if (readyState == 4) {
		        if (responseText != "anonymous") {	     
			      alert("Welcome back. You are now logged on.");
				  document.getElementById('currentUserMessage').innerHTML = "You are logged on as " + responseText;
			   } else {
			      alert("Sorry, I could not log you on. Please check your username and password.");
			   }
		   }
		}
 
 
 
 
 (function(a){a.fn.fancyZoom=function(p){var p=p||{};var m=p&&p.directory?p.directory:"images";var e=false;if(a("#zoom").length==0){var f=a.browser.msie?"gif":"png";var k='<div id="zoom" style="display:none;">                   <table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;">                     <tbody>                       <tr>                         <td class="tl" style="background:url('+m+"/tl."+f+') 0 0 no-repeat; width:20px; height:20px; overflow:hidden;" />                         <td class="tm" style="background:url('+m+"/tm."+f+') 0 0 repeat-x; height:20px; overflow:hidden;" />                         <td class="tr" style="background:url('+m+"/tr."+f+') 100% 0 no-repeat; width:20px; height:20px; overflow:hidden;" />                       </tr>                       <tr>                         <td class="ml" style="background:url('+m+"/ml."+f+') 0 0 repeat-y; width:20px; overflow:hidden;" />                         <td class="mm" style="background:#fff; vertical-align:top; padding:10px;">                           <div id="zoom_content">                           </div>                         </td>                         <td class="mr" style="background:url('+m+"/mr."+f+') 100% 0 repeat-y;  width:20px; overflow:hidden;" />                       </tr>                       <tr>                         <td class="bl" style="background:url('+m+"/bl."+f+') 0 100% no-repeat; width:20px; height:20px; overflow:hidden;" />                         <td class="bm" style="background:url('+m+"/bm."+f+') 0 100% repeat-x; height:20px; overflow:hidden;" />                         <td class="br" style="background:url('+m+"/br."+f+') 100% 100% no-repeat; width:20px; height:20px; overflow:hidden;" />                       </tr>                     </tbody>                   </table>                   <a href="#" title="Close" id="zoom_close" style="position:absolute; top:0; left:0;">                     <img src="'+m+"/closebox."+f+'" alt="Close" style="border:none; margin:0; padding:0;" />                   </a>                 </div>';a("body").append(k);a("html").click(function(q){if(a(q.target).parents("#zoom:visible").length==0){l();}});a(document).keyup(function(q){if(q.keyCode==27&&a("#zoom:visible").length>0){l();}});a("#zoom_close").click(l);}var o=a("#zoom");var j=a("#zoom_table");var i=a("#zoom_close");var h=a("#zoom_content");var b=a("td.ml,td.mm,td.mr");this.each(function(q){a(a(this).attr("href")).hide();a(this).click(n);});return this;function n(w){if(e){return false;}e=true;var q=a(a(this).attr("href"));var u=p.width;var v=p.height;var r=window.innerWidth||(window.document.documentElement.clientWidth||window.document.body.clientWidth);var E=window.innerHeight||(window.document.documentElement.clientHeight||window.document.body.clientHeight);var C=window.pageXOffset||(window.document.documentElement.scrollLeft||window.document.body.scrollLeft);var B=window.pageYOffset||(window.document.documentElement.scrollTop||window.document.body.scrollTop);var F={width:r,height:E,x:C,y:B};var r=(u||q.width())+60;var E=(v||q.height())+60;var z=F;var A=Math.max((z.height/2)-(E/2)+B,0);var D=(z.width/2)-(r/2);var s=w.pageY;var t=w.pageX;i.attr("curTop",s);i.attr("curLeft",t);i.attr("scaleImg",p.scaleImg?"true":"false");a("#zoom").hide().css({position:"absolute",top:s+"px",left:t+"px",width:"1px",height:"1px"});g();i.hide();if(p.closeOnClick){a("#zoom").click(l);}if(p.scaleImg){h.html(q.html());a("#zoom_content img").css("width","100%");}else{h.html("");}a("#zoom").animate({top:A+"px",left:D+"px",opacity:"show",width:r,height:E},500,null,function(){if(p.scaleImg!=true){h.html(q.html());}d();i.show();e=false;});return false;}function l(){if(e){return false;}e=true;a("#zoom").unbind("click");g();if(i.attr("scaleImg")!="true"){h.html("");}i.hide();a("#zoom").animate({top:i.attr("curTop")+"px",left:i.attr("curLeft")+"px",opacity:"hide",width:"1px",height:"1px"},500,null,function(){if(i.attr("scaleImg")=="true"){h.html("");}d();e=false;});return false;}function c(s){a("#zoom_table td").each(function(u){var t=a(this).css("background-image").replace(/\.(png|gif|none)\"\)$/,"."+s+'")');a(this).css("background-image",t);});var r=i.children("img");var q=r.attr("src").replace(/\.(png|gif|none)$/,"."+s);r.attr("src",q);}function g(){if(a.browser.msie&&parseFloat(a.browser.version)>=7){c("gif");}}function d(){if(a.browser.msie&&a.browser.version>=7){c("png");}}};})(jQuery);
 
 