//*************************************************************************************************

// submitEmail()

// Verifies that a customer has entered a valid email address

//*************************************************************************************************

function submitEmail(){

	var emailValue = email.emailVal.value;

	var emailValueLength = email.emailVal.value.length;

	var emailValueAfterSign = (emailValue.substring(emailValue.indexOf('@')));

	

	if((emailValue.length < 1) || (emailValue == "Please provide your email address.")){

		alert("Please provide your email address.");

		email.emailVal.focus();

	}

	

  else if((emailValue.indexOf('@') == -1)||(emailValue.indexOf('@') == 0)||(emailValue.indexOf('@') == emailValueLength - 1)){

  	alert("Please provide a valid email address.");

		email.emailVal.focus();

	}

	

	else if((emailValue.indexOf('.') == -1)||(emailValue.indexOf('.') == 0)||(emailValue.indexOf('.') == emailValueLength - 1)){

  	alert("Please provide a valid email address.");

		email.emailVal.focus();

	}

	

	else if((emailValueAfterSign.indexOf('.') == -1)||(emailValueAfterSign.indexOf('.') == 0)||(emailValueAfterSign.indexOf('.') == emailValueLength - 1)){

  	alert("Please provide a valid email address.");

		email.emailVal.focus();

	}

	else{

		window.open('http://site.summitonline.com/php_doc/email_list/index.php?emailVal='+emailValue,'emailSubmit','toolbar=no,resizable=no,scrollable=no,height=200,width=360');

	}

}





//*************************************************************************************************

// emailSubmitCheck()

// Submits the email request if the cutomer uses the enter key versus clicking the button

//*************************************************************************************************

function emailSubmitCheck(){

	if((document.all.email.emailVal.focus)&&(event.keyCode==13)){

		submitEmail();

	}

}





//*************************************************************************************************

// openPopUp()

// Opens pages into a new Window

//*************************************************************************************************

function openPopUp(linkURL,windowName,windowHeight,windowWidth){

	top.window.open(linkURL,windowName,'location=no,status=no,scrollbars=yes,height=' + windowHeight + ',width=' + windowWidth + '');

}





//*************************************************************************************************

// showAdOns()

// Opens the Add On Viewer module

//*************************************************************************************************

function showAdOns(url){

	top.window.open(url,'adOns','toolbar=no,scrollbars=yes,resizable=no,height=400,width=600');

}





//*************************************************************************************************

// rollOver()

// Controls an images rollover

//*************************************************************************************************

function rollOver(imgID,imgName){

	this.imgID = eval("document.images." + imgID);

	this.imgID.src = "http://site.summitonline.com/images/" + imgName + ".gif";

}





//*************************************************************************************************

// searchSubmit()

// Controls the submission of a search query

//*************************************************************************************************

function searchSubmit(){

	document.f.query.value = document.all.query_orig.value;

	document.f.submit();

}





//*************************************************************************************************

// enterSubmit()

// Submits the search form to the searchSubmit() function when a customer hits the enter key

//*************************************************************************************************

function enterSubmit(){

	if((document.all.query_orig.focus)&&(event.keyCode==13)){

		searchSubmit();

	}

}





//*************************************************************************************************

// MM_jumpMenu()

// resets drop-down boxes for shop by brand and shop by size

//*************************************************************************************************

function MM_jumpMenu(targ,selObj,restore){

	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

	if(restore){

  	selObj.selectedIndex=0;

  }

}





//*************************************************************************************************

// viewFotos()

// displays the large images on the website

//*************************************************************************************************

function viewFotos(img, name){

	var features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=560,height=580";

	dlg = window.open ("","Details",features);

	dlg.document.write("<html><head><title>" + name + " Zoom</title></head>");

	dlg.document.write("<body bgcolor=white><center>");

	dlg.document.write("<table border=0 cellpadding=3 cellspacing=0 width=100%>");

	dlg.document.write("<tr><td align=center><b><font size=2 face=Arial color=#0066CC>" +  name + "</font></b></td></tr>");

	dlg.document.write("<tr><td align=center><img src=" + img + "></td></tr>");

	dlg.document.write("<tr><td align=center><font size=1 face=Arial>Click <a href=# onClick=window.close(); style='color:#0066CC'>here</a> to close window</a></font></td></tr>");

	dlg.document.write("</table>");

	dlg.document.write("</body></html>");

}





//*************************************************************************************************

// CaricaFoto()

// collects parameters for ViewFotos() which displays the large photos on the website

//*************************************************************************************************

function CaricaFoto(img,name){

  foto1= new Image();

  foto1.src=(img);

  viewFotos(img,name);

}





//*************************************************************************************************

// openWin()

// Opens pages into a new Window

//*************************************************************************************************

function openWin(url){

	window.top.open(url,'newWin','toolbar=no,resizable=no,width=500,height=380');

}





//*************************************************************************************************

// writeReview()

// Opens window to write a review

//*************************************************************************************************

function writeReview(url){

	window.top.open(url,'writeReview','toolbar=no,resizable=no,scrollbars=no,width=500,height=450');

}





//*************************************************************************************************

// readReview()

// Opens window to read a review

//*************************************************************************************************

function readReview(url){

	window.top.open(url,'readReview','toolbar=no,resizable=no,scrollbars=yes,width=800,height=600');

}





//*************************************************************************************************

// tellAFriend()

// Opens the tell a friend module

//*************************************************************************************************

function tellAFriend(){

	var currentURL = new String(location);

	var imgURL = currentURL.substring(currentURL.indexOf('com/') + 4);

  imgURL = imgURL.substring(0,imgURL.indexOf('.')) + ".jpg";

	var appURL = "http://site.summitonline.com/php_doc/tell_a_friend/index.php?page=" + currentURL + "&img=" + imgURL;

	window.top.open(appURL,'newWin','toolbar=no,resizable=no,width=500,height=416');

}





//*************************************************************************************************

// showTimeLeft()

// function to countdown time to xmas guarantee

//*************************************************************************************************

function showTimeLeft(){

			

	var endDate = new Date(2004, 11, 21, 12, 0, 0);

	var startDate = new Date();

	

	var endDate_milliseconds = endDate.getTime();

	var startDate_milliseconds = startDate.getTime();

	

	var difference = endDate_milliseconds - startDate_milliseconds;

	

	var daysDifference = Math.floor(difference/1000/60/60/24);

	var daysDifference_hours = Math.floor(daysDifference * 24);

	difference = difference - daysDifference*1000*60*60*24;

	

	var hoursDifference = Math.floor(difference/1000/60/60);

	var hoursDifferenceDisplay = Math.floor(difference/1000/60/60) + daysDifference_hours;

	if(hoursDifferenceDisplay < 10){

		hoursDifferenceDisplay = "0" + hoursDifferenceDisplay;

	}

	difference = difference - hoursDifference*1000*60*60

	

	var minutesDifference = Math.floor(difference/1000/60);

	var minutesDifferenceDisplay = Math.floor(difference/1000/60);

	if(minutesDifferenceDisplay < 10){

		minutesDifferenceDisplay = "0" + minutesDifferenceDisplay;

	}

	difference = difference - minutesDifference*1000*60

	

	var secondsDifference = Math.floor(difference/1000);

	var secondsDifferenceDisplay = Math.floor(difference/1000);

	if(secondsDifferenceDisplay < 10){

		secondsDifferenceDisplay = "0" + secondsDifferenceDisplay;

	}

	

	var display = "";

	display = hoursDifferenceDisplay + ":" + minutesDifferenceDisplay + ":" + secondsDifferenceDisplay;

	return display;

}





//*************************************************************************************************

// sizeSubmit()

// function to submit shop by size pages

//*************************************************************************************************

function sizeSubmit()

{

	var chosenValue = document.all.chooseSize.value;

	document.shopBySize.size.value = chosenValue;

	document.shopBySize.submit();

}





//*************************************************************************************************

// imageSwitch()

// function to control rollovers

//*************************************************************************************************

function imageSwitch(imgName, imgSrc)

{

	theImg = document.getElementById(imgName);

	theImg.src = imgSrc;

}






//*************************************************************************************************

