///// ////////// CUSTOM ATTRIBUTES /////////////
$(document).ready(function () {	
	$('.enableDatePicker').datepicker({showTime: false,dateFormat:datePickerDateFormat});
	$('.enableDateTimePicker').datetimepicker({dateFormat:datePickerDateFormat});
	$('.enableTimePicker').timepicker({ampm: false,stepMinute: 15});
	$(document).on("click",".importGlobalAttributes",function(event){
	event.preventDefault();		
	});	
	$(document).on("click",".customAttributeStatus",function(){		  
		var obj=$(this);
		var data=new Object();
		var ajaxUrl = "/attribute/AjaxChangeCustAttrStatus/";  
		data.customAttributeID=$(this).attr('customAttributeID'); 
		if($(this).hasClass('status-active'))
		{
			data.newClass='status-inactive hide-txt customAttributeStatus';
			data.attributeStatus='Inactive';	
		}
		else if($(this).hasClass('status-inactive'))
		{
			data.newClass='status-active hide-txt customAttributeStatus';
			data.attributeStatus='Active';	
		}
			$.ajax({
			   type: "POST",
			   url: GLOBAL_BASE_PATH+ajaxUrl,
			   data:data,
			   success: function(msg){
					setActiveTabSaveButton();
					jNotifyShow(atrributeStatusChange, "common_message","message_success");
					obj.attr('class',data.newClass+' hide-txt');
					obj.attr('title',data.attributeStatus);
			    }
  			});			
	}); 
	
	$(document).on("click",".adminAttributeCheckBoxes",function(){	
		var thisName = $(this).attr("name");
		var chkLength = $("input[type='checkbox'][name='"+thisName+"']:checked").length;
		var hiddenName = thisName.split("[]");
		hiddenName = hiddenName[0];
		var thisVal = '';
		$("input[type='checkbox'][name='"+thisName+"']:checked").each(function(){
			thisVal = thisVal+$(this).val()+',';	
		})			
		if(chkLength==0)
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val('');
		}	
		else		
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val(thisVal);
		}
	});	
	$(document).on("click",".customAttributeFile",function(){			  
		var obj=$(this);		
		var productRequestID 		= $("#productRequestID").val();
		jConfirm(lblAttributeFileDeleted, 'Alert',function (r) {
			if (r == true) 
			{				
				var data=new Object();
				var ajaxUrl = "/product/AjaxDestroyCustAttrFile/";
				var attrValueID=obj.attr('attrValueID');
				data.attrValueID=attrValueID;
				data.productRequestID=productRequestID;
				$.ajax({
				   type: "POST",
				   url: GLOBAL_BASE_PATH+ajaxUrl,
				   data:data,
				   success: function(msg){
					console.log($("#FileEdit_"+attrValueID));
					console.log($("#trashDisplay_"+attrValueID));
					$("#FileEdit_"+attrValueID).show();
					$("#trashDisplay_"+attrValueID).hide();
					
			jNotifyShow(msgAttributeFileDeleted, "common_message","message_success");											
					}
				});			
			} 
			else 
			{
				return false;
			}
		},okText,cancelText);					
	});
	$(document).on("click",".left-tab-a",function(){		
	var thisVar = $(this);
	var thisRel = $(this).attr("rel");
	var cmButtonsFloating = $("#"+thisRel+"-section").children(".cm-buttons-floating");
	var cmButtons = $("#"+thisRel+"-section").children(".cm-buttons");
	$.scrollPane({
			floating: cmButtonsFloating,
			fixed: cmButtons,
			padding: 71
		});
	toggleSaveButton(thisRel);
	var editedForms = 0;
	var editedForm = '';
	$("form").each(function(){
	if($(this).attr("changed")=="true")
	{
		editedForm = $(this).attr("rel");
		editedForms++;
	}	
	});
	if (editedForm!='' && thisRel!=editedForm) {
		jAlert(lblPageLeaveAlert);
		jConfirm(lblPageLeaveAlert, 'Alert',function (r) {
			if (r == true) 
			{
				setSelectedTab(thisVar,cmButtonsFloating,cmButtons,thisRel);
			}
			else 
			{
				return false;
			}
		},okText,cancelText);	  

	}
	else
	{
		setSelectedTab(thisVar,cmButtonsFloating,cmButtons,thisRel);
	}
	});
	$(window).scroll(function(){
     var thisRel =   $(".left-tab li a.active").attr("rel");
	 toggleSaveButton(thisRel);
    })
	setActiveTabSaveButton();	 
	$("form").attr("changed",false); 
	$("form :input").change(function() {
	$(this).parents("form").attr("changed",true);
	});	
	$(document).on("click","input[type=submit]",function() {
	$("form").attr("changed",false); 
	});
	$('form').bind("submit",function () {	
		setErrortab();
	});		
});
function setActiveTabSaveButton()
{
	var thisRel =   $(".left-tab li a.active").attr("rel");
	var cmButtonsFloating = $("#"+thisRel+"-section").children(".cm-buttons-floating");
	var cmButtons = $("#"+thisRel+"-section").children(".cm-buttons");
	$.scrollPane({
			floating: cmButtonsFloating,
			fixed: cmButtons,
			padding: 71
		});
	  $.fn.hasScrollBar = function() {
		var thisRel =   $(".left-tab li a.active").attr("rel");
		toggleSaveButton(thisRel);
	}
	var thisRel =   $(".left-tab li a.active").attr("rel");
	toggleSaveButton(thisRel);
}
window.onbeforeunload = confirmExit;
function setSelectedTab(thisVar,cmButtonsFloating,cmButtons,thisRel)
{
	
	$("ul.left-tab>li>a").removeClass("active");	
	thisVar.addClass("active");	
	var thisIndex = $("ul.left-tab>li>a").index(thisVar);
	$(".tabpane").hide();
	$(".tabpane:eq("+thisIndex+")").show();
	if(thisVar.attr('id')=="general")
	{
		$('.cropSection').addClass('cur_menu');
	}
	if(thisVar.attr('id')=="qtyPrice")
	{
		$('.cropSection').removeClass('cur_menu');
	}
	
        if(thisRel=='attribute-save' && $("#attributeSetID").val()>0 && $("#hidAttributeSetID").val()>0 && $("#attributeSetID").val()!=$("#hidAttributeSetID").val()) {
           reloadCustomAttributesCustom($("#attributeSetID").val());
        }
	if(thisVar.hasClass('inventoryLink'))
	{
	
		inventoryUpdate();
	}
        
	$.scrollPane({
				floating: cmButtonsFloating,
				fixed: cmButtons,
				padding: 71
			});
	toggleSaveButton(thisRel);
}
function confirmExit()
{
	var editedForms = 0;
	var returnData = ''
	$("form").each(function(){
	if($(this).attr("changed")=="true")
	editedForms++;
	});
	if (editedForms>0) {
	  return lblPageLeaveAlert;
	}
	return null;
}
setCustomAttributePriority();
setAttributeCheckBox();
setErrortab();
function setErrortab()
{	
	$('.left-tab-a').removeClass("error");
	$("form").each(function(){
	var formName = $(this).attr("name");
	//var invalidPanels = $(this).find('.hid_err_'+formName+'_validations[value=1]').closest('.tabpane');
	var invalidPanels = $(this).find(".message_validation:not(.hide),.message_inline_validation:not(.hide)").closest('.tabpane');
	
	if (invalidPanels.size() > 0) 
	{		
		$.each($.unique(invalidPanels.get()), function () {
			var index = $(this).index('.tabpane');					
			$('#maintab').find('.left-tab-a:eq(' + index + ')').addClass("error");
		});
	}
	});
}
function toggleSaveButton(thisRel)
{
	$(".save-floating-section").hide();
	$("#"+thisRel+"-section").show();
}
function setAttributeCheckBox()
{
	$(".adminAttributeCheckBoxes").each(function(){
		var thisName = $(this).attr("name");
		var chkLength = $("input[type='checkbox'][name='"+thisName+"']:checked").length;
		var hiddenName = thisName.split("[]");
		hiddenName = hiddenName[0];
		var thisVal = '';
		$("input[type='checkbox'][name='"+thisName+"']:checked").each(function(){
			thisVal = thisVal+$(this).val()+',';	
		})			
		if(chkLength==0)
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val('');
		}	
		else		
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val(thisVal);
		}
	});	
}
//MIC
function reloadCustomAttributesCustom(attributeSetID)
{		
	$("#loadCustomAttributesLoader").removeClass("hide");
	$("#loadCustomAttributesLoader").show();
	var productID 				= $("#productID").val();
	var productRequestID 		= $("#productRequestID").val();
	
	if(productID>0 || productRequestID>0)
	{
		$.ajax({
			type: "POST",
			async:false,
			url: GLOBAL_BASE_PATH + '/product/ajaxReloadCustomAttributes/',
			data: {
				"productID": productID,				
				"productRequestID":productRequestID,
                                "attrSetID":attributeSetID ,
                                "prevAttrSetID":$("#hidAttrSetID").val() ,
			},
			success: function (data) {
                                $("#hidAttributeSetID").val(attributeSetID);
				$("#loadCustomAttributes").empty();	
				$("#loadCustomAttributesLoader").addClass("hide");
				$("#loadCustomAttributesLoader").hide();
				$("#loadCustomAttributes").append(data);
                                
				setCustomAttributePriority();	
				setActiveTabSaveButton();
				
				
				var errors = $("#formCustomAttributeAdd").find('.hid_err_formCustomAttributeAdd_validations[value=1]').length;	
				if (errors==0) 
				{		
					$('#maintab').find('.left-tab-a[rel="attribute-save"]').removeClass("error");
				}
			}
		});	
	}	
}
function reloadCustomAttributes(msgStatus)
{		
	$("#loadCustomAttributesLoader").removeClass("hide");
	$("#loadCustomAttributesLoader").show();
	var productID 				= $("#productID").val();
	var productRequestID 		= $("#productRequestID").val();
	
	if(productID>0 || productRequestID>0)
	{
		$.ajax({
			type: "POST",
			async:false,
			url: GLOBAL_BASE_PATH + '/product/ajaxReloadCustomAttributes/',
			data: {
				"productID": productID,				
				"productRequestID":productRequestID
			},
			success: function (data) {
				$("#loadCustomAttributes").empty();	
				$("#loadCustomAttributesLoader").addClass("hide");
				$("#loadCustomAttributesLoader").hide();
				$("#loadCustomAttributes").append(data);
				setCustomAttributePriority();	
				setActiveTabSaveButton();
				$('.enableDatePicker').datepicker({showTime: false,dateFormat:datePickerDateFormat});
				$('.enableDateTimePicker').datetimepicker({dateFormat:datePickerDateFormat});
				if(msgStatus)
				{	
					var msg = msgAttributeUpdate;
					if(msgStatus=='1')
					msg = msgAttributeAdd;
					else if(msgStatus=='3')
					msg = msgImportGlobalAttributes;					
					jNotifyShow(msg, "common_message","message_success");
				}
				var errors = $("#formCustomAttributeAdd").find('.hid_err_formCustomAttributeAdd_validations[value=1]').length;	
				if (errors==0) 
				{		
					$('#maintab').find('.left-tab-a[rel="attribute-save"]').removeClass("error");
				}
			}
		});	
	}	
}
function setCustomAttributePriority()
{
	if ($(".customAttributePriority").length >= 1)
	{		
		$(".customAttributePriority").tableDnD({
		onDragClass: "myDragClass",
		onDrop: function(table, row) {
		setPriorityOrder();
		}		
		});	
	}
	else
	{
		$(".customAttributePriorityRows").css("cursor","default");	
	}
}
function setPriorityOrder()
{
	var	Order	=	escape($.tableDnD.serialize());	
	if(Order.indexOf("userLevelCustomAttr")>=0)	
	{
		Order	=	Order.replace(/userLevelCustomAttr%5B%5D%3D/g,'');
	}	
	else
	return false;
	Order	=	Order.replace(/%26/g,'|');
	saveCustomAttributePriority(Order);

}
function saveCustomAttributePriority(order)
{	
	if(order)
	{
		var orderList=order.split("|");	
		var priority = 1;
		for (var i=0;i<orderList.length;i++)
		{ 
			if(orderList[i]!='')
			{
				if($("#customAttributes_"+orderList[i]+"_priority").length>0)
				{
					$("#customAttributes_"+orderList[i]+"_priority").val(priority);
					priority++;	
				}				
			}
		}	
	}	
}

