<!--
// Copyright (c) 2006-09 Easy2.com, Inc. All rights reserved.

// Populate the variable below with the text or image that will launch a product demo.
var easy2LinkDisplay = '';

// The "document.write" code below can be changed to a <div>, <p> or <td> if needed, BUT MAKE SURE THE ID IS NOT CHANGED.
document.write('<span id=\"easy2Container_linen_demos\" style=\"display: none;\"></span>');

// *********************************************************************************************************************
// ***************************************Do not change the code below this line.***************************************
// *********************************************************************************************************************

function easy2CheckModules(easy2IncludeID) {	
	var containerObj = document.getElementById('easy2Container_' + easy2IncludeID);
		
	if(containerObj && easy2IncludeID.indexOf('_') != -1) {

		var this_url = easy2CurrentURL();		
		var scrObj = document.getElementById('easy2Script_' + easy2IncludeID);

		if(getLocale(scrObj).indexOf('locale=en_CA') != -1) {
			easy2IncludeID = "linc_307";
			containerObj.setAttribute('id','easy2Container_linc_307');
			scrObj.setAttribute('id','easy2Script_linc_307');
			easy2LinkDisplay = '<img src=\"http://includes.easy2.com/dm/images/linc_viewDemo.gif\" border=\"0\">';
		} else {
			easy2IncludeID = "linc_308";
			containerObj.setAttribute('id','easy2Container_linc_308');
			scrObj.setAttribute('id','easy2Script_linc_308');	
			easy2LinkDisplay = '<img src=\"http://includes.easy2.com/dm/images/linc_viewDemo_fr.gif\" border=\"0\">';	
		}	

		var qs_1 = '', qs_2 = '', path_1 = '', path_2 = '', other_1 = 'product_demo_id', other_2 = '';
		var check_url = 'http://media.easy2.com/dyna_includes2/actions/check_image.asp';
		var launch_url = 'http://webapps.easy2.com/dyna_includes2/actions/master_page.asp';

		var imgObj = document.createElement('img');
							
		var temp_url = (path_1 != '' || path_2 != '') ? easy2PathVal(this_url, true) : easy2PathVal(this_url, false);
		temp_url += (qs_1 != '') ? '?' + qs_1 + '=' + easy2ParamVal(this_url, qs_1) : '';
		temp_url += (qs_2 != '') ? '&' + qs_2 + '=' + easy2ParamVal(this_url, qs_2) : '';

		var e2_vars = '?e2__dyna_include_pid=' + easy2IncludeID.split('_')[1];
		e2_vars += '&e2__dyna_include_host=' + easy2IncludeID.split('_')[0];
		e2_vars += '&e2__dyna_include_url=' + escape(temp_url);
		
		if(scrObj && scrObj.src && scrObj.src != '') {
			var arrURL = scrObj.src.split('?');  
			if(arrURL.length > 1) e2_vars += '&' + arrURL[1];
		}
		
		e2_vars += '&e2__dyna_include_cache=true';
		
		imgObj.onload = function() {
			launch_url += e2_vars;
			var this_link = '<a href=\"#\" onclick=\"easy2PopOpenWin(\'' + launch_url + '\', \'easy2Window\', 600, 450); return false;\">';
			this_link += easy2LinkDisplay;
			this_link += '</a>';
			containerObj.innerHTML = this_link;
			containerObj.style.display = '';
			imgObj = null;
		}
		
		imgObj.onerror = function() {
			imgObj = null;
		}
		
		check_url += e2_vars;
		imgObj.src = check_url;
	}	
}

function easy2PopOpenWin(theURL, Name, popW, popH) {
	theURL += (theURL.indexOf('?') > -1) ? '&' : '?';
	theURL += 'referurl=' + easy2CurrentURL();
	var winHorz = (screen.width-popW)/2;
	var winVert = (screen.height-popH)/2;
	var winProp = 'width=' + popW + ',height=' + popH + ',left=' + winHorz + ',top=' + winVert + ',scrollbars=yes,resizable=yes';
	easy2PopWin = window.open(theURL, Name, winProp);
	if (easy2PopWin && !easy2PopWin.closed && easy2PopWin.top && window.focus) {easy2PopWin.focus()};
	return false;
}

function easy2CurrentURL() {
	var thisURL = window.location.href.toString();
	var arrURL = thisURL.split('?');
	var thisURL = unescape(arrURL[0]);
	if(arrURL.length > 1) thisURL += '?' + arrURL[1];
	return thisURL;
}	

function easy2ParamVal(url, var_name) {
	var pat = '(?:&|\\b|\\?)' + var_name + '=([^&#]*)';
	var re = new RegExp(pat,'i');
	var arr = url.match(re);
	var val = (arr) ? arr[1] : '';
	return val;
}

function easy2PathVal(url, path) {
	var val = '';
	var pat = '^([^:]+[:/]+[^/]+)([^?#]*)';
	var re = new RegExp(pat,'i');
	var arr = url.match(re);
	if(arr) {
		val = arr[1];
		val += (path) ? arr[2] : '';
	}
	return val;
}

function getLocale(this_script) {
	  if(this_script && this_script.src && this_script.src != '') {
	  		var arrURL = this_script.src.split('?'); 
	  		var CaLocal = arrURL[1].split('&');
  			return(CaLocal[1]);
  	} else {
  		  return("locale=en_CA");
  	}
}


easy2CheckModules('linen_demos');

//-->
