/*	Mouseover Preview Images Script */
// Set the document up to keep track of the mouse position
var cX = 0; var cY = 0;
function UpdateCursorPosition(e){cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){	cX = event.clientX + document.body.scrollLeft;cY = event.clientY + document.body.scrollTop;}
if(document.all) {document.onmousemove = UpdateCursorPositionDocAll;}else {document.onmousemove = UpdateCursorPosition; }
function truebody(){return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}

var cursorInDiv=false; var cursorInImg=false;
var previewHtmlBegin = "<table cellSpacing=\"0\" cellpadding=\"0\" runat=\"server\" width=\"250\"><TR><td align=\"center\"><table bgColor=\"#ffffff\" class=\"TableBorder\" width=\"100%\" cellpadding=\"0\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">"
var previewHtmlCrossStitch = "<tr class=\"CustomTableColor\" style=\"padding:5px 5px 0 5px;\" align=\"center\"><td class=\"defaultText12\">This is a <strong>CROSS-STITCH</strong> pattern.</td></tr>"
var previewHtmlSoftware = "<tr class=\"CustomTableColor\" style=\"padding:5px 5px 0 5px;\"><td class=\"defaultText12\">"

var previewHtmlImg1 = "<tr><td align=\"center\" style=\"padding:5px;\">"
var previewHtmlImg2 = "</td></tr><tr class=\"CustomTableColor\" style=\"padding:0 5px 5px 5px;\"><td valign=\"top\" align=\"center\" class=\"defaultText12\"><strong>Design Courtesy : </strong>"
var previewDivEFP = "<div class=\"CustomTableColor\" style=\"padding:5px 5px 0 5px;\" align=\"center\"><font class='defaultText12'>This is a <strong>keyboard font</strong> - requires <strong>Embroidery Fonts Plus</strong> software.</font></div>"
var previewDivFont = "<div class=\"CustomTableColor\" style=\"padding:5px 5px 0 5px;\" align=\"center\"><font class='defaultText12'>This is an <strong>alphabet</strong>. Each letter, number, or symbol is an <strong>individual stitch file</strong>.</font></div>"
var previewHtmlImg3 = "<br><a class=\"defaultText10\" href=\"linkgoeshere\">Download Zip file</a>"
var previewHtmlEnd = "</td></tr></table></td></tr></table></td></tr></table>"

function AssignPosition(d,e,prd) {
var xcoord=0;
var ycoord=0;
var defaultimageheight=290;
var defaultimagewidth=265;
if (prd != null) {if (prd.toLowerCase() == "font") defaultimageheight=320;}

var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

if (typeof window.event != "undefined"){
	if (docwidth - event.clientX < defaultimagewidth ){xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
	} 
	else {xcoord += truebody().scrollLeft+event.clientX}
	if (docheight - event.clientY < (defaultimageheight)){ycoord += event.clientY + truebody().scrollTop - Math.max(0,(defaultimageheight + event.clientY - docheight));} 
	else {ycoord += truebody().scrollTop + event.clientY;}
} 
else {
	if (docwidth - cX < defaultimagewidth ){xcoord = cX - xcoord - defaultimagewidth; // Move to the left side of the cursor
	} else {xcoord += cX;}
	if (docheight - cY < defaultimageheight){ycoord += cY - Math.max(0,(defaultimageheight + cY - docheight - truebody().scrollTop));} 
	else {ycoord += cY;}
}
d.style.left = xcoord+"px";
d.style.top = ycoord+"px";
}
function toggleDiv(obj,ancHref,imgSrc,isCrossStitch,isEFP,vendor,prdType,name,desc){
	var obj1 = MM_findObj(obj);var anc1 = MM_findObj(ancHref);
	var buildTag="";
	if (isCrossStitch == null){isCrossStitch="false";}if (isEFP == null){isEFP="false";}
	if (vendor == null) {vendor="Other";}if (prdType == null) {prdType = "design";}
	if (desc == null) {desc="none";}

	if (anc1 != null && imgSrc != null && obj1.innerHTML == "")
	{	
		buildTag = previewHtmlBegin; 
		if (isCrossStitch.toLowerCase() =="true"){buildTag = buildTag + previewHtmlCrossStitch;}
		if (desc!="none"){buildTag = buildTag + previewHtmlSoftware + desc + "</td></tr>";}
		
		if (prdType.toLowerCase() == "font" && isEFP.toLowerCase()== "true") {buildTag = buildTag + previewDivEFP}
		else if (prdType.toLowerCase() == "font" && isEFP.toLowerCase()  == "false") {buildTag = buildTag + previewDivFont}
		var ancImg = "<a href=\"" + anc1 + "\">"; 
		ancImg = ancImg + "<img src=\"" + imgSrc + "\" title=\"" + name 
		if (prdType.toLowerCase()=="font"){ancImg = ancImg + " embroidery font" } else {ancImg = ancImg + " embroidery design" }
		ancImg = ancImg + "\" border=\"0\" onmousedown=\"return false;\" oncontextmenu=\"alert(\'Images are copyright-protected!\');return false;\" onselectstart=\"return false;\"></a>";
		
		buildTag = buildTag + previewHtmlImg1 + ancImg + previewHtmlImg2 + vendor + previewHtmlImg3.replace("linkgoeshere",anc1) + previewHtmlEnd;
		obj1.innerHTML = buildTag;
	}
	if(cursorInImg) {AssignPosition(obj1);obj1.style.visibility ='visible';}
	if(cursorInDiv&&obj1.style.visibility !='visible') {obj1.style.visibility ='visible';}
}