///// ////////// CUSTOM ATTRIBUTES ENDS/////////////
/////////////////// Product Options Tab Begin /////////////////
$(document).ready(function () 
{
     $(document).on("click",".deleteRow", function () {		 
        var element = $(this).parent().parent();
		var row_is_delete_id	= $(this).attr('rel');
		var optId=$(this).attr('id');
		if($("#productOptionsGroup_"+optId+"_defaultOpion").is(':checked'))		
		{deletemsg=msgdeldefaultOption;}
		else
		{deletemsg=msgSelectAtleastOne;}
        jConfirm(deletemsg, 'Delete', function (deletedConfirm) 
		{
        	if (deletedConfirm == true) 
			{
				$("#"+row_is_delete_id).val('1');
					element.addClass("hide");				
                if ($(".productOptionRow").not('.hide').size() == 1)
				{
				
					$(".op-delete").addClass("hide");
                    
				}
				else
				{
					$(".op-delete").removeClass("hide");
				}
				
			$('.productOptionRow:visible:first').find('.defaultOpion').prop('checked',true);
			var id=$("input:radio.defaultOpion:checked:visible").attr('rel');
			$("input[id='productOptionsGroup_"+id+"_productOptionStatus'][value='Inactive']").attr('disabled','disabled');
			$("input[id='productOptionsGroup_"+id+"_productOptionStatus'][value='Active']").prop('checked',true);
			}
        });
    });
	 $(document).on("click","#add_new_options", function () {
   	 	loadOptions();
	});
	
});

