function getFlashWidth(flashsrc) { // function to get flash's width
	var flashTag = document.getElementById(flashsrc);
	var iWidth = flashTag.width;
	return iWidth;
}

function getFlashHeight(flashsrc) { // function to get flash's height
	var flashTag = document.getElementById(flashsrc);
	var iHeight = flashTag.height;
	return iHeight;
}

function append_cookie(name, appendvalue, path) {
	var cookievalue = read_cookie(name);
	var duplicate = false;
	if (cookievalue != "" && cookievalue != null) {
		var cookie_array = cookievalue.split(":");
		for (var i=0; i<cookie_array.length; ++i) {
			if (cookie_array[i] == appendvalue) {
				duplicate = true;
			}
		}
	}
	if (duplicate) {
		alert("This item is already inside your cart.");
	} else {
		if (cookievalue != null)
			cookievalue = cookievalue + ":" + appendvalue;
		else
			cookievalue = appendvalue;
		write_cookie(name, cookievalue, path);
		alert("Item has been added to your cart.");
	}
}

function delete_item(name, itemID) {
	cookievalue = read_cookie(name);
	var cookie_array = cookievalue.split(":");
	var duplicate = false;
	var tmp_string = "";
	for (var i=0; i<cookie_array.length; ++i) {
		if (cookie_array[i] != itemID) {
			if (tmp_string == "") 
				tmp_string = cookie_array[i];
			else
				tmp_string = tmp_string + ":" + cookie_array[i];
		}
	}
	alert("Item has been removed from your cart.");
	write_cookie(name, tmp_string, "");
	window.location.reload(); // reload the current page
}

function write_cookie(name, value, path) {
	// set cookie expiry date
	var expiration_date = new Date();
	expiration_date.setYear(expiration_date.getYear () + 1);
	expiration_date = expiration_date.toGMTString();
	// create cookie string
	var cookie_string = escape(name) + "=" + escape(value) + "; expires=" + expiration_date;
	if (path != null)
		cookie_string += "; path=" + path;
	// set the cookie
	document.cookie = cookie_string;
}

function read_cookie(key, skips) {
	if (skips == null)
		skips = 0;
	// read the cookies and split them into array
	var cookie_string = "" + document.cookie;
	var cookie_array = cookie_string.split ("; ");
	// read the cookie array and get the requested cookie data
	for (var i=0; i<cookie_array.length; ++i) {
		var single_cookie = cookie_array[i].split ("=");
		if (single_cookie.length != 2)
			continue;
		var name  = unescape(single_cookie [0]);
		var value = unescape(single_cookie [1]);
	}
	if (key == name && skips -- == 0) // Return cookie if found
		return value;
	else // return null if requested cookie not found
		return null;
}

function delete_cookie(name, path) {
	// set expiry date
	var expiration_date = new Date();
	expiration_date.setYear (expiration_date.getYear () - 1);
	expiration_date = expiration_date.toGMTString();
	// create cookie string
	var cookie_string = escape (name) + "=; expires=" + expiration_date;
	if (path != null)
		cookie_string += "; path=" + path;
	// Delete cookie
	document.cookie = cookie_string;
}

function delete_all_cookies(path) {
	// read the cookie and split them into array
	var cookie_string = "" + document.cookie;
	var cookie_array = cookie_string.split ("; ");
	// go through the array and delete everyone of them
	for (var i = 0; i < cookie_array.length; ++ i) {
		var single_cookie = cookie_array [i].split ("=");
		if (single_cookie.length != 2)
			continue;
		var name = unescape(single_cookie [0]);
		delete_cookie(name, path);
	}
}

function confirmDelete() {
	var confirmation = confirm("Proceed to clear your cart content?");
	if (confirmation) {
		delete_cookie("cartcontent", "");
		window.location.reload(); // reload the current page
	}
}