function closeDiv(obj)
{
	if(!cursorInDiv && !cursorInImg)
	{
		var obj1 = MM_findObj(obj);
		obj1.style.visibility ='hidden';	
		cursorInDiv=false;
		cursorInImg=false;
	}
}
function showDiv(obj1, obj2){
	var obj1 = MM_findObj(obj1);
	AssignPosition(obj1);
	var obj2 = MM_findObj(obj2);
	if(obj1.style.visibility == "hidden")
	{obj1.style.visibility = "visible";
	obj1.innerHTML = obj2.innerHTML;
	}
}
function CheckFreeDesignsFlash(){
var requiredMajorVersion = 6;
var requiredMinorVersion = 0;
var requiredRevision = 0;
flashrow = MM_findObj('divFlash');
adrow = MM_findObj('divAdR');
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
flashrow.innerHTML = "";
if (hasRequestedVersion){
	flashrow.style.display="block";
	adrow.style.display="none";
	flashrow.innerHTML = AC_FL_RunContent(
									"src", "images/designs_images/freeads?dv=1234",
									"width", "300",
									"height", "165",
									"id", "edAds",
									"quality", "high",
									"bgcolor", "#FFFFFF",
									"base",".",
									"name", "detectionExample",
									"allowScriptAccess","sameDomain",
									"type", "application/x-shockwave-flash",
									'codebase', 'https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
									"pluginspage", "http://www.adobe.com/go/getflashplayer"
						);
	}
else {flashrow.style.display="none";adrow.style.display="block";}
}
function CheckFlash(){
var requiredMajorVersion = 6;
var requiredMinorVersion = 0;
var requiredRevision = 0;
flashrow = MM_findObj('divFlash');
adrow = MM_findObj('divAdR');
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
flashrow.innerHTML = "";
if (hasRequestedVersion){
	flashrow.style.display="block";
	adrow.style.display="none";
	flashrow.innerHTML = AC_FL_RunContent(
									"src", "images/slideshow1?dv=1234",
									"width", "400",
									"height", "220",
									"id", "edAds",
									"quality", "high",
									"bgcolor", "#FFFFFF",
									"base",".",
									"name", "detectionExample",
									"allowScriptAccess","sameDomain",
									"type", "application/x-shockwave-flash",
									'codebase', 'https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
									"pluginspage", "http://www.adobe.com/go/getflashplayer"
						);
	}
else {flashrow.style.display="none";adrow.style.display="block";}
}
function ClickButton(e, LinkToClick) { 
var i = 0; 
while (i < document.forms(0).elements.length) { 
if (document.forms(0).elements(i).name.indexOf(LinkToClick) > -1) 
{ document.forms(0).elements(i).click(); return (true); } 
	i++; } 
i=0; 
while (i < document.links.length) 
{ if (document.links.item(i).id.toString().indexOf(LinkToClick) > -1) { 
document.links.item(i).click(); return (true); } 
i++; } return (false); } 
function newin(theURL,winName,features) {var x = window.open(theURL,winName,features);x.focus();}
function newPopUp(theURL, winsize) { 
  winName = null;
  var features;
	if (winsize != null)
		features = winsize + ", resizable = no, scrollbars=yes, left=10, top=10";
	else
		features = "width=500,height=500, resizable = no, scrollbars=yes, left=10, top=10";
  var x = window.open(theURL,winName,features);
  x.focus();}
function LinkPopUpToOriginalWindow(theURL) {
	if (opener && !opener.closed){opener.location.href=theURL;}
	else {opener = window.open(theURL, 'main');}
	return false;}
function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}
function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;}
function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}
function MM_jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;}