function loadOptions() 
{
	
	if(postCallback=="1")
	{
		postCallback = '';
		return false;
	}	
	
    $("#productoptions_loader").removeClass("hide");
    var productOptionCount = $("#productOptionAddCount").val();
	var productTypeData=$("#productTypeKey").val();
	
    $.ajax({
        type: "POST",
		async:false,
        url: GLOBAL_BASE_PATH + '/product/ajaxLoadProductOptionsTpl/',
        data: {
            "productOptionCount": productOptionCount,
			 "productTypeKey": productTypeData,
			"productSelectedType":$("#productSelectedType").attr('rel')
        },
        success: function (data) {
            $("#productoptions_loader").addClass("hide");
            productOptionCount = parseInt(productOptionCount) + 1;
            $("#productOptionAddCount").val(productOptionCount)
            $('#productoptions_loader').before(data);
			/*$("#productOptionsGroup_"+productOptionCount+"_productOptionName").focus(); instead give scrolltodiv*/
			
			 if (!$("#enableMultipleOptions").is(':checked')) {			  
			$(".single-option").hide();
			$('.defaultOpion:not(.hidden)').attr('value','Yes');
			$('.defaultOpion:not(.hidden)').prop('checked', true);
			$('.defaultOpion:not(.hidden)').attr('disabled',true);			
			 }
			 else
			 {
		if($('.productOptionRow:not(.hidden)').size()>1)
		{	
		var z=0;		
		$('.op-delete').removeClass("hide");	
		$('.defaultOpion').each(function() { 
		
		if ($(this).is(':checked')) { 
		z=1;
		}
		})								 
		
		if (z == 1) 
		{
		
		$("#productOptionsGroup_"+productOptionCount+"_defaultOpion").attr('value','');
		$("#productOptionsGroup_"+productOptionCount+"_defaultOpion").prop('checked', false);
		}	} 
			 }
			if($("#InventoryTrackLevel").val()=='No')
				{
				$('.stock').hide();
				}
				else
				{
				if($("#InventoryTrackLevel").val()=='Product')	
				$(".optionQty").addClass('mandatory');				
				$('.stock').show();
				}		
            $("#productoptions_loader").addClass("hide");
        }
    });
}

