/***
**		Atomic Update v.4.0b 
**		common js library
**		author jb sigit n 
**		May 20, 2009
**		http://www.antibiasa.net
**/

var BASEURL = 'http://www.kettlevalleystone.com/admin/';
var ROOTURL = BASEURL+'index.php/';

function SetImageSwap(PrevImage,ActiveImage)
{
	InactiveImage = $(PrevImage).attr('src');
	$(PrevImage).attr('src',ActiveImage);
	$(PrevImage).mouseout(function(){$(PrevImage).attr('src',InactiveImage);});	
}

function SwapLargeImage(ImageURL)
{
	$("#LargeImage img").attr('src',ImageURL);
}

function effectStart()
{
	$("#footer-outer").animate({"width":187,"opacity":"show"},"1000","easeInSine",function(){
		$("#footer-content").fadeIn("fast",function(){
			$("#body-content").slideDown("slow");
		});		
	});
}

function ajaxfilemanager(field_name, url, type, win) 
{
	var ajaxfilemanagerurl = BASEURL+"js/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";
	switch (type) {
		case "image":
			break;
		case "media":
			break;
		case "flash": 
			break;
		case "file":
			break;
		default:
			return false;
	}
    tinyMCE.activeEditor.windowManager.open({
        url: BASEURL+"js/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php",
            width: 782,
            height: 440,
            inline : "yes",
            close_previous : "no"
     },{
            window : win,
            input : field_name
     });
}


function Redirect(URL)
{
	window.location = URL;
}

function ValidateForm(ElID)
{
	if(ElID!='')
	{
		el = $("#"+ElID);
		if(el.val()=='')
		{
			$("#Error"+el.attr('id')).remove();
			$("#"+ElID).after("<span class=\"FieldRequired\" id=\"Error"+el.attr('id')+"\">&nbsp;&nbsp;This field is required.</span>");
		}
		else
		{
			$("#Error"+el.attr('id')).remove();
		}
	}
	else
	{	
		result = true;
		$("label[class='required']").each(function(){
			
			el = $("#"+$(this).attr('for'));
			if(el.val()=='')
			{
				$("#Error"+el.attr('id')).remove();
				$("#"+el.attr('id')).after("<span class=\"FieldRequired\" id=\"Error"+el.attr('id')+"\">&nbsp;&nbsp;This field is required.</span>");
				result = false;
			}
			else
			{
				$("#Error"+el.attr('id')).remove();
				result = true;
			}
			
		});
		return result;
	}
}


function TriggerCheck(checkboxAll)
{
	if(checkboxAll.is(":checked"))
		$("input[class='RecordCheckbox']").attr("checked",true);
	else
		$("input[class='RecordCheckbox']").attr("checked",false);
}

function TriggerCheckImage()
{
	isCheck = $("#isCheckCounter").val();
	
	if(isCheck==1)
		 $("#isCheckCounter").val(0);
	else
		 $("#isCheckCounter").val(1);

	isCheckCounter = $("#isCheckCounter").val();
	if(isCheckCounter ==1)
	{
		$("input[name='CategoryGalleryID[]']").attr("checked",true);
	}
	else
	{
		$("input[name='CategoryGalleryID[]']").attr("checked",false);
	}
}

function TriggerCheckGallery(checkboxAll)
{
	if(checkboxAll.is(":checked"))
		$("input[class='RecordCheckbox']").attr("checked",true);
	else
		$("input[class='RecordCheckbox']").attr("checked",false);
	
	markselected($("input[class='RecordCheckbox']"));
}

function TriggerCheckProductImage()
{
	isCheck = $("#isCheckCounter").val();
	
	if(isCheck==1)
		 $("#isCheckCounter").val(0);
	else
		 $("#isCheckCounter").val(1);

	isCheckCounter = $("#isCheckCounter").val();
	if(isCheckCounter ==1)
	{
		$("input[name='ProductGalleryID[]']").attr("checked",true);
	}
	else
	{
		$("input[name='ProductGalleryID[]']").attr("checked",false);
	}
}


