﻿function openpopup(productid)
{
    window.open('/print.aspx?id='+productid,"Print","width=500,height=720,scroll=0,status=0");
}
connectionSpeed = 0;
function drawCSImageTag( fileLocation, fileSize, imgTagProperties ) {
	start = (new Date()).getTime();
		
	loc = fileLocation + '?t=' + escape(start);

		var imgLoader=document.getElementById('imgLoader');
	 imgLoader.innerHTML='<img src="' + loc + '" ' + imgTagProperties + ' onload="connectionSpeed=computeConnectionSpeed(' + start + ',' + fileSize + ');">';
	
	return;
}

function computeConnectionSpeed( start, fileSize ) {

   var SType;
   SLOW_MODEM = 15;
	FAST_MODEM = 57;
	ISDN_MODEM = 120;
	end = (new Date()).getTime();
	connectSpeed = (Math.floor((((fileSize * 8) / ((end - start) / 1000)) / 1024) * 10) / 10);
	
	if (connectSpeed) {
		if (connectSpeed < SLOW_MODEM) {
			SType="L";
		} else if (connectSpeed < FAST_MODEM) {
			SType= "L";
		} else if (connectSpeed < ISDN_MODEM) {
			SType= "L";
		} else {
			SType= "H";
		}
	}
	
	createCookie('SP',SType,1);
	
	return connectSpeed;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

drawCSImageTag('/images/beta_solar_node.jpg',32958,'border=2 height=1 alt="bway solar AP"');  