var res = screen.width;

$(document).ready(function(){
	
	$("a[href*='catalogviewer.aspx']").click(function(){
		writeCookie('preferDigitalCatalog',1,365);
		 return true;
	});
	if(res <= 800)
	{
		$(".global").after($("#dogear").css({ position: 'relative', margin: '-30px 0', float: 'left' }));
	}
});

var jaaspeel = new Object();

var pref = ReadCookie('preferDigitalCatalog');
if (pref == 1) {
	jaaspeel.ad_url = 'javascript:OpenCatalogViewer();'
}
else{
	jaaspeel.ad_url = 'http://' + document.location.host + escape('/enhanced_catalog/');
}

jaaspeel.small_path = '/flash/peel/small';
jaaspeel.small_image = escape('/flash/peel/small.jpg');
jaaspeel.small_width = '100';
jaaspeel.small_height = '100';
jaaspeel.small_params = 'ico=' + jaaspeel.small_image;

jaaspeel.big_path = '/flash/peel/large';
jaaspeel.big_image = escape('/flash/peel/large.jpg');
jaaspeel.big_width = '650';
jaaspeel.big_height = '650';
jaaspeel.big_params = 'big=' + jaaspeel.big_image + '&ad_url=' + jaaspeel.ad_url;

function sizeup987(){
	document.getElementById('jcornerBig').style.top = '0px';
	document.getElementById('jcornerSmall').style.top = '-1000px';
}

function sizedown987(){
	document.getElementById("jcornerSmall").style.top = "0px";
	document.getElementById("jcornerBig").style.top = "-1000px";
}
 
function OpenCatalogViewer(){
	var url = 'http://' + document.location.host + escape('/catalogviewer.aspx');
	var fakeLink = document.createElement ("a");
	if (typeof(fakeLink.click) == 'undefined')
		location.href = url;  // sends referrer in FF, not in IE
	else
	{
		fakeLink.href = url;
		document.body.appendChild(fakeLink);
		fakeLink.click();   // click() method defined in IE only
	}
} 

var hasRequestedVersion = DetectFlashVer(7, 0, 0);
if ((hasRequestedVersion)&&(pref == 0)) {
	WriteFlashDogEar();	
}
else {
	WriteStaticDogEar();	
}

function writeCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";path=/;domain=.mouser.com;expires="+exdate.toGMTString());
};
 
function WriteFlashDogEar(){
	document.write('<div id="jcornerSmall" style="position:absolute;width:'+ jaaspeel.small_width +'px;height:'+ jaaspeel.small_height +'px;z-index:9999;right:0px;top:0px;">');
// <jcornerSmall>
// object params 
document.write("<script language='javascript'>");
document.write("if (AC_FL_RunContent == 0) {");
document.write("alert('This page requires AC_RunActiveContent.js.');");
document.write("} else {");
document.write("AC_FL_RunContent(");
document.write("'codebase', '" +document.location.protocol+"//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',");
document.write("'width','" + jaaspeel.small_width + "',");
document.write("'height','" + jaaspeel.small_height + "',");
document.write("'src','" + jaaspeel.small_path + "',");
document.write("'FlashVars','" + jaaspeel.small_params + "',");
document.write("'quality', 'high',");
document.write("'pluginspage', '" +document.location.protocol+"//www.macromedia.com/go/getflashplayer',");
document.write("'align', 'middle',");
document.write("'play', 'true',");
document.write("'wmode', 'transparent',");
document.write("'devicefont', 'false',");
document.write("'id', 'jcornerSmallObject',");
document.write("'name', 'small',");
document.write("'menu', 'true',");
document.write("'allowFullScreen', 'false',");
document.write("'allowScriptAccess','always'");;
document.write(");");
document.write("}");
document.write("</script>");

document.write('</div>');
document.write('</script>');
// </jcornerSmall>
// <jcornerBig>
document.write('<div id="jcornerBig" style="position:absolute;width:'+ jaaspeel.big_width +'px;height:'+ jaaspeel.big_height +'px;z-index:9999;right:0px;top:0px;">');
// object
document.write("<script language='javascript'>");
document.write("if (AC_FL_RunContent == 0) {");
document.write("alert('This page requires AC_RunActiveContent.js.');");
document.write("} else {");
document.write("AC_FL_RunContent(");
document.write("'codebase', '" +document.location.protocol+"//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',");
document.write("'width','" + jaaspeel.big_width + "',");
document.write("'height','" + jaaspeel.big_height + "',");
document.write("'src','" + jaaspeel.big_path + "',");
document.write("'FlashVars','" + jaaspeel.big_params + "',");
document.write("'quality', 'high',");
document.write("'pluginspage', '" +document.location.protocol+"//www.macromedia.com/go/getflashplayer',");
document.write("'align', 'middle',");
document.write("'play', 'true',");
document.write("'wmode', 'transparent',");
document.write("'devicefont', 'false',");
document.write("'id', 'jcornerLargeObject',");
document.write("'name', 'large',");
document.write("'menu', 'true',");
document.write("'allowFullScreen', 'false',");
document.write("'allowScriptAccess','always'");;
document.write(");");
document.write("}");
document.write("</script>");
document.write('</div>');
// </jcornerBig>
setTimeout('document.getElementById("jcornerBig").style.top = "-1000px";',1000);
}

function WriteStaticDogEar(){
document.write("<style type='text/css'>");
document.write("#dogear {display:block;}");
document.write("</style>");
}

 