/*
The following functions randomly select a homepage feature item from among the array of defined features.
Flash or a static image is displayed, depending on the version of the user's Flash player.
*/

var homepageFeatures = [];

homepageFeatures.push({
	swf: "/flash/home/dura.swf", 
	flashvars: {url1: "/duramax-phone", url2: "/duracore-phone"}, 
	parameters: {bgcolor: "#ffffff"}, 
	attributes: {id: "homeFlash"}, 
	nonFlashImage: "/flash/home/dura.jpg", 
	nonFlashURL: "/phones",
	nonFlashURLTarget: "_self",
	width: "610"
});

function writeHomepageFeature(index) {
	var width = (homepageFeatures[index].width) ? homepageFeatures[index].width : "590";
	swfobject.embedSWF(homepageFeatures[index].swf, "homeFlash", width, "360", "8.0.0", false, homepageFeatures[index].flashvars, homepageFeatures[index].parameters, homepageFeatures[index].attributes, writeHomepageFeatureCallback);
}

function writeHomepageFeatureCallback(e) {
	if (!e.success) {
		if (homepageFeatures[homepageFeatureIndex].width)
			document.getElementById("homeFlashNonFlashImage").width = homepageFeatures[homepageFeatureIndex].width;
		document.getElementById("homeFlashNonFlashImage").src = homepageFeatures[homepageFeatureIndex].nonFlashImage;
		if (homepageFeatures[homepageFeatureIndex].nonFlashURL)
			document.getElementById("homeFlashNonFlashLink").href = homepageFeatures[homepageFeatureIndex].nonFlashURL;
		if (homepageFeatures[homepageFeatureIndex].nonFlashURLTarget) 
			document.getElementById("homeFlashNonFlashLink").target = homepageFeatures[homepageFeatureIndex].nonFlashURLTarget;
	}
}

var homepageFeatureIndex = getRandomNumber(homepageFeatures.length);
writeHomepageFeature(homepageFeatureIndex);

/*
The following script defines the various promotional code blocks
that will be randomly displayed on this page.
*/

var left = [];
var middle = [];
var right = [];

/* DuraCore */
left.push(
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:5px; top:0px;"><a href="/duracore-phone"><img src="/image/home/promo_hd_duracore.gif" alt="Kyocera DuraCore" width="132" height="14" border="0"/></a></div>' +
	'<div style="position:absolute; left:5px; top:20px;"><a href="/duracore-phone"><img src="/image/home/promo_img_duracore.jpg" alt="" width="46" height="90" border="0"/></a></div>' +
	'<div style="position:absolute; left:63px; top:25px; width:100px;" class="homePromo"><a href="/duracore-phone">Essential in the elements.</a></div>' +
	'</div>'
);

/* C5121 */
left.push(
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:5px; top:0px;"><a href="/c5121-phone"><img src="/image/home/promo_hd_c5121.gif" alt="Milano C5121" width="104" height="12" border="0"/></a></div>' +
	'<div style="position:absolute; left:5px; top:20px;"><a href="/c5121-phone"><img src="/image/home/promo_img_c5121.jpg" alt="" width="46" height="86" border="0"/></a></div>' +
	'<div style="position:absolute; left:63px; top:25px; width:100px;" class="homePromo"><a href="/c5121-phone">Plays well with others.</a></div>' +
	'</div>'
);

/* DuraMax */
left.push(
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:5px; top:0px;"><a href="/duramax-phone"><img src="/image/home/promo_hd_duramax.gif" alt="Kyocera DuraMax" width="129" height="14" border="0"/></a></div>' +
	'<div style="position:absolute; left:5px; top:20px;"><a href="/duramax-phone"><img src="/image/home/promo_img_duramax.jpg" alt="" width="46" height="90" border="0"/></a></div>' +
	'<div style="position:absolute; left:63px; top:25px; width:100px;" class="homePromo"><a href="/duramax-phone">Essential in the elements.</a></div>' +
	'</div>'
);

/* C5120 */
left.push(
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:5px; top:0px;"><a href="/c5120-phone"><img src="/image/home/promo_hd_c5120.gif" alt="Milano C5120" width="107" height="12" border="0"/></a></div>' +
	'<div style="position:absolute; left:5px; top:20px;"><a href="/c5120-phone"><img src="/image/home/promo_img_c5120.jpg" alt="" width="46" height="86" border="0"/></a></div>' +
	'<div style="position:absolute; left:63px; top:25px; width:100px;" class="homePromo"><a href="/c5120-phone">Plays well with others.</a></div>' +
	'</div>'
);

/* Echo Dual Screen Apps (6 Jul 11) */
middle[ middle.length ] = '' +
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:0px; top:0px;"><a href="http://www.echobykyocera.com/top-apps/detail.cfm?a=255" target="_blank"><img src="/image/home/promo_hd_echo-dual-screen-apps.gif" alt="Echo Dual Screen Apps" width="168" height="14" border="0"/></a></div>' +
	'<div style="position:absolute; left:0px; top:22px;"><a href="http://www.echobykyocera.com/top-apps/detail.cfm?a=255" target="_blank"><img src="/image/home/promo_img_echo-dual-screen-apps.gif" alt="" width="58" height="58" border="0"/></a></div>' +
	'<div style="position:absolute; left:65px; top:20px; width:120px;" class="homePromo"><a href="http://www.echobykyocera.com/top-apps/detail.cfm?a=255" target="_blank">The ever popular Sonic the Hedgehog game from Sega only $4.99!</a></div>' +
	'</div>';

/* KR2 Mobile Router (2 Mar 08) */
/*
middle[ middle.length ] = '' +
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:27px; top:0px;"><a href="/kr2-router"><img src="/image/home/promo_hd_kr2-mobile-router.gif" alt="KR2 Mobile Router" width="136" height="12" border="0"/></a></div>' +
	'<div style="position:absolute; left:20px; top:22px;"><a href="/kr2-router"><img src="/image/home/promo_img_kr2-mobile-router.gif" alt="" width="87" height="75" border="0"/></a></div>' +
	'<div style="position:absolute; left:110px; top:30px; width:100px;" class="homePromo"><a href="/kr2-router">Wireless Broadband Anywhere.</a></div>' +
	'</div>';
*/

/* online support */
right[ right.length ] = '' +
	'<div style="position:absolute;">' +
	'<div style="position:absolute; left:8px; top:0px;"><a href="/support"><img src="/image/home/promo_img_support.gif" alt="" width="161" height="54" border="0"/></a></div>' +
	'<div style="position:absolute; left:0px; top:54px;"><a href="/support"><img src="/image/home/promo_hd_support.gif" alt="online support" width="109" height="15" border="0"/></a></div>' +
	'<div style="position:absolute; left:23px; top:80px; width:145px;" class="homePromo"><a href="/support">We\'re here if you need us, but you probably won\'t.</a></div>' +
	'</div>';
	

writeblock = function(array) {
	if( !array.length ) return;
	document.write(array[getRandomNumber(array.length)]);
}