//This function checks the current page to see if the page name matches one of the Links in the 
//Tab and highlights the current page on the Tab
function checkTopLink(){	
var cnt = document.anchors.length;
for (i=0; i< cnt; i++)
{	var st = document.anchors[i].href.toUpperCase();
	var dt = document.URL.toUpperCase(); 
	if (st==dt && document.anchors[i].className=="LinkText")
		{document.anchors[i].className = "LinkHighlight";}
	else
	{ if(document.anchors[i].className == "LinkHighlight")
		document.anchors[i].className = "LinkText";
	}}
var leftnavitemvalue = ReadCookie("Cookie_LeftNavItem");
if(leftnavitemvalue=="")
	showNav('eddiv');
else
	showNav(leftnavitemvalue);}

// This function handles Hiding and Displaying Left Navigation Items
function showNav(ctrlID){
var edctrl = MM_findObj('edDIV');var epctrl = MM_findObj('epDIV');var cdctrl = MM_findObj('cdDIV');var efctrl = MM_findObj('efDIV');
var gcctrl = MM_findObj('gcDIV');var wnctrl = MM_findObj('wnDIV');var etctrl = MM_findObj('etDIV');var esctrl = MM_findObj('esDIV');
var fbctrl = MM_findObj('fbDIV');var edcctrl = MM_findObj('edcDIV');
if (edctrl != null) {edctrl.style.display="none";}
if (epctrl != null) {epctrl.style.display="none";}
if (cdctrl != null) {cdctrl.style.display="none";}
if (efctrl != null) {efctrl.style.display="none";}
if (gcctrl != null) {gcctrl.style.display="none";}
if (wnctrl != null) {wnctrl.style.display="none";}
if (etctrl != null) {etctrl.style.display="none";}
if (esctrl != null) {esctrl.style.display="none";}
if (fbctrl != null) {fbctrl.style.display="none";}
if (edcctrl != null) {edcctrl.style.display="none";}
switch (ctrlID.toLowerCase()){
	case "eddiv": if (edctrl != null) {edctrl.style.display="block";SetCookie("Cookie_LeftNavItem","eddiv",24); }break;
	case "epdiv": if (epctrl != null) {epctrl.style.display="block";SetCookie("Cookie_LeftNavItem","epdiv",24); }break;
	case "cddiv": if (cdctrl != null) {cdctrl.style.display="block";SetCookie("Cookie_LeftNavItem","cddiv",24); }break;
	case "efdiv": if (efctrl != null) {efctrl.style.display="block";SetCookie("Cookie_LeftNavItem","efdiv",24); }break;
	case "wndiv":if (wnctrl != null) { wnctrl.style.display="block";SetCookie("Cookie_LeftNavItem","wndiv",24); }break;
	case "gcdiv": if (gcctrl != null) {gcctrl.style.display="block";SetCookie("Cookie_LeftNavItem","gcdiv",24); }break;
	case "etdiv": if (etctrl != null) {etctrl.style.display="block";SetCookie("Cookie_LeftNavItem","etdiv",24); }break;
	case "esdiv": if (esctrl != null) {esctrl.style.display="block";SetCookie("Cookie_LeftNavItem","esdiv",24);  }break;
	case "fbdiv": if (fbctrl != null) {fbctrl.style.display="block";SetCookie("Cookie_LeftNavItem","fbdiv",24); }break;
	case "edcdiv": if (edcctrl != null) {edcctrl.style.display="block";SetCookie("Cookie_LeftNavItem","edcdiv",24); }break;
}
}

function SetCookie(cookieName,cookieValue,nHours) {
 var today = new Date();
 var expire = new Date();
 if (nHours==null || nHours==0) nHours=1;
 expire.setTime(today.getTime() + 3600000*nHours);
 document.cookie = cookieName+"="+cookieValue+ ";expires="+expire.toGMTString();}
function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return theCookie.substring(ind+cookieName.length+1,ind1);}

function fnTrapKD(btnID, event){btn = MM_findObj(btnID);
	if (document.all)
	{	if (event.keyCode == 13)
		{	event.returnValue=false;event.cancel = true;btn.click();}}
	else if (document.getElementById)
	{	if (event.which == 13)
		{	event.returnValue=false;event.cancel = true;btn.focus();btn.click();}}
	else if(document.layers)
	{	if(event.which == 13)
		{	event.returnValue=false;event.cancel = true;btn.focus();btn.click();}}}
		
//Added by Guillermo during FES merger. 03/13/2007 3:59pm
function changeImages(){for (var i=0; i<changeImages.arguments.length; i+=2){document[changeImages.arguments[i]].src = changeImages.arguments[i+1];}}