var Site = {

	Init: function() {
		Site.ImageRotater();
		Site.NewsRotater();
		Site.Reorder();
		
		if ($('txtUsername')) $('txtUsername').focus();
		if ($('txtTitle')) $('txtTitle').focus();
		if ($('txtHeadline')) $('txtHeadline').focus();
		if ($('txaData')) $('txaData').focus();
		if ($('txtName')) $('txtName').focus();
		if ($('txtFirstName')) $('txtFirstName').focus();
		
		if ($('product-ticker')) fnProductTickerStart();
	},

	ImageRotater: function() {
		if ($(document.body).getElement('div.imageRotater')) {
			var scroller = new ContentScroller({slideDuration: 4500, fadeDuration: 500});
			scroller.addSlides($$('div.imageRotater img').setStyle('z-index', 1));
			scroller.start();
		}
	},
	
	NewsRotater: function() {
		if ($(document.body).getElement('div.newsRotater')) {
			$(document.body).getElement('div.newsRotater').setStyle('display', 'block');
			
			var scroller = new ContentScroller({slideDuration: 4500, fadeDuration: 500});
			scroller.addSlides($$('div.newsRotater div').setStyle('z-index', 1));
			scroller.start();
		}
	},
	
	ChangeImage: function(element, image, title) {
		if ($(element)) {
			$(element).src = image;
			$(element).title = title;		
		}
	},
	
	Reorder: function() {
		if ($('itemList')) {
			var sortableLists = new Sortables($('itemList'), {
				clone: true,
				handle: '.handle', 
				revert: {
					duration: 50
				},
				opacity: .1,
				onStart: function(el){
				/*	el.highlight('#F3F865');*/	
				},
				onSort: function(el) {
				},
				onComplete: function(el) {
					$('hdnPostionIDs').value = this.serialize(0); 
				}
			}).attach();
		}
	}
		
};

window.addEvent("domready", Site.Init);

function FillingDeliveryAddress() {
	$('txtShippingFirstName').value = $('txtBillingFirstName').value;
	$('txtShippingLastName').value = $('txtBillingLastName').value;
	$('txtShippingAddress1').value = $('txtBillingAddress1').value;
	$('txtShippingAddress2').value = $('txtBillingAddress2').value;
	$('txtShippingTownCity').value = $('txtBillingTownCity').value;
	$('txtShippingCounty').value = $('txtBillingCounty').value;
	$('txtShippingPostcode').value = $('txtBillingPostcode').value;
	$('sltShippingCountryID').value = $('sltBillingCountryID').value;
} //FillingDeliveryAddress

function fnOrder(lngID1, lngOrderID1, lngID2, lngOrderID2, strMode, frm) {
	if (strMode == "Up") {
		frm.hdnID1.value = lngID2;
		frm.hdnOrderID1.value = lngOrderID1;
		frm.hdnID2.value = lngID1;
		frm.hdnOrderID2.value = lngOrderID2;
	} else if (strMode == "Down") {
		frm.hdnID1.value = lngID1;
		frm.hdnOrderID1.value = lngOrderID2;
		frm.hdnID2.value = lngID2;
		frm.hdnOrderID2.value = lngOrderID1;
	} //end if
	
	frm.submit();
} //fnOrder

function fnShowMasterImage($strFilename) {
	$("srcMaster").src = "/images/shop/" + $strFilename;
	$("hrefMaster").href = "/images/shop/" + $strFilename;
} //fnShowMasterImage

