// JavaScript Document

// EDIT THESE VALUES IF REQUIRED
var alertText = 'Are you sure you wish to perform this action' + "\n"; //DEFAULT TEXT DISPLAYED ON CONFIRM BUTTONS/LINKS WHEN NO ALT/TITLE
var newWindowLink = false; //OPEN EXTERNAL LINKS BY DEFAULT IN A NEW WINDOW (TRUE/FALSE)?


var woms = new Array(); //CREATE ARRAY OF FUNCTIONS TO LAUNCH ONLOAD

//ONLOAD MANAGER
function womOn(){
  window.onload = womGo;
}

function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}

function CreateBookmarkLink() {

	title = document.title;
	url = window.location.href;
	
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if(window.external) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) {
		return true;
	}
	
}

function objToggle(obj) { 

	var obj = document.getElementById(obj);

	if(obj.style.display == "block") { 
		obj.style.display = "none";
	} else { 
		obj.style.display = "block";
	}

}


function limitChars(textarea, limit, infodiv) 
{ 
var text = textarea.value;  
var textlength = text.length; 
var info = document.getElementById(infodiv); 

if(textlength > limit) 
{ 
info.innerHTML = 'You cannot write more then '+limit+' characters!'; 
textarea.value = text.substr(0,limit); 
return false; 
} 
else 
{ 
info.innerHTML = 'You have '+ (limit - textlength) +' characters left.'; 
return true; 
} 
}



jQuery(document).ready(function() {

	if($('#mycarousel').length > 0){

		jQuery('#mycarousel').jcarousel({
			scroll : 4
		});

	}

	$('#same_delivery').click(function() {

		$('#delivery_firstname').val($('#bill_firstname').val());
		$('#delivery_lastname').val($('#bill_lastname').val());
		$('#delivery_address1').val($('#bill_address1').val());
		$('#delivery_address2').val($('#bill_address2').val());
		$('#delivery_address3').val($('#bill_address3').val());
		$('#delivery_postcode').val($('#bill_postcode').val());
		$('#delivery_town').val($('#bill_town').val());
		$('#delivery_county').val($('#bill_county').val());
		$('#delivery_country').val($('#bill_country').val());

	  });

});

