// JavaScript Document

function openCCWin(ccElement) {
	var altTag = ccElement.getAttribute('alt');
	var sourcePage = document.URL;
	var sourcePath = ccElement.getAttribute('src');
	var sourceFile = getFileFromUrl(sourcePath);
	
	var form = document.createElement("form");
	form.setAttribute("method", "post");
	form.setAttribute("action", "/creative-commons-image.php");
	form.setAttribute("target", "_blank");
	
	addFormField(form, "altTag", altTag);
	addFormField(form, "sourcePage", sourcePage);
	addFormField(form, "sourceFile", sourceFile);
	document.body.appendChild(form);	
	form.submit();
}

function addFormField (form, name, value) {
	var hiddenField = document.createElement("input");              
	hiddenField.setAttribute("name", name);
	hiddenField.setAttribute("value", value);
	hiddenField.setAttribute("type", "hidden");
	form.appendChild(hiddenField);
}

function getFileFromUrl(url) {
	return url.substring(url.lastIndexOf('/') + 1);
}

var ccImage = null;

function ccHover(me) {
  ccImage=me;
  var text = "License this image: " + getFileFromUrl(ccImage.getAttribute('src')); // + ccImage.getAttribute("src");
  ccImage.setAttribute('title', text);
  ccImage.style.cursor="pointer";
  ccImage.onmouseout=ccReset;
}

function ccReset() {
}

function addbookmark() {
	bookmarkurl="http://www.coliccalm.com"
	bookmarktitle="Colic Calm Gripe Water, Natural Relief of Infant Colic, Gas and Reflux"
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function openFlash() {
	day = new Date();
	flash_id = day.getTime();
	window.open("http://www.coliccalm.com/flash/HowItWorks-Baby9.html", flash_id,
	"toolbar=0, scrollbars=0,location=0,menubar=0,resizable=0,width=660,height=500,left=90,top=65");
}

function OpenBBBWindow() {
		theWindow = window.open("http://www.labbb.org/BBBWeb/Forms/Business/CompanyReportPage_Expository.aspx?CompanyID=100011349", "BBB", "directories=no, menubar=no, scrollbars=yes, status=no, toolbar=no, resizable=yes, width=600, height=400");
		if (window.focus) theWindow.focus();
}

function OpenColicShopWindow() {
		theWindow = window.open("http://www.colicshop.com/colic-calm-gripe-water.shtml", "BBB", "directories=no, menubar=no, scrollbars=yes, status=no, toolbar=yes, resizable=yes, width=600, height=400");
		if (window.focus) theWindow.focus();
}