// Product Options Tab End 

//Product Image section
    var productID = $("#productID").val();
        var productRequestID = $("#productRequestID").val();
        if (!productID && !productRequestID) {
			loadOptions();	
			}
			 
	if(!$("#enableMultipleOptions").is(':checked')) 
       {				
		$('.single-option').hide();	
		$('.productOptionRow').removeClass("option");
		$('.defaultOpion:not(.hidden)').attr('value','Yes');
		$('.defaultOpion:not(.hidden)').prop('checked', true);
		$('.defaultOpion:not(.hidden)').attr('disabled',true);
       }
       else
       {
	if (productID || productRequestID)
	$('.inventoryTab').hide();
	var id=$("input:radio.defaultOpion:checked").attr('rel');
	$("input[id='productOptionsGroup_"+id+"_productOptionStatus'][value='Inactive']").attr('disabled','disabled');
	
		if($('.productOptionRow:not(.hidden)').size()==1)
		{			
		$('.op-delete').addClass("hide");	
		}
		$('.productOptionRow').addClass("option");
       }
			
  $(document).on('click',".add_option_images",function () {
	
		var productOptionId=$(this).attr('id');		
		var productOptionImageCount=$("#productOptionImageCount"+productOptionId).val();	
		var loadProductImages = loadOptionImages(productOptionImageCount,productOptionId);
		$("#noImageUl").addClass("hide");
		setTimeout('$("#productImagesul .delete").remove();', 200);		
    })
function loadOptionImages(productOptionImageAddCount,optionCount) {
    $("#productimages_loader").removeClass("hide");
    var productImageCount = productOptionImageAddCount;
    $.ajax({
        type: "POST",
        url: GLOBAL_BASE_PATH + '/product/ajaxlistProductOptionImages/',
		async:false,
        data: {
            "productImageCount": productImageCount,
			 "optionCount": optionCount,
            "ajax_root_path": GLOBAL_ROOT_PATH
        },
        success: function (data) {
          //  $('#productImagesul'+optionCount).append(data);
	    $(data).insertBefore('#upload-btn'+optionCount);
            $("#productOptionImageCount"+optionCount).val(parseInt(productImageCount) + 1);
	    
	     if ($(".productImageLi"+optionCount).not('.hide').size() == 1)
	     {
            $("#productImagesul"+optionCount+" .delete02").hide();
	     }
	     else
	       $("#productImagesul"+optionCount+" .delete02").show();
            $('.edit').attr('title', 'Edit');
	 $("#productOptionImageCountNo"+optionCount).val(parseInt(productImageCount) + 1);		     
			// obj.attr('id','add_new_images');
        }
    });
}
//MIC



$(document).on('click',".defaultOpion",function () {
		
	$('.defaultOpion').each(function() {

	     $(this).prop('checked', false);
		 $("input[id='productOptionsGroup_"+$(this).attr('rel')+"_productOptionStatus'][value='Inactive']").removeAttr('disabled');
						 })							 
		$(this).prop('checked',true);	
		
		$(this).attr('value','Yes');
		$("input[id='productOptionsGroup_"+$(this).attr('rel')+"_productOptionStatus'][value='Inactive']").prop('checked',false);
		$("input[id='productOptionsGroup_"+$(this).attr('rel')+"_productOptionStatus'][value='Inactive']").attr('disabled','disabled');
		 $("input[id='productOptionsGroup_"+$(this).attr('rel')+"_productOptionStatus'][value='Active']").prop('checked',true);
		 	 
	})
$(document).on("click",'#enableMultipleOptions',function(){	
		    if ($("#enableMultipleOptions").is(':checked')) 
			{
				$('.inventoryTab').hide();
				$("#enableMultiple").val('checked');											   
				$('.defaultOpion:not(.hidden)').attr('disabled',false);
				$(".productOptionRow:visible input[type='radio'][value='Inactive']").removeAttr('disabled');
				$('.single-option').show();
				$(".other:not(.deleted)").removeClass("hide");                                              
				$('.multioptiondelete:not(.hidden)').attr('value','0');
					 //delete only one row											 
				if($('.productOptionRow:not(.hide)').size()==1)
					       {	
				$('.op-delete').addClass("hide");
				$(".productOptionRow:visible input[type='radio'][value='Inactive']").attr('disabled','disabled');
															       
					       }
					       else
					       {
						       $('.op-delete').removeClass("hide");
						       
					       }
					       $('.productOptionRow').addClass("option");	
			}
    else {
		$('.inventoryTab').show();
		$('#enableMultiple').val('');
		 $('.multioptiondelete').val('1');		
		 $('.productOptionRow:visible:not(:first)').addClass("other"); 
		 $('.productOptionRow:visible:not(:first)').addClass("hide");				 		     		
		$('.productOptionRow:visible .multioptiondelete').attr('value','0');
		 $('.single-option').hide();
		 $('.op-delete').addClass("hide");
		 $('.productOptionRow').removeClass("option");	  
    }
});
/////////////////// Product Options Tab End /////////////////

//Import Global Option Section   
    function reloadCustomOptions(msgStatus)
{		
	$("#loadCustomAttributesLoader").removeClass("hide");
	$("#loadCustomAttributesLoader").show();
	var productID 				= $("#productID").val();
	var productRequestID 		= $("#productRequestID").val();	
	if(productID>0 || productRequestID>0)
	{
		
		$.ajax({
			type: "POST",
			async:false,
			url: GLOBAL_BASE_PATH + '/product/ajaxReloadCustomOption/',
			data: {
				"productID": productID,				
				"productRequestID":productRequestID
			},
			success: function (data) {
				$("#loadCustomOptions").empty();	
				$("#loadCustomOptionsLoader").addClass("hide");
				$("#loadCustomOptionsLoader").hide();
				$("#loadCustomOptions").append(data);
				setCustomAttributePriority();	
				setActiveTabSaveButton();				
				if(msgStatus)
				{	
					var msg = msgOptionUpdate;
					if(msgStatus=='1')
					msg = msgOptionAdd;
					else if(msgStatus=='3')
					{
					msg = msgImportGlobalOption;
					
					}
					jNotifyShow(msg, "common_message","message_success");					
					
				}
				$("#optionBlockChange").val(1);
				var errors = $("#formCustomOptionAdd").find('.hid_err_formCustomOptionAdd_validations[value=1]').length;	
				if (errors==0) 
				{		
					$('#maintab').find('.left-tab-a[rel="custom-option-save"]').removeClass("error");
				}
			}
		});	
	}	
}

$(document).on("click",".customOptionDelete",function(){
	
		var obj=$(this);
		jConfirm(msgConfirmDelete, 'Alert',function (r) {
			if (r == true) 
			{
				
				var data=new Object();
				var ajaxUrl = "/productoption/AjaxDestroyProOption/";  
				data.customOptionID=obj.attr('customOptionID');
				data.productID= $("#productID").val();
				data.productRequestID= $("#productRequestID").val();
				data.isGlobal= obj.attr('rel');
				data.type= obj.attr('type');
				$.ajax({
				   type: "POST",
				   url: GLOBAL_BASE_PATH+ajaxUrl,
				   data:data,
				   success: function(data){
					if (data) {
					if (data!=3)
					{
				$("#optionBlockChange").val(1);
				 reloadCustomOptions();
				setActiveTabSaveButton();
				jNotifyShow(msgOptionDeleted, "common_message","message_success");
					}
					else
					{
					jNotifyShow(msgdeleteCustomOption, "common_message","message_error");	
					}
				
				
							}
							}
				});			
			} 
			else 
			{
				return false;
			}
		},okText,cancelText);					
	});


$(document).on("click",".ComboCheckBoxes",function(){	
		var thisName = $(this).attr("name");
		var chkLength = $("input[type='checkbox'][name='"+thisName+"']:checked").length;
		var hiddenName = thisName.split("[]");
		hiddenName = hiddenName[0];
		var thisVal = '';
		$("input[type='checkbox'][name='"+thisName+"']:checked").each(function(){
			thisVal = thisVal+$(this).val()+',';	
		})			
		if(chkLength==0)
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val('');
		}	
		else		
		{
			$("input[type='hidden'][name='"+hiddenName+"']").val(thisVal);
		}
	});



$(document).on("click",".customOptionStatus",function(){		  
		var obj=$(this);
		var data=new Object();
		var ajaxUrl = "/productoption/AjaxChangeOptStatus/";  
		data.customOptionID=$(this).attr('customOptionID');
		data.productRequestID= $("#productRequestID").val();
		data.type=$(this).attr('type');
		if($(this).hasClass('status-active'))
		{
			data.newClass='status-inactive hide-txt icon-tick customOptionStatus';
			data.status='I';

		}
		else if($(this).hasClass('status-inactive'))
		{
			data.newClass='status-active hide-txt icon-tick customOptionStatus';
			data.status='A';	
		}
			$.ajax({
			   type: "POST",
			   url: GLOBAL_BASE_PATH+ajaxUrl,
			   data:data,
			   success: function(msg){
					setActiveTabSaveButton();
					if (msg==2)
				    jNotifyShow(OptionStatusmsg, "common_message","message_error");
					else					
					{
					jNotifyShow(OptionStatusChange, "common_message","message_success");
					obj.attr('class',data.newClass+' hide-txt');
					obj.attr('title','status');
					$("#optionBlockChange").val(1);
					}
			    }
  			});			
	});

$(document).on("click",".attributeReset",function(){
$attributeID=$(this).attr('rel');
	if($("#adminAttributeValues_"+$attributeID).val()!='')
	{
$("#adminAttributeValues_"+$attributeID).val('');
	}

});
function inventoryUpdate()
{	
var productID=$("#productID").val();
var productRequestID= $("#productRequestID").val();	
if($("#optionBlockChange").val()==1)
{
$.ajax({
			type: "POST",
			async:false,
			url: GLOBAL_BASE_PATH + '/product/ajaxReloadAddCombo/',
			data:"productID="+productID+"&productRequestID="+productRequestID,
			 success: function(data){    
			var x = jQuery.parseJSON(data);
			 $("#ajaxAddBlock").html('');
			  if (x.count>0)
			{
			$("#AddComboLink").show();
			}
			else
			{
			$("#AddComboLink").hide();
			} 
			 $("#ajaxAddBlock").html(x.html);
			 $("#optionBlockChange").val(0);
			 }
			 
});
}
}
function showThumbImages(opid,imagecount)
{
$("#thumbBlock_" + opid+"_" + imagecount).removeClass('hide');
$("#thumbLink_" + opid+"_" + imagecount).removeClass("show");
$("#thumbLink_" + opid+"_" + imagecount).addClass("hide");
$("#thumbBlock_" + opid+"_" + imagecount).focus();
}
setCurrentTab();
function setCurrentTab()
{
if(__currentTab)
{
	$('.left-tab-a').removeClass('active');
	$(".tabpane").hide();
	$('.left-tab-a[rel=' + __currentTab + ']').addClass('active');
	var thisVar = $('.left-tab-a[rel=' + __currentTab + ']');
	var thisIndex = $("ul.left-tab>li>a").index(thisVar);
	$(".tabpane:eq("+thisIndex+")").show();
	
}
else
{
	$('.left-tab-a:first').addClass('active');
	$(".tabpane:first").show();
}
}

function setAjaxErrortab(formtab,show)
{	
	
	if (show==1) 
	$('.left-tab-a[rel=' + formtab + ']').addClass('error');
	else
	$('.left-tab-a[rel=' + formtab + ']').removeClass('error');	
	
}