// countdown

// countdown for guaranteed xmas shipping

//*************************************************************************************************

function CD_T(id, e) {
	var n = new Date();
	CD_D(+n, id, e);
	setTimeout("if(typeof CD_T=='function'){CD_T('" + id + "'," + e + ")}", 1100-n.getMilliseconds()); // offset from 1100 so that our clock ticks every second (the millisecond correction each loop sees to that), but updates 0.1s after every whole second so that we don't accidentally read the same Date() twice in the same second
};

// Calculate time and update display (dateNow, countdownId, eventDate)
function CD_D(n, id, e) {
	var ms = e - n;
	if (ms <= 0) ms *= -1;
	var d = Math.floor(ms/864E5);
	ms -= d*864E5;
	var h = Math.floor(ms/36E5);
	ms -= h*36E5;
	var m = Math.floor(ms/6E4);
	ms -= m*6E4;
	var s = Math.floor(ms/1E3);

	// If you want to manually customise the counter display, then edit this line:
	if (CD_OBJS[id]) {
		CD_OBJS[id].innerHTML = d + " day" + (d == 1 ? " " : "s ") + CD_ZP(h) + "h " + CD_ZP(m) + "m ";
		CD_OBJS[id].style.display = "block";
	}
};

// Prefix single integers with a zero
function CD_ZP(i) {
	return (i<10 ? "0" + i : i);
};

// Initialisation
function CD_Init() {
	var pref = "countdown";
	var objH = 1; // temp boolean true value
	if (document.getElementById || document.all) {
		for (var i=1; objH; ++i) {
			var id	= pref + i;
			objH	= document.getElementById ? document.getElementById(id) : document.all[id];

			if (objH && (typeof objH.innerHTML) != 'undefined') {
				var s	= objH.innerHTML;
				var dt	= CD_Parse(s);
				if (!isNaN(dt)) {
					CD_OBJS[id] = objH; // Store global reference to countdown element object
					CD_T(id, dt.valueOf());
					if (objH.style) {
						objH.style.visibility = "visible";
					}
				}
				else {
					objH.innerHTML = s + "";
				}
			}
		}
	}
};

// Get Date() object from 2006-01-01 00:00:00 GMT+00:00 date format
function CD_Parse(strDate) {
	// Pattern match to a countdown date
	var objReDte = /(\d{4})\-(\d{1,2})\-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{0,2})\s+GMT([+\-])(\d{1,2}):?(\d{1,2})?/;

	if (strDate.match(objReDte)) {
		// Start with a default date and build it up into the countdown date through Date setter methods
		var d = new Date(0);

		d.setUTCFullYear(+RegExp.$1,+RegExp.$2-1,+RegExp.$3); // Set YYYY-MM-DD directly as UTC
		d.setUTCHours(+RegExp.$4,+RegExp.$5,+RegExp.$6); // Set HH:MM:SS directly as UTC

		// If there is a timezone offset specified then we need to compensate for the offset from UTC
		var tzs	= (RegExp.$7 == "-" ? -1 : 1); // Timezone sign
		var tzh = +RegExp.$8; // Get requested timezone offset HH (offset ahead of UTC - may be negative)
		var tzm = +RegExp.$9; // Get requested timezone offset MM (offset ahead of UTC - always positive)
		if (tzh) {
			d.setUTCHours(d.getUTCHours() - tzh*tzs); // Compensate for timezone HH offset from UTC
		}
		if (tzm) {
			d.setUTCMinutes(d.getUTCMinutes() - tzm*tzs); // Compensate for timezone MM offset, depending on whether the requested MM offset is ahead or behind of UTC
		}
		return d; // Date now correctly parsed into a Date object correctly offset from UTC internally regardless of users current timezone.
	}
	else {
		return NaN; // Didn't match required date format
	};
};

var CD_OBJS = new Object();

// Try not to commandeer the default onload handler if possible
if (window.attachEvent) {
	window.attachEvent('onload', CD_Init);
}
else if (window.addEventListener) {
	window.addEventListener("load", CD_Init, false);
}
else {
	window.onload = CD_Init;
}

