
var plugin
var main
var layout_style = "4"
var layout_iconhide = 2
var stage_width
var hlroot =""
var video_directory = "img/"
var img_directory = "img/"

// main tiles
var videoArr = new Array("1", "2", "3", "4", "5")

// Layout generic
var tbLeft = 190
var tbTop = 230
var tbWidth = 170
var tbText = "Streamdoc is web-based software which allows you to organize and store your documents"
var tbText2 = "Streamdoc is web based software which allows you to organize and store your documents";
// The one-click method allows you to store document content and document with one click of a mouse button. Fast retrieval when searching for text.
// Layout # 2
// Icon/images in horizontal placement
var imgArr2 = new Array("10", "11", "12", "14", "13")


// Layout # 3
// Icon/images in vertical placement


// Layout # 4
// Icon/images in circle
var imgArr4 = new Array("11", "12", "13", "14", "15", "16", "17")
var imgIconsArr4 = new Array("img/91.png", "img/92.png", "img/93.png", "img/94.png", "img/95.png", "img/96.png", "img/97.png")
//                           1     2      3      4      5      6     7
var imgArr4PosX = new Array("220", "365", "450", "350", "200", "75", "90")
var imgArr4PosY = new Array("150", "175", "275", "400", "415", "325", "200")

// txtBody horizontal placement
var tbArr4Top = new Array("130", "275", "130", "130", "130", "130", "130")
var tbArr4Left = new Array("300", "80", "80", "95", "100", "140", "150")
var tbArr4Width = new Array("350", "500", "210", "550", "600", "450", "350")

var iconArr3 = new Array("10", "11", "12", "14", "13")
var txtArr = new Array(" ", " ", " ", " ", " ")
var txtArr2 = new Array(" ", " ", " ", " ", " ")
//var txtArr3 = new Array(" ", " ", " ", " ", " ")
var txtArr4 = new Array(" ", " ", " ", " ", " ")
var txtArr41 = new Array(" ", " ", " ", " ", " ")
var txtArrTitles = new Array(" ", " ", " ", " ", " ")
var txtArrTitles2 = new Array(" ", " ", " ", " ", " ")
var txtArrTitles3 = new Array(" ", " ", " ", " ", " ")
//var sp = "                              "
 
var _root_xmouse = 0
var _root_ymouse = 0
var menu_hide_time = 100

var objsArr = new Array()
var mainNavArrTitles = new Array("PAYMENTS", "PAYMENTS")
var mainNavArr = new Array("Nav_0", "Nav_1", "Nav_2", "Nav_3", "Nav_4", "Nav_5")
var subNavArr = new Array()
subNavArr[0] = new Array("Features", "FAQs", "Resources", "Demos")
subNavArr[1] = new Array("Agendas", "City", "Departments", "Code")
subNavArr[2] = new Array("Here", "Emergency", "Things")
subNavArr[3] = new Array("Business", "Business", "Business", "Commerce")
subNavArr[4] = new Array("Features", "FAQs", "Resources", "Demos")
subNavArr[5] = new Array("Features", "FAQs", "Resources", "Demos")

// Populate navigation links
var subNavLinksArr = new Array()
subNavLinksArr[0] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
subNavLinksArr[1] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
subNavLinksArr[2] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
subNavLinksArr[3] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
subNavLinksArr[4] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
subNavLinksArr[5] = new Array("main3.aspx", "main4.aspx", "main5.aspx", "main6.aspx")
        
// Populate text content for row B large images. These show on rollover of image.
txtArrTitles[0] = "1. Cut costs";
txtArrTitles[1] = "2. Easy to use";
txtArrTitles[2] = "3. Full text indexing";
txtArrTitles[3] = "4. Audit capabilities";
txtArrTitles[4] = "5. Document security";
txtArrTitles[5] = "6. Document accessiblity";
txtArrTitles[6] = "7. Going green makes green sense";
txtArrTitles[7] = "7. Go Green";

// Text content for Large tiles
txtArr[0] = "lorem ipsum 10";
txtArr[1] = "lorem ipsum 11";
txtArr[2] = "lorem ipsum 12";
txtArr[3] = "lorem ipsum 13";
txtArr[4] = "lorem ipsum 14";
txtArr[5] = "lorem ipsum 15";

// Populate text content for row A smaller images. These show on rollover of image.
txtArrTitles2[0] = "b Title 10";
txtArrTitles2[1] = "b Title 11";
txtArrTitles2[2] = "b Title 12";
txtArrTitles2[3] = "b Title 13";
txtArrTitles2[4] = "simple document management";

// Text content for small tiles
txtArr2[0] = "lorem ipsum 1";
txtArr2[1] = "lorem ipsum 2";
txtArr2[2] = "lorem ipsum 3";
txtArr2[3] = "lorem ipsum 4";
txtArr2[4] = "lorem ipsum 5";

// Populate text content for row A smaller images. These show on rollover of image.
txtArrTitles3[0] = " ... fast and efficiently";
txtArrTitles3[1] = "             ... using full-text indexing";
txtArrTitles3[2] = "faster retrieval for ...";
txtArrTitles3[3] = "web-based ...";
txtArrTitles3[4] = "electronic storage for ...";

// Text content for small tiles
txtArr4[0] = "Consider one example of an industry that needs to cut costs in managing documents: \n\n'Today, it takes 80 to 90 days to resolve the medical portion of a disability claim. Most of that time involves getting the right medical information securely into the hands of the people who can adjudicate the claims. [...] However, with time consuming manual retrieval, it can cost hospitals a lot more to retrieve and send the information than the amount they get reimbursed. When the process is automated, the hospital costs for record retrieval and transmission drop significantly, and the hospitals can make money by processing each request.' \n\nWarren Suss, Government Computer News, March 2009.";
txtArr4[1] = "So much software is complicated to use and difficult to set up. Not so with Streamdoc. Very little training is needed so that you can be usefully retrieving the documents you need in minutes, not days. If you've used a web browser, then you'll find no difficulty with Streamdoc. \n\nStreamdoc makes managing your documents easy. This allows you to concentrate on the document information itself and not on the task of locating and retrieving it.";
txtArr4[2] = "No tedious indexing is required. Streamdoc will pull out all the necessary data from your scanned document. \n\nYou can still add, key words, categorizations, document ownership, retention policies and other data on the advanced indexing screen. \n\nUse one of the search options to find the document(s) you need based on its content, meta data or abstract.";
txtArr4[3] = "Comprehensive reports show you who has retrieved which documents and when. All activity is logged. Compliance with HIPAA, Sarbanes-Oxley and a host of other regulations is becoming increasingly an important issue. \n\n'Centers for Medicare and Medicaid Services has stated that a likely request in a compliance audit will be for a list of all users authorized to access systems that store, process, or transmit patient data. [...] Every user must have a unique identifier to access patient data'. \n\nHIPAA: Time To Get Serious \nFebruary 27, 2009, Information Week Analytics";
txtArr4[4] = "Having one copy of a document in a locked file cabinet is not as secure as you might imagine. Often file cabinets are not locked. Even opening a locked one is not difficult for anyone determined to take a document. Will they document be returned? Will it be correctly re-filed? How often have you found this not to be the case? \n\nElectronic archival of your important documents keeps them much more secure. Streamdoc is a true archival software in that it does not permit alteration of the original stored document. \n\nNatural disasters such as fire and floods can destroy your document store. The document data is backed up from the database and the documents themselves can be backed up to tape or backed up online for greater security.";
txtArr4[5] = "Since Streamdoc is a web-based software application many users can view the same documents at the same time and from virtually anywhere. Productivity can only benefit from this feature of online access. \n\nEnjoy the freedom and flexibility of working when and where you need to."; 
txtArr4[6] = "How much paper do you need to run your business? \nProbably more than you think. Much paper is consumed converting from electronic form to hard copy. Think about all those emails and faxes users print. Going green doesn't mean completely eliminating paper. Even though the paperless office may be a myth, paper reduction is still possible! \n\nBy storing your documents electronically you save both in paper production and paper disposal. Fewer resources are required to manufacture the paper you use. Fewer resources are needed to print, copy, store, retrieve and eventually dispose of all those documents. So it just makes 'green sense' to get the right document management solution. ";
// Text for txtBody when large tiles entered
txtArr41[0] = "SCAN YOUR DOCUMENTS \n\nBusinesses can easily accumulate thousands of documents. The influx of emails, faxes, PO's Invoices, policy documents and the like present a growing challenge. Where and how to store them all? How do we make them easily accessible to the people who need them? Electronic storage of your documents is a smart way to go. Streamdoc will help you meet these challenges in a cost-effective manner. \n\nBy accessing your documents electronically, you will save on paper, storage and distribution costs. Increased productivity and customer satisfaction are well within reach. Tracking document access and usage will help you comply with HIPAA and SOX regulations. \n\nThe paperless office may still be a myth, but paper reduction is not. Let Streamdoc help you reduce the paper shuffle in your business!";
//txtArr41[1] = "FULL-TEXT INDEXING \nSo much software is complicated to use and difficult to set up. Not so with Streamdoc. Very little training is needed so that you can be usefully retrieving the documents you need in minutes, not days. If you've used a web browser, then you'll find no difficulty with Streamdoc.";
txtArr41[1] = "ORGANIZE IMPORTANT WORK \n\nThe documents just keep flooding in. Before you realize it there is a growing paper mess in the office. Stacked files and stuffed filing cabinets clog the flow of work and stifle your ability to respond quickly and effectively to escalating business demands. \n\nWhat kind of documents do you need to store? \n\n"
+ "accounting reports, activity sheets, advertising materials, audit reports, bank statements, brochures, budgets, cancelled checks, correspondence, customer lists, designs, draft proposals, emails, health and safety, insurance policies, invoices, job descriptions, letters, logs, marketing materials, meeting agendas, memos, misprinted forms, notes, performance appraisals, phone messages, policy documents, price lists, product information, "
+ "purchase orders, reports, requirements specifications, rules and regulations, sales leads, sales statistics, shipping information, sign in sheets, specification drawings, tax records, testing notes, training manuals, user manuals, etc...";
txtArr41[2] = "FIND DOCUMENTS QUICKLY \n\nStop looking for lost paperwork. When you need to help a customer pull up the relevant document in seconds. Avoid wasting time searching for it, running to the filing cabinet, or searching under a stack of folders. Avoid having to return calls after hunting down the documents you needed but were not accessible. Avoid giving excuses for lost or damaged paperwork. Pull up what you need when you need it and respond faster to customer requests! "
+ "\n\nFILE DOCUMENTS EASILY \n\nNo tedious indexing is required. Streamdoc will pull out all the necessary data from your scanned document. You can still add additional key words, categorizations, document ownership, retention policies and other data on the advanced indexing screen. ";
txtArr41[3] = "WEB-BASED \n\n1. Allow access from virtually anywhere with a secure user logon. \n\n2. No more misplaced documents \n\n3. All user and document activity is logged for reports \n\n4. No computer installation issues \n\n5. Documents stored online and backed up \n\n6. Admin user manages all user accounts to control access \n\n7. Save on paper and distribution costs \n\n8. Avoid the constant paper shuffle"
txtArr41[4] = "REDUCE STORAGE COSTS \n\nThe amount of paper which businesses process today is simply staggering. Mountains of paper are moved about, stored, retrieved, stored again, misplaced, reproduced, duplicated, faxed, scanned and then shredded. Even the paperwork costs for a small business can be significant when you consider the real costs. For example, it has been estimated that it costs ... \n\n$20 to file a document \n\n$120 to find a misfiled document \n\n$220 to reproduce a lost document. \n\nAverage document is photocopied 19 times \n\nStaff spend 50% of their time looking for information \n\nThe 'cost of failure'. What is the real cost of NOT finding a document?";
txtArr41[5] = "";
txtArr41[6] = "";

// Set 1
var tile_img_width=120
var tile_img_height=80
var tile_spacing=0
var tile_top=0
var tile_scale=1
var tile_z=10
var tile_scale_up_to = 2.5
var tile_scale_up_to4 = 3.15

// Set 2
var tile_img_width2 = 120
var tile_img_height2 = 80
var tile_spacing2 = 0
var tile_top2 = 0
var tile_scale2 = 1
var tile_z2 = 10
var tile_scale_up_to2 = 1.2

var tileObjsArr = new Array()
var tileObjsArr2 = new Array()
var tileObjsArr3 = new Array()         
var tileObjsArr4 = new Array()      


//var videoTilePropsArr=new Array()
// Image array #1
for(i=0;i<videoArr.length;i++) {

	tileObjsArr[i]=new Object()
	
	//tileObjsArr[i].x=i*tile_spacing
	tileObjsArr[i].x=tile_spacing
	tileObjsArr[i].y=tile_top	
	tileObjsArr[i].z=tile_z
	
	tileObjsArr[i].width=tile_img_width
	tileObjsArr[i].height=tile_img_height
	
	tileObjsArr[i].scale=tile_scale
	tileObjsArr[i].center_x=tile_img_width/2
	tileObjsArr[i].center_y=tile_img_height/2
	
	if(i<Math.floor(videoArr.length/2)) {
		if(i==((videoArr.length-1)/2)) {
			tile_z=videoArr.length-1
		}
		else {
			tile_z+=1
		}
		nextspot=tile_spacing+(tile_img_width*tile_scale)+22
		tile_scale+=0.3
		tile_spacing=nextspot

	}
	else {
		tile_z-=1
		tile_scale-=0.3
		nextspot=tile_spacing+tile_img_width*tile_scale+22
		tile_spacing=nextspot
	}
	
	
}


tileHolder_width=tileObjsArr[videoArr.length-1].x + tileObjsArr[videoArr.length-1].width
//tileHolder_width=i*tile_spacing


// Image array #2
for (i = 0; i < imgArr2.length; i++) {

    tileObjsArr2[i] = new Object()

    //tileObjsArr2[i].x=i*tile_spacing
    tileObjsArr2[i].x = tile_spacing2
    tileObjsArr2[i].y = tile_top2
    tileObjsArr2[i].z = tile_z2

    tileObjsArr2[i].width = tile_img_width2
    tileObjsArr2[i].height = tile_img_height2

    tileObjsArr2[i].scale = tile_scale2
    tileObjsArr2[i].center_x = tile_img_width2 / 2
    tileObjsArr2[i].center_y = tile_img_height2 / 2

    if (i < Math.floor(imgArr2.length / 2)) {
        if (i == ((imgArr2.length - 1) / 2)) {
            tile_z2 = imgArr2.length - 1
        }
        else {
            tile_z2 += 1
        }
        nextspot2 = tile_spacing2 + (tile_img_width2 * tile_scale2) + 4
        tile_scale2 += 0
        tile_spacing2 = nextspot2

    }
    else {
        tile_z2 -= 1
        tile_scale2 -= 0
        nextspot2 = tile_spacing2 + tile_img_width2 * tile_scale2 + 4
        tile_spacing2 = nextspot2
    }


}

tileHolder_width2 = tileObjsArr2[imgArr2.length - 1].x + tileObjsArr2[imgArr2.length - 1].width



// Image array #4
for (i = 0; i < imgArr4.length; i++) {

    tileObjsArr4[i] = new Object()

    //tileObjsArr2[i].x=i*tile_spacing
    tileObjsArr4[i].x = tile_spacing2
    tileObjsArr4[i].y = tile_top2
    tileObjsArr4[i].z = tile_z2

    tileObjsArr4[i].width = tile_img_width2
    tileObjsArr4[i].height = tile_img_height2

    tileObjsArr4[i].scale = tile_scale2
    tileObjsArr4[i].center_x = tile_img_width2 / 2
    tileObjsArr4[i].center_y = tile_img_height2 / 2

    if (i < Math.floor(imgArr4.length / 2)) {
        if (i == ((imgArr4.length - 1) / 2)) {
            tile_z2 = imgArr4.length - 1
        }
        else {
            tile_z2 += 1
        }
        nextspot2 = tile_spacing2 + (tile_img_width2 * tile_scale2) + 4
        tile_scale2 += 0
        tile_spacing2 = nextspot2

    }
    else {
        tile_z2 -= 1
        tile_scale2 -= 0
        nextspot2 = tile_spacing2 + tile_img_width2 * tile_scale2 + 4
        tile_spacing2 = nextspot2
    }

}

tileHolder_width4 = tileObjsArr4[imgArr4.length - 1].x + tileObjsArr4[imgArr4.length - 1].width
//tileHolder_width=i*tile_spacing



// FADE FUNCTION
//-------------------------------------------------------------------------
var TimeToFade = 1000.0;

function fade(eid) {
    var element = main.findName(eid);
   //alert("eid: " + eid + "  element: " + element);      alert("element is null");
    if (element == null)
    return;

//alert(Math.random());
var Opa = 0;
for (i = 0; i < 100000; i++) {
    if (Math.random() > .95) {
        Opa = Opa + 0.0001
        element.opacity = Opa;
        //alert(Opa)
    }
}

//alert(element.opacity);
return;


alert("element.FadeState: " + element.FadeState);

    if (element.FadeState == null) {
    alert("element.FadeState");
        if (element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '1') {
            element.FadeState = 2;
        }
        else {
            element.FadeState = -2;
        }
    }
  alert("Hello");
  //alert(element.FadeState)

    if (element.FadeState == 1 || element.FadeState == -1) {
        element.FadeState = element.FadeState == 1 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
    else {
        element.FadeState = element.FadeState == 2 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade;
        setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
    }
}

function animateFade(lastTick, eid) {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;

    var element = document.getElementById(eid);

    if (element.FadeTimeLeft <= elapsedTicks) {
        element.style.opacity = element.FadeState == 1 ? '1' : '0';
        element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
        element.FadeState = element.FadeState == 1 ? 2 : -2;
        return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft / TimeToFade;
    if (element.FadeState == 1)
        newOpVal = 1 - newOpVal;

    element.style.opacity = newOpVal;
    element.style.filter = 'alpha(opacity = ' + (newOpVal * 100) + ')';

    setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

function fntbBody_Defaults() {
    // Set txtBody to default params
    var xamlObject = main.FindName("txtbody2");
    xamlObject.setValue("Canvas.Top", tbTop);
    xamlObject.setValue("Canvas.Left", tbLeft);
    xamlObject.setValue("Width", tbWidth);
    //xamlObject.setValue("Visibility", "Visible");
    xamlObject.setValue("Text", tbText);
    xamlObject.setValue("Opacity", 1);

    //var xamlObject2 = main.FindName("txtbody");
    //xamlObject2.setValue("Visibility", "Collapsed");
}

function fntbBody_Defaults2() {
    // Set txtBody to default params
    var xamlObject = main.FindName("txtbody2");
    xamlObject.setValue("Canvas.Top", tbTop-5);
    xamlObject.setValue("Canvas.Left", tbLeft-50);
    xamlObject.setValue("Width", tbWidth+120);
    xamlObject.setValue("Text", tbText2);
    xamlObject.setValue("Opacity", 1);
}

// ---------------------------------------------------------------------------
// MAIN
// ---------------------------------------------------------------------------
function mainCanvasLoaded(s) {

	//alert("main loaded")
		
	main=s.findName("mainCanvas")
	
	plugin = s.getHost()

	//stage_width=plugin.content.actualWidth	
	stage_width=plugin.width

	buildImages()

	switch (layout_style) {
	    case "0": 
	        break;
	    case "1": 
	        break;
	    case "2": buildImages2()
	        break;
	    case "3": buildImages3()
	        break;
	    case "4": buildImages4()
	        break;
	    default: buildImages2();
	}
	
	
	buildNav(s)

	// Start up
	//img = main.findName("Logo").source = "img/logo.png";
	res = fnShowSmallTitles();

	// Load default home page data
	hdr = main.findName("info").text = "";
	hdr = main.findName("txtbody").text = "";
	img = main.findName("myPic").source = "img/104.png";

    // Load default title and image
	var res = fnShowDetails(5, "simple document management", "img/home.png");

	// Set txtBody to default params
	hdr = fntbBody_Defaults2();
	
	// Load default nav menu
	navHomeAction(s)
}






function buildImages() {

    var tileHolder_str = '<Canvas Name="tilesHolder" Canvas.ZIndex="100" Canvas.Left="' + (stage_width / 2 - tileHolder_width / 2) + '" Canvas.Top="550">';	
	
	for(i=0;i<videoArr.length;i++) {
	
		//tileObjsArr[i]=new Object()
		
		tileHolder_left=tileObjsArr[i].x
		tileHolder_top=tileObjsArr[i].y
		tile_z=tileObjsArr[i].z
		
		tileHolderReflection_top=(tileObjsArr[i].height*2)
		
		tile_img_width=tileObjsArr[i].width
		tile_img_height=tileObjsArr[i].height
		
		scale_x=scale_y=tileObjsArr[i].scale
		center_x=tileObjsArr[i].center_x
		center_y=tileObjsArr[i].center_y
		
		tileHolder_str += 		'<Canvas Name="tileHolder_'+i+'" Canvas.Left="'+tileHolder_left+'" Canvas.Top="'+tileHolder_top+'" Canvas.ZIndex="'+tile_z+'">'

		tileHolder_str +=       '<Canvas Name="imgHolderReflection_' + i + '" Canvas.ZIndex="50" Canvas.Top="' + tileHolderReflection_top + '">'
		tileHolder_str += 		'		<Canvas.OpacityMask>'
		tileHolder_str += 		'			<LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">'           
		tileHolder_str += 		'	      		<GradientStop Offset="0.37" Color="#00000000"  />'      
		tileHolder_str += 		'	      		<GradientStop Offset="1" Color="#88000000"  />'
		tileHolder_str += 		'	      	</LinearGradientBrush>'          
		tileHolder_str += 		'		</Canvas.OpacityMask>'
		tileHolder_str += 		'		<Canvas.RenderTransform><TransformGroup><ScaleTransform Name="ReflectionScaleTransform_'+i+'" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /></TransformGroup></Canvas.RenderTransform>'
		tileHolder_str +=		'		<Image Name="imgReflection_'+i+'" Stretch="Fill" Width="'+tile_img_width+'" Height="'+tile_img_height+'" Source="'+video_directory+videoArr[i]+'.jpg" />'
		tileHolder_str +=		'	</Canvas>'

		tileHolder_str +=       '	<Canvas Name="imgHolder_' + i + '"  >'
		tileHolder_str +=       '		<Image Name="img_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" MouseEnter="tileEnter" MouseLeave="tileLeave" MouseLeftButtonDown="tilePress" Source="' + video_directory + videoArr[i] + '.jpg" />'
		tileHolder_str +=		'	</Canvas>'
		tileHolder_str +=		'	 <Canvas.RenderTransform><ScaleTransform Name="st_'+i+'" ScaleX="'+scale_x+'" ScaleY="'+scale_y+'" CenterX="'+center_x+'" CenterY="'+center_y+'"/></Canvas.RenderTransform>'	
		tileHolder_str +=		'</Canvas>'	
	
		//tileObjsArr[i].scale_x=scale_x
		//tileObjsArr[i].scale_y=scale_y
		tileObjsArr[i].parent="tileHolder_"+i
		tileObjsArr[i].scaleTransform="st_"+i
		
	}

	tileHolder_str += '</Canvas>';	           
	//alert(tileHolder_str)
	tileHolderTag=plugin.content.createFromXaml(tileHolder_str)
	main.children.add(tileHolderTag)

}



function buildImages2() {

    var tileHolder_str = '<Canvas Name="tilesHolder2" Canvas.Left="' + (stage_width / 2 - tileHolder_width2 / 2) + '" Canvas.Top="430">';

    for (i = 0; i < imgArr2.length; i++) {

        //tileObjsArr[i]=new Object()

        tileHolder_left = tileObjsArr2[i].x + 100   // val 100 sets offsett from LHS
        tileHolder_top = tileObjsArr2[i].y
        tile_z = tileObjsArr2[i].z

        tileHolderReflection_top = (tileObjsArr2[i].height * 1)

        tile_img_width=64  // = tileObjsArr2[i].width/1.4
        tile_img_height = tileObjsArr2[i].height/1.4

        scale_x = scale_y = tileObjsArr2[i].scale
        center_x = tileObjsArr2[i].center_x
        center_y = tileObjsArr2[i].center_y

        tileHolder_str += '<Canvas Name="tileHolder2_' + i + '" Canvas.Left="' + tileHolder_left + '" Canvas.Top="' + tileHolder_top + '" Canvas.ZIndex="' + tile_z + '">'

        tileHolder_str += '	<Canvas Name="imgHolderReflection2_' + i + '" Canvas.Top="' + tileHolderReflection_top + '">'
        tileHolder_str += '		<Canvas.OpacityMask>'
        tileHolder_str += '			<LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">'
        tileHolder_str += '	      		<GradientStop Offset="0.37" Color="#00000000"  />'
        tileHolder_str += '	      		<GradientStop Offset="1" Color="#88000000"  />'
        tileHolder_str += '	      	</LinearGradientBrush>'
        tileHolder_str += '		</Canvas.OpacityMask>'
        tileHolder_str += '		<Canvas.RenderTransform><TransformGroup><ScaleTransform Name="ReflectionScaleTransform2_' + i + '" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /></TransformGroup></Canvas.RenderTransform>'
        tileHolder_str += '		<Image Name="imgReflection2_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" Source="' + video_directory + imgArr2[i] + '.png" />'
        tileHolder_str += '	</Canvas>'

        tileHolder_str += '	<Canvas Name="imgHolder2_' + i + '"  >'
        tileHolder_str += '		<Image Name="img2_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" MouseEnter="tileEnter2" MouseLeave="tileLeave2" MouseLeftButtonDown="tilePress" Source="' + video_directory + imgArr2[i] + '.png" />'
        tileHolder_str += '	</Canvas>'
        tileHolder_str += '	 <Canvas.RenderTransform><ScaleTransform Name="st2_' + i + '" ScaleX="' + scale_x + '" ScaleY="' + scale_y + '" CenterX="' + center_x + '" CenterY="' + center_y + '"/></Canvas.RenderTransform>'
        tileHolder_str += '</Canvas>'

        //tileObjsArr[i].scale_x=scale_x
        //tileObjsArr[i].scale_y=scale_y
        tileObjsArr2[i].parent = "tileHolder2_" + i
        tileObjsArr2[i].scaleTransform = "st2_" + i

    }

    tileHolder_str += '</Canvas>'; 
    //alert(tileHolder_str)
    tileHolderTag = plugin.content.createFromXaml(tileHolder_str)
    main.children.add(tileHolderTag)

}

// Images and text for home page 'news' items
function buildImages3() {

    var tileHolder_str = '<Canvas Name="tilesHolder3" Canvas.Left="' + (stage_width / 2 - tileHolder_width2 / 2) + '" Canvas.Top="150">';

    for (i = 0; i < imgArr2.length; i++) {
    
        tileHolder_left = 100 //val 100 sets offsett from LHS
        tileHolder_top = tileObjsArr2[i].y + (i * 50) 
        tile_z = tileObjsArr2[i].z

        tileHolderReflection_top = (tileObjsArr2[i].height * 1)

        tile_img_width = 48  // = tileObjsArr2[i].width/1.4
        tile_img_height = tileObjsArr2[i].height / 1.4

        scale_x = scale_y = tileObjsArr2[i].scale
        center_x = tileObjsArr2[i].center_x
        center_y = tileObjsArr2[i].center_y

        tileHolder_str += '<Canvas Name="tileHolder3_' + i + '" Canvas.Left="' + tileHolder_left + '" Canvas.Top="' + tileHolder_top + '" Canvas.ZIndex="' + tile_z + '">'

        tileHolder_str += '	<Canvas Name="imgHolderReflection3_' + i + '" Canvas.Top="' + tileHolderReflection_top + '">'
        tileHolder_str += '		<Canvas.OpacityMask>'
        tileHolder_str += '			<LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">'
        tileHolder_str += '	      		<GradientStop Offset="0.37" Color="#00000000"  />'
        tileHolder_str += '	      		<GradientStop Offset="1" Color="#88000000"  />'
        tileHolder_str += '	      	</LinearGradientBrush>'
        tileHolder_str += '		</Canvas.OpacityMask>'
        tileHolder_str += '		<Canvas.RenderTransform><TransformGroup><ScaleTransform Name="ReflectionScaleTransform3_' + i + '" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /></TransformGroup></Canvas.RenderTransform>'
        tileHolder_str += '		<Image Name="imgReflection3_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" Source="' + img_directory + imgArr2[i] + '.png" />'
        tileHolder_str += '	</Canvas>'

        tileHolder_str += '	<Canvas Name="imgHolder3_' + i + '"  >'
        tileHolder_str += '		<Image Name="img3_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" MouseEnter="tileEnter3" MouseLeave="tileLeave3" MouseLeftButtonDown="tilePress" Source="' + img_directory + imgArr2[i] + '.png" />'
        tileHolder_str += '	</Canvas>'
        tileHolder_str += '	 <Canvas.RenderTransform><ScaleTransform Name="st3_' + i + '" ScaleX="' + scale_x + '" ScaleY="' + scale_y + '" CenterX="' + center_x + '" CenterY="' + center_y + '"/></Canvas.RenderTransform>'
        tileHolder_str += '</Canvas>'

        //tileObjsArr[i].scale_x=scale_x
        //tileObjsArr[i].scale_y=scale_y
        tileObjsArr2[i].parent = "tileHolder3_" + i
        tileObjsArr2[i].scaleTransform = "st3_" + i

    }

    tileHolder_str += '</Canvas>';
    //alert(tileHolder_str)
    tileHolderTag = plugin.content.createFromXaml(tileHolder_str)
    main.children.add(tileHolderTag)

}

// Images and text for home page in shape formation
function buildImages4() {

    var tileHolder_str = '<Canvas Name="tilesHolder4" Canvas.ZIndex="100" Canvas.Left="200" Canvas.Top="20">';

    for (i = 0; i < imgArr4.length; i++) {

        tileHolder_left = 350 //val 100 sets offsett from LHS
        tileHolder_top = 100 //tileObjsArr2[i].y + (i * 50)

        tileHolder_left = imgArr4PosX[i]
        tileHolder_top = imgArr4PosY[i]
        tile_z = tileObjsArr4[i].z 

        tileHolderReflection_top = (tileObjsArr4[i].height * 1.1)

        tile_img_width = 48  // = tileObjsArr2[i].width/1.4
        tile_img_height = tileObjsArr4[i].height / 1.4

        scale_x = scale_y = tileObjsArr4[i].scale
        center_x = tileObjsArr4[i].center_x
        center_y = tileObjsArr4[i].center_y

        tileHolder_str += '<Canvas Name="tileHolder4_' + i + '" Canvas.Left="' + tileHolder_left + '" Canvas.Top="' + tileHolder_top + '" Canvas.ZIndex="' + tile_z + '">'

        tileHolder_str += '	<Canvas Name="imgHolderReflection4_' + i + '" Canvas.Top="' + tileHolderReflection_top + '">'
        tileHolder_str += '		<Canvas.OpacityMask>'
        tileHolder_str += '			<LinearGradientBrush  StartPoint="0,0" EndPoint="0,1">'
        tileHolder_str += '	      		<GradientStop Offset="0.37" Color="#00000000"  />'
        tileHolder_str += '	      		<GradientStop Offset="1" Color="#88000000"  />'
        tileHolder_str += '	      	</LinearGradientBrush>'
        tileHolder_str += '		</Canvas.OpacityMask>'
        tileHolder_str += '		<Canvas.RenderTransform><TransformGroup><ScaleTransform Name="ReflectionScaleTransform4_' + i + '" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /></TransformGroup></Canvas.RenderTransform>'
        tileHolder_str += '		<Image Name="imgReflection4_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" Source="' + img_directory + imgArr4[i] + '.png" />'
        tileHolder_str += '	</Canvas>'

        tileHolder_str += '	<Canvas Name="imgHolder4_' + i + '"  >'
        tileHolder_str += '		<Image Name="img4_' + i + '" Stretch="Fill" Width="' + tile_img_width + '" Height="' + tile_img_height + '" MouseEnter="tileEnter4" MouseLeave="tileLeave4" MouseLeftButtonDown="tilePress" Source="' + img_directory + imgArr4[i] + '.png" />'
        tileHolder_str += '	</Canvas>'
        tileHolder_str += '	 <Canvas.RenderTransform><ScaleTransform Name="st4_' + i + '" ScaleX="' + scale_x + '" ScaleY="' + scale_y + '" CenterX="' + center_x + '" CenterY="' + center_y + '"/></Canvas.RenderTransform>'
        tileHolder_str += '</Canvas>'

        //tileObjsArr[i].scale_x=scale_x
        //tileObjsArr[i].scale_y=scale_y
        tileObjsArr4[i].parent = "tileHolder4_" + i
        tileObjsArr4[i].scaleTransform = "st4_" + i

    }

    tileHolder_str += '</Canvas>';
    //alert(tileHolder_str)
    tileHolderTag4 = plugin.content.createFromXaml(tileHolder_str)
    main.children.add(tileHolderTag4)

}



function tilePress(s) {

	//s.findName("videoHolder").opacity=1
	//vid.play()
	var hl = ""
	var id = s.name.split("_")[1]
	switch (id) {
	    case "0": hl = 'main.aspx?q=6069&p=9261';
	        break;
	    case "1": hl = 'main.aspx?q=6067&p=9159';
	        break;
	    case "2": hl = 'main.aspx?q=6030&p=9731';
	        break;
	    case "3": hl = 'main.aspx?q=6068&p=9215';
	        break;
	    case "4": hl = 'main.aspx?q=6080&p=9337';
	        break;
	    default:  hl = 'main3.aspx';
	}
	
	window.location = hl
}


function tileEnter(s,e) {

    // Time to zoom to larger image
    time_to_scale_tile = 0.9
	
	var obj = 1.0
	var ind=s.name.split("_")[1]
	var me=tileObjsArr[ind]
	
	var par=s.findName(me.parent)
	var st=s.findName(me.scaleTransform)

	//for(i=0;i<videoArr.length;i++) {
		//s.findName("tileHolder_"+i)["Canvas.ZIndex"]=0
	//}

	// Animate fade in of text
	hdr = main.findName("FadeIn2").Begin();
	hdr = main.findName("FadeIn").Begin();
	
	// Line icons up to top of pagge
	hdr = main.findName("P1MoveTop").Begin();
	hdr = main.findName("P2MoveTop").Begin();
	hdr = main.findName("P3MoveTop").Begin();
	hdr = main.findName("P4MoveTop").Begin();
	hdr = main.findName("P5MoveTop").Begin();
	hdr = main.findName("P6MoveTop").Begin();
	hdr = main.findName("P7MoveTop").Begin();

	hdr = main.findName("P1MoveLeft").Begin();
	hdr = main.findName("P2MoveLeft").Begin();
	hdr = main.findName("P3MoveLeft").Begin();
	hdr = main.findName("P4MoveLeft").Begin();
	hdr = main.findName("P5MoveLeft").Begin();
	hdr = main.findName("P6MoveLeft").Begin();
	hdr = main.findName("P7MoveLeft").Begin();


	var xamlObject = main.FindName("txtbody");
	xamlObject.setValue("Canvas.Top", 135);
	xamlObject.setValue("Canvas.Left", 110);
	xamlObject.setValue("Width", 520);
	xamlObject.setValue("Visibility", "Visible");
	xamlObject.setValue("Text", txtArr41[ind]);
	xamlObject.setValue("Cursor", "Hand");
	
	// Animate slide out of text and set title
	hdr = main.findName("tbSlider").text = txtArrTitles3[ind];
	hdr = main.findName("tbSlider").Visibility = "Visible"
	hdr = main.findName("aSlideOut").Begin();
	
	par["Canvas.ZIndex"]=50
	
	if(me.tweenS2) {
		me.tweenS2.stop()
		me.tweenY2.stop()
	}
	
	me.tweenS = new Tween(new Object(),'s',Tween.strongEaseOut,st.scaleX,tile_scale_up_to,time_to_scale_tile)
	
	me.tweenS.onMotionChanged = function(event){	
		st.scaleX = event.target._pos
		st.scaleY = event.target._pos
	}
	
	me.tweenS.start()		

	me.tweenY = new Tween(new Object(),'y',Tween.strongEaseOut,par["Canvas.Top"],(me.y+40),time_to_scale_tile)

	me.tweenY.onMotionChanged = function(event) {

	var pt = event.name;

	    par["Canvas.Top"] = event.target._pos;
	}
	
	me.tweenY.start()

	// Case statement for image title
	var title1 = null;
	var title2 = null;
	var ctl = null;	
	switch (ind) {
	    case "0": title1 =  'Calendar';
	        strImg = "img/100.png";
	        ctl="tbB1"
	        break;
	    case "1": title1 =  'Newsletter';
	        strImg = "img/101.png";
	        ctl = "tbB2"
	        break;
	    case "2": title1 = 'test';
	        strImg = "img/102.png";
	        ctl = "tbB3"
	        break;
	    case "3": title1 = 'Discover ';
	        strImg = "img/103.png";
	        ctl = "tbB4"
	        break;
	    case "4": title1 = 'Local';
	        strImg = "img/104.png";
	        ctl = "tbB5"
	        break;
	    default: result = ' ';
	}


	var forecol = "#FF0A286F"  
	hdr = main.findName(ctl).fontsize = 22;
	hdr = main.findName(ctl).foreground = "#000000"
	hdr = main.findName(ctl).Opacity = "0.8" 
	//hdr = main.findName(ctl).ZIndex = "101" 

	//hdr = main.findName("info").text = title1
	var res = fnShowDetails(ind, title1, strImg);
	res=fntbBody_Defaults2()
	//res = fnHideSmallTitles();
	//res = fnSetSmallTitles(ind,0);

}

function fnShowDetails(id, strVal, strImg) {

    hdr = main.findName("info").text = strVal;
    //hdr = main.findName("txtbody").text = txtArr[id];
    //img = main.findName("myPic").source = strImg;
    

}

function fnSetATitles() {
    // Set all titles
    var intFontsize = 10
    var forecol = "#FF8AA6E9"
    hdr = main.findName("txtTitleA0").fontsize = intFontsize;
    hdr = main.findName("txtTitleA1").fontsize = intFontsize;
    hdr = main.findName("txtTitleA2").fontsize = intFontsize;
    hdr = main.findName("txtTitleA3").fontsize = intFontsize;
    hdr = main.findName("txtTitleA4").fontsize = intFontsize;
    hdr = main.findName("txtTitleA0").foreground = forecol
    hdr = main.findName("txtTitleA1").foreground = forecol
    hdr = main.findName("txtTitleA2").foreground = forecol
    hdr = main.findName("txtTitleA3").foreground = forecol
    hdr = main.findName("txtTitleA4").foreground = forecol
}

function fnSetBTitles() {
    // Set all titles
    var intFontsize = 9
    var forecol = "#FF8AA6E9"
    hdr = main.findName("tbB1").fontsize = intFontsize;
    hdr = main.findName("tbB2").fontsize = intFontsize;
    hdr = main.findName("tbB3").fontsize = intFontsize; 
    hdr = main.findName("tbB4").fontsize = intFontsize;        
    hdr = main.findName("tbB5").fontsize = intFontsize;
    hdr = main.findName("tbB1").foreground = forecol
    hdr = main.findName("tbB2").foreground = forecol
    hdr = main.findName("tbB3").foreground = forecol
    hdr = main.findName("tbB4").foreground = forecol
    hdr = main.findName("tbB5").foreground = forecol 
}

function fnHideSmallTitles() {
    // Hide all titles
    var Vis = "Collapsed"
    hdr2 = main.findName("txtTitleA0").Visibility = Vis;
    hdr2 = main.findName("txtTitleA1").Visibility = Vis;
    hdr2 = main.findName("txtTitleA2").Visibility = Vis;
    hdr2 = main.findName("txtTitleA3").Visibility = Vis;     
    hdr2 = main.findName("txtTitleA4").Visibility = Vis;     
    //hdr2 = main.findName("txtTitleA5").Visibility = "Collapsed";    
}

function fnShowSmallTitles() {
    // Show and populate small titles

    var Vis = "Collapsed"
    hdr2 = main.findName("txtTitleA0").text = txtArrTitles2[0];
    hdr2 = main.findName("txtTitleA1").text = txtArrTitles2[1];    
    hdr2 = main.findName("txtTitleA2").text = txtArrTitles2[2];
    hdr2 = main.findName("txtTitleA3").text = txtArrTitles2[3];
    hdr2 = main.findName("txtTitleA4").text = txtArrTitles2[4];
    hdr2 = main.findName("txtTitleA0").Visibility = Vis;
    hdr2 = main.findName("txtTitleA1").Visibility = Vis;
    hdr2 = main.findName("txtTitleA2").Visibility = Vis;
    hdr2 = main.findName("txtTitleA3").Visibility = Vis;
    hdr2 = main.findName("txtTitleA4").Visibility = Vis;    
}

function fnSetSmallTitles(ind, style) {
    // Set style of A title
    var vfontsize=14
    var vforecol = "#000000"  
    var vopacity = "0.8"
    hdr = main.findName("txtTitleA" + ind).fontsize = vfontsize;
    hdr = main.findName("txtTitleA" + ind).foreground = vforecol
    hdr = main.findName("txtTitleA" + ind).Opacity = vopacity    

}

function fnShowSmallTitle(id) {
    // Show and populate small title

    var tbName = ""
    switch (id) {
        case "0":
            strVal = ""
            tbName = "txtTitleA0";
            break;
        case "1":
            strVal = 'My FAQs';
            tbName = "txtTitleA1";
            break;
        case "2":
            strVal = 'My Contacts';
            tbName = "txtTitleA2";
            break;
        case "3":
            strVal = 'My Other';
            tbName = "txtTitleA3";
            break;
        case "4":
            strVal = 'My Schedules';
            tbName = "txtTitleA4";
            break;
        default: result = ' ';

    }

    hdr2 = main.findName(tbName).text = txtArrTitles2[id];
    hdr2 = main.findName(tbName).Visibility = "Visible";
}

function tileLeave(s,e) {

	var ind=s.name.split("_")[1]
	var me=tileObjsArr[ind]
	
	time_to_scale_tile= (tile_scale_up_to-me.scale)
	
	var par=s.findName(me.parent)
	var st=s.findName(me.scaleTransform)

	// Animate fade out of text
	hdr = main.findName("FadeOut2").Begin();
	hdr = main.findName("FadeOut").Begin();
	
	// Line icons up to center of page
	hdr = main.findName("P1MoveCenter").Begin();
	hdr = main.findName("P2MoveCenter").Begin();
	hdr = main.findName("P3MoveCenter").Begin();
	hdr = main.findName("P4MoveCenter").Begin();
	hdr = main.findName("P5MoveCenter").Begin();
	hdr = main.findName("P6MoveCenter").Begin();
	hdr = main.findName("P7MoveCenter").Begin();

	hdr = main.findName("P1MoveLeftCenter").Begin();
	hdr = main.findName("P2MoveLeftCenter").Begin();
	hdr = main.findName("P3MoveLeftCenter").Begin();
	hdr = main.findName("P4MoveLeftCenter").Begin();
	hdr = main.findName("P5MoveLeftCenter").Begin();
	hdr = main.findName("P6MoveLeftCenter").Begin();
	hdr = main.findName("P7MoveLeftCenter").Begin();	
	
	// Animate slide back in of text
	hdr = main.findName("aSlideIn").Begin();	
	
	par["Canvas.ZIndex"]=49
	
	me.tweenS.stop()
	me.tweenY.stop()
	diff=st.scaleX-(st.scaleX-me.scale)/3
	
	me.tweenS2 = new Tween(new Object(),'s',Tween.strongEaseOut,st.scaleX,me.scale,time_to_scale_tile)
	
	me.tweenS2.onMotionChanged = function(event){	
		st.scaleX = event.target._pos
		st.scaleY = event.target._pos
	}
	
	me.tweenS2.onMotionFinished = function(event){	
		par["Canvas.ZIndex"]=me.z
	}	
	
	me.tweenS2.start()	
	me.tweenY2 = new Tween(new Object(),'y',Tween.strongEaseOut,par["Canvas.Top"],0,time_to_scale_tile)
	me.tweenY2.onMotionChanged = function(event){
	    par["Canvas.Top"] = event.target._pos
	}

	me.tweenY2.start()

	// Default image title
//	hdr = main.findName("info").text = "Image Solutions"
//	hdr = main.findName("tbB1").fontsize = 9;
//	hdr = main.findName("tbB2").fontsize = 9;	
//	hdr = main.findName("tbB3").fontsize = 9;
//	hdr = main.findName("tbB4").fontsize = 9;
//	hdr = main.findName("tbB5").fontsize = 9;

	// Reset B titles
	hdr = fnSetBTitles();
}


function tileEnter2(s, e) {

    // Time to zoom to larger image
    time_to_scale_tile = 1.5

    var ind = s.name.split("_")[1]
    var me = tileObjsArr2[ind]
    var par = s.findName(me.parent)
    var st = s.findName(me.scaleTransform)

    for (i = 0; i < imgArr2.length; i++) {
        //s.findName("tileHolder_"+i)["Canvas.ZIndex"]=0
    }

    par["Canvas.ZIndex"] = 50

    if (me.tweenS2) {
        me.tweenS2.stop()
        me.tweenY2.stop()
    }

    me.tweenS = new Tween(new Object(), 's', Tween.strongEaseOut, st.scaleX, tile_scale_up_to2, time_to_scale_tile)

    me.tweenS.onMotionChanged = function(event) {
        st.scaleX = event.target._pos
        st.scaleY = event.target._pos
    }

    me.tweenS.start()
    me.tweenY = new Tween(new Object(), 'y', Tween.strongEaseOut, par["Canvas.Top"], (me.y + 10), time_to_scale_tile)
    me.tweenY.onMotionChanged = function(event) {
        var pt = event.name;
        par["Canvas.Top"] = event.target._pos;
    }

    me.tweenY.start()

    // Create image source path
    strImg = "img/" + iconArr3[ind]+ ".png"
    //hdr = main.findName("info").text = title1
    title1 = txtArrTitles2[ind]
    
    var res = fnShowDetails2(ind, title1, strImg)
    //res = fnHideSmallTitles();
    res = fnSetSmallTitles(ind,1);

    // Nav menu control
    navEnter(s, e, ind)
}

function fnShowDetails2(id, strVal, strImg) {

    var s1 = "1. Main Idea \n2. Next Idea \n3. Third Idea"
    hdr = main.findName("info").text = strVal;
    hdr = main.findName("txtbody").text = txtArr2[id];
    //hdr2 = main.findName("txtbody").Visibility = "Collapsed";

    //TARGET ELEMENT
    //var box = main.findName("txtbody");
    //box.style.opacity = "1";
    //alert(box);

    //hdr2 = fade(hdr2, 100);
    hdr = main.findName("txtbody").name
    //hdr = setInterval("setAction", 1000);
    //hdr2 = fade(hdr);
    //alert("fnShowDetails2: " + hdr.name);
    img = main.findName("myPic").source = strImg;

}

function setAction() {
    alert("setAction");
    hdr = main.findName("txtbody").name;
    hdr2 = fade(hdr);
}

function tileLeave2(s, e) {


    //time_to_scale_tile=0.7

    var ind = s.name.split("_")[1]
    var me = tileObjsArr2[ind]

    time_to_scale_tile = (tile_scale_up_to - me.scale)

    var par = s.findName(me.parent)
    var st = s.findName(me.scaleTransform)

    for (i = 0; i < imgArr2.length; i++) {
        //s.findName("tileHolder_"+i)["Canvas.ZIndex"]=0
    }

    par["Canvas.ZIndex"] = 49


    me.tweenS.stop()
    me.tweenY.stop()
    diff = st.scaleX - (st.scaleX - me.scale) / 3

    me.tweenS2 = new Tween(new Object(), 's', Tween.strongEaseOut, st.scaleX, me.scale, time_to_scale_tile)
    me.tweenS2.onMotionChanged = function(event) {
        st.scaleX = event.target._pos
        st.scaleY = event.target._pos
    }

    me.tweenS2.onMotionFinished = function(event) {
        par["Canvas.ZIndex"] = me.z
    }

    me.tweenS2.start()
    me.tweenY2 = new Tween(new Object(), 'y', Tween.strongEaseOut, par["Canvas.Top"], 0, time_to_scale_tile)
    me.tweenY2.onMotionChanged = function(event) {
        par["Canvas.Top"] = event.target._pos
    }

    me.tweenY2.start()

    // Default image title
    //hdr = main.findName("info").text = "Image Solutions"
    res = fnSetSmallTitles(ind,0);

    // Reset A titles
    hdr=fnSetATitles();
    
    navLeave(s, e)
}


// Tile section 4
// ----------------------------------------------------------------
function tileEnter4(s, e) {

    // Time to zoom to larger image
    time_to_scale_tile = 0.9
    var ind = s.name.split("_")[1]
    var me = tileObjsArr4[ind]
    var par = s.findName(me.parent)
    var st = s.findName(me.scaleTransform)

    // Settings for txtBody content
    hdr = main.findName("FadeIn").Begin();

    var xamlObject = main.FindName("txtbody");
    xamlObject.setValue("Canvas.Top", tbArr4Top[ind]);
    xamlObject.setValue("Canvas.Left", tbArr4Left[ind]);
    xamlObject.setValue("Width", tbArr4Width[ind]);
    xamlObject.setValue("Visibility", "Visible");
    xamlObject.setValue("Text", txtArr4[ind]);
    xamlObject.setValue("Cursor", "Hand");

    // Animate slide out of text and set title
    // Slider #2 management
    var u = fnRunSlider2(ind, 0);

    
    // Slider #3 management
    // param1: slidername, param2: 1=out, 0=in, param3: property name
    //alert("enter1")
    //var v = fnRunSlider3(ind, 0);
    //var v = fnRunSlider(3, 0, "(Canvas.Top)");
    var o = main.FindName("aSlideOut2");
    //o.findname("aSlideOut2")["Storyboard.TargetProperty."] = "AutoReverse";
    //o.findname("aSlideOut2") = "True";
    o.findname("aSlideOut2").begin();
    o.findname("aSlideOut2V").Begin();
    o = null;
   
    //v = null;
    //alert("leave1")
    
    par["Canvas.ZIndex"] = 50

    if (me.tweenS4) {
        me.tweenS4.stop()
        me.tweenY4.stop()
    }

    me.tweenS4 = new Tween(new Object(), 's', Tween.regularEaseOut2, st.scaleX, tile_scale_up_to4, time_to_scale_tile)

    me.tweenS4.onMotionChanged = function(event) {
        st.scaleX = event.target._pos 
        st.scaleY = event.target._pos 
    }

    me.tweenS4.start()
    me.tweenY4 = new Tween(new Object(), 'y', Tween.strongEaseOut, par["Canvas.Top"], (me.y + 10), time_to_scale_tile)
    //me.tweenY4.onMotionChanged = function(event) {
    //
    //  var pt = event.name;
    //    par["Canvas.Top"] = event.target._pos;
    //}

    //me.tweenY4.start()

    //Hide all icon images
    //alert(ind)
    fnShowStateIcons(4, 0, ind, layout_iconhide)
    

    // Create image source path
    strImg = "img/" + iconArr3[ind] + ".png"
    title1 = txtArrTitles2[ind]

    var res //= fnShowDetails4(ind, title1, strImg)
    //hdr = main.findName("FadeInIcon").Begin();
    var xamlObj44 = main.FindName("myPic");
    xamlObj44.setValue("Visibility", "Visible");
    //alert(imgIconsArr4[ind]);
    xamlObj44.setValue("Source", imgIconsArr4[ind]);
    xamlObj44.setValue("Canvas.Top", tbArr4Top[ind]);
    xamlObj44.setValue("Canvas.Left", tbArr4Left[ind]-80);
    xamlObj44.setValue("Canvas.ZIndex", 58);

    
    
    //res = fnHideSmallTitles();
    res = fnSetSmallTitles(ind, 1);

    // Nav menu control
    //navEnter(s, e, ind)
}

function fnRunSlider2(id, inout) {
    // Find slider, set text, run story
    var xamlSlider2 = main.FindName("tbSlider2");
    xamlSlider2.setValue("Text", txtArrTitles[id]);
    xamlSlider2.setValue("Visibility", "Visible");
    if (inout == 0) {
        hdr22 = main.findName("aSlideOut2").Begin(); 
    } else { hdr22 = main.findName("aSlideIn2").Begin();}  
}

function fnRunSlider3(id, inout) {
    // Find slider, set text, run story
    var xamlSlider3 = main.FindName("tbSlider3");
    xamlSlider3.setValue("Text", txtArrTitles[id]);
    xamlSlider3.setValue("Visibility", "Visible");
    if (inout == 0) {
        hdr33 = main.findName("aSlideOut3").Begin();
    } else { hdr33 = main.findName("aSlideIn3").Begin(); 
    }
}

function fnRunSlider(sliderid, inout, propname) {
    // hdr = fnRunSlider(3, 0, "(Canvas.Top)")
    // param1: sliderid, param2: 0=out, 1=in, param3: property name
    var slider = "aSlide" + "In" + sliderid ;
    if (inout == 0) { slider = "aSlide" + "Out"  + sliderid }
    var o = main.FindName(slider);
    //alert(slider)
    o.findname(slider)["Storyboard.TargetProperty"] = propname;
    o.findname(slider).begin();
    o = null;
}

function fnLineUpIcons() {

  // line up other icons
    var me2 = tileObjsArr4[2]
    var par2 = s.findName(me2.parent)
    var st2 = s.findName(me2.scaleTransform)
    me2.tweenS.onMotionChanged = function(event) {
        st2.scaleX = event.target._pos
        st2.scaleY = event.target._pos
    }
    //alert(me2.name)
    me2.tweenS = new Tween(new Object(), 's', Tween.strongEaseOut, st2.scaleX, tile_scale_up_to2, time_to_scale_tile)
    me2.tweenY = new Tween(new Object(), 'y', Tween.strongEaseOut, 500, (me2.y + 10), time_to_scale_tile)
    me2.tweenY.start()

    // end line up other icons

}

function fnShowDetails4(id, strVal, strImg) {

    hdr = main.findName("myPic").Visibility = "Visible";
    hdr = main.findName("myPic").Source = imgIconsArr4[ind];

    alert(ind);

    var xamlObj44 = main.FindName("myPic");
    xamlObj44.setValue("Visibility", "Visible");
    alert(imgIconsArr4[ind]);
    xamlObj44.setValue("Source", imgIconsArr4[ind]);
    xamlObj44.setValue("Canvas.Top", tbArr4Top[ind]);
    xamlObj44.setValue("Canvas.Left", 50);
    xamlObj44.setValue("Canvas.ZIndex", 58);
    //xamlObj4.setValue("Width", 50);
}


function tileLeave4(s, e) {

    //time_to_scale_tile=0.7
    var ind = s.name.split("_")[1]
    var me = tileObjsArr4[ind]

    time_to_scale_tile = (tile_scale_up_to - me.scale)

    var par = s.findName(me.parent)
    var st = s.findName(me.scaleTransform)

    // Animate fade out of text
    hdr = main.findName("FadeOut").Begin();

    var u = fnRunSlider2(ind, 1);
 
    par["Canvas.ZIndex"] = 49

    me.tweenS4.stop()
    me.tweenY4.stop()
    diff = st.scaleX - (st.scaleX - me.scale) / 3

    me.tweenS42 = new Tween(new Object(), 's', Tween.strongEaseOut, st.scaleX, me.scale, time_to_scale_tile)
    me.tweenS42.onMotionChanged = function(event) {
        st.scaleX = event.target._pos
        st.scaleY = event.target._pos
    }

    me.tweenS42.onMotionFinished = function(event) {
        par["Canvas.ZIndex"] = me.z
    }

    me.tweenS42.start()
    me.tweenY42 = new Tween(new Object(), 'y', Tween.strongEaseOut, par["Canvas.Top"], 0, time_to_scale_tile)
    me.tweenY42.onMotionChanged = function(event) {
        par["Canvas.Top"] = event.target._pos
    }

    // Set txtBody to default params
    hdr = main.findName("myPic").Visibility = "Collapsed";
    //hdr = fntbBody_Defaults(); 
    
    //Hide all icon images
    fnShowStateIcons(4, 1, ind, layout_iconhide)
    
    // Default image title
    //hdr = main.findName("info").text = "Image Solutions"
    res = fnSetSmallTitles(ind, 0);

    // Reset A titles
    hdr = fnSetATitles();

    navLeave(s, e)
}



function fnShowStateIcons(arNum, IsShow, IconShowId, styleid) {
    // Hide or show icons in a given array
    // assumes naming convention: imgHolder+arraynum+iconnum. Eg: imgHolder4_2"

    var show = "Collapsed"
    var fade = "FadeOutIcon"

    if (IsShow == 1) {
        show = "Visible";
        fade = "FadeInIcon"
    }

    if (styleid == 1) {
        // styleid = 1 (visible/invisible action)
        for (i = 0; i < imgArr4.length; i++) {
            hdr2 = main.findName("imgHolder4_" + i).Visibility = show;
            hdr2 = main.findName("imgReflection4_" + i).Visibility = show;
        }

    }

    // Only fade in/out icons not selected
    if (styleid == 2) {
        if (IsShow == 1) {
            if (IconShowId != 0) { hdr2 = main.findName("FadeInIcon0").Begin(); };
            if (IconShowId != 1) { hdr2 = main.findName("FadeInIcon1").Begin(); };
            if (IconShowId != 2) { hdr2 = main.findName("FadeInIcon2").Begin(); };
            if (IconShowId != 3) { hdr2 = main.findName("FadeInIcon3").Begin(); };
            if (IconShowId != 4) { hdr2 = main.findName("FadeInIcon4").Begin(); };
            if (IconShowId != 5) { hdr2 = main.findName("FadeInIcon5").Begin(); };
            if (IconShowId != 6) { hdr2 = main.findName("FadeInIcon6").Begin(); };            
        } else {
            if (IconShowId != 0) { hdr2 = main.findName("FadeOutIcon0").Begin(); };
            if (IconShowId != 1) { hdr2 = main.findName("FadeOutIcon1").Begin(); };
            if (IconShowId != 2) { hdr2 = main.findName("FadeOutIcon2").Begin(); };
            if (IconShowId != 3) { hdr2 = main.findName("FadeOutIcon3").Begin(); };
            if (IconShowId != 4) { hdr2 = main.findName("FadeOutIcon4").Begin(); };
            if (IconShowId != 5) { hdr2 = main.findName("FadeOutIcon5").Begin(); };
            if (IconShowId != 6) { hdr2 = main.findName("FadeOutIcon6").Begin(); };                                  
        }      
    }

    // Calling icon (tile over) still should be visible
    hdr2 = main.findName("imgHolder4_" + IconShowId).Visibility = "Visible";
    //hdr2 = main.findName("imgHolder4_" + IconShowId).Opacity = 1;
    hdr2 = main.findName("imgReflection4_" + IconShowId).Visibility = "Visible";
}



// ----------------------------------------------------------
// NAVIGATION MENU SECTION
// ----------------------------------------------------------

var colForeground = "#4682B4"
var colBorder = "#4682B4"
var colFill = "#F8F8FF"

function buildNav(s) {
   
    for (i = 0; i < mainNavArr.length; i++) {

        objsArr["nav_" + i] = new Object()
        objsArr["nav_" + i].checkSubTO = 0

        objsArr["sub_nav_" + i] = new Object()

        left_nav_pos = 12       
        main_nav_spacing = 180
        main_nav_width = 160
        main_nav_height = 20

        sub_nav_width = 155
        sub_nav_height = 20
        sub_nav_offset_top = 5
        sub_nav_spacing = 2

        sub_nav_container_width = 160
        sub_nav_container_height = subNavArr[i].length * (sub_nav_height + sub_nav_spacing) + sub_nav_offset_top * 2
        sub_nav_container_offset_top = 20 - sub_nav_container_height

        objsArr["sub_nav_" + i].top = sub_nav_container_offset_top
        objsArr["sub_nav_" + i].height = sub_nav_container_height
        objsArr["sub_nav_" + i].spotY = main_nav_height       

        nav_canvas_str = '<Canvas>'
        //nav_canvas_str += '	<Canvas Name="nav_' + i + '" Canvas.Left="' + (main_nav_spacing * 1) + '" MouseEnter="navEnter" MouseLeave="navLeave">'
        nav_canvas_str += '	<Canvas Name="nav_' + i + '" Canvas.Left="' + left_nav_pos + '"  >'
        nav_canvas_str += '		<Rectangle Name="rnav_' + i + '" Visibility="Collapsed" Fill="' + colFill + '" Height="' + main_nav_height + '" Width="' + main_nav_width + '" Opacity="0.4"></Rectangle>'
        nav_canvas_str += '		<TextBlock Name="tbnav_' + i + '" Visibility="Collapsed" Canvas.Left="8" Canvas.Top="4"  Width="' + main_nav_width + '" TextWrapping="Wrap" FontFamily="Verdana" FontSize="12">' + mainNavArr[i] + '</TextBlock>'
        nav_canvas_str += '	</Canvas>'

        nav_canvas_str += '	<Canvas>' //extra canvas for clip       (Border) Stroke="Black"
        nav_canvas_str += '		<Canvas Name="sub_nav_' + i + '"  Canvas.Left="' + left_nav_pos + '" Canvas.Top="' + sub_nav_container_offset_top + '" MouseEnter="subConEnter" >'
        nav_canvas_str += '			<Rectangle Height="' + sub_nav_container_height + '" Width="' + sub_nav_container_width + '" Opacity="0.84"></Rectangle>'

        for (j = 0; j < subNavArr[i].length; j++) {
            nav_canvas_str += '		<Canvas Name="sub_nav_' + i + '_' + j + '" Canvas.Left="5" Canvas.Top="' + ((sub_nav_height + sub_nav_spacing) * j + sub_nav_offset_top) + '" MouseEnter="subEnter" MouseLeave="subLeave" MouseLeftButtonDown="navMenuPress">'
            nav_canvas_str += '			<Rectangle Stroke="' + colBorder + '" Height="' + sub_nav_height + '" Width="' + sub_nav_width + '" Opacity="0.84"></Rectangle>'
            nav_canvas_str += '			<TextBlock Canvas.Left="8" Canvas.Top="4" Cursor="Hand" Foreground="' + colForeground + '" Width="' + sub_nav_width + '" TextWrapping="Wrap" FontFamily="Verdana" FontSize="11">' + subNavArr[i][j] + '</TextBlock> '
            nav_canvas_str += '		</Canvas>'
        }

        nav_canvas_str += '		</Canvas>'
        nav_canvas_str += '		<Canvas.Clip>'
        //nav_canvas_str += '			<RectangleGeometry Rect="' + (main_nav_spacing * i) + ',' + main_nav_height + ',' + sub_nav_container_width + ',' + sub_nav_container_height + '" />'
        nav_canvas_str += '			<RectangleGeometry Rect="' + left_nav_pos + ',' + main_nav_height + ',' + sub_nav_container_width + ',' + sub_nav_container_height + '" />'
        
        nav_canvas_str += '		</Canvas.Clip>'
        nav_canvas_str += '	</Canvas>'

        nav_canvas_str += '</Canvas>'

        //nav_canvas_str+=''
        //nav_canvas_str+=''

        xamlTags = plugin.content.createFromXaml(nav_canvas_str)
        s.findName("mainNavHolder").children.add(xamlTags)

    }

}



function navEnter(s, e, id) {

    // Select nav menu to display
    //alert(id)
    var nav_name = "nav_0"
    switch (id) {
        case "0": title1 = 'Management';
            nav_name = "nav_0"
            navLeave(s, e, "nav_1")
            navLeave(s, e, "nav_2") 
            navLeave(s, e, "nav_3")
            navLeave(s, e, "nav_4")  
            navLeave(s, e, "nav_5")                       
            break;
        case "1": title1 = 'Solutions';
            nav_name = "nav_1"
            navLeave(s, e, "nav_0")
            navLeave(s, e, "nav_2")
            navLeave(s, e, "nav_3")
            navLeave(s, e, "nav_4")
            navLeave(s, e, "nav_5")                    
            break;
        case "2": title1 = 'FAQs';
            nav_name = "nav_2"
            navLeave(s, e, "nav_0")
            navLeave(s, e, "nav_1")
            navLeave(s, e, "nav_3")
            navLeave(s, e, "nav_4")
            navLeave(s, e, "nav_5")             
            break;
        case "3": title1 = 'Contact Us';
            nav_name = "nav_3"
            navLeave(s, e, "nav_0")
            navLeave(s, e, "nav_1")
            navLeave(s, e, "nav_2")
            navLeave(s, e, "nav_4")
            navLeave(s, e, "nav_5")              
            break;
        case "4": title1 = 'Other';
            nav_name = "nav_4"
            navLeave(s, e, "nav_0")            
            navLeave(s, e, "nav_1")
            navLeave(s, e, "nav_2")
            navLeave(s, e, "nav_3")
            navLeave(s, e, "nav_5")  
            break;
        default: result = ' ';
    }
  
    navEnterAction(s, e, id, nav_name)

}

function navEnterAction(s, e, id, nav_name) {

    // Determine settings based on calling image
    //alert("Hello navEnter s:" + s.name);
    ss = s.findName("mainNavHolder")
    clearTimeout(objsArr[nav_name].checkSubTO)
    var subRef = s.findName("sub_" + nav_name)
    //hdr2 = s.findName("r" + nav_name).Visibility = "Visible";
    //hdr2 = s.findName("tb" + nav_name).Visibility = "Visible";
    subRef.visibility = "Visible"
    var subRefObj = objsArr["sub_" + nav_name]
    if (subRefObj.tweenY2) {
        subRefObj.tweenY2.stop()
    }

    var cur_prop = subRef["Canvas.Top"]

    subRefObj.tweenY = new Tween(new Object(), 'y', Tween.regularEaseOut, cur_prop, subRefObj.spotY, 0.5)

    subRefObj.tweenY.onMotionChanged = function(event) {
        subRef["Canvas.Top"] = event.target._pos
    }

    subRefObj.tweenY.start()

}

function navHomeAction(s) {

    // Determine settings for home page
    //alert("Hello navHomeAction");

    //ss = s.findName("mainNavHolder")
    //alert(s.name)
    nav_name = "nav_5"
    clearTimeout(objsArr[nav_name].checkSubTO)
    var subRef = s.findName("sub_" + nav_name)
    //alert("sub_" + nav_name)
    subRef.visibility = "Visible"
    var subRefObj = objsArr["sub_" + nav_name]
    if (subRefObj.tweenY2) {
        subRefObj.tweenY2.stop()
    }

    var cur_prop = subRef["Canvas.Top"]

    subRefObj.tweenY = new Tween(new Object(), 'y', Tween.regularEaseOut, cur_prop, subRefObj.spotY, 0.5)

    subRefObj.tweenY.onMotionChanged = function(event) {
        subRef["Canvas.Top"] = event.target._pos
    }

    subRefObj.tweenY.start()
}


function navLeaveX(s, e) {
    
    var name_str = s.name
    objsArr[s.name].checkSubTO = setTimeout("checkSub('" + name_str + "')", menu_hide_time)

}

function navLeave(s, e, nav_name) {
    
    //alert("Hello navLeave s:" + s.name);
    //var name_str = s.name
    var name_str = nav_name //"nav_0"
    objsArr[nav_name].checkSubTO = setTimeout("checkSub('" + name_str + "')", menu_hide_time)
    hdr2 = s.findName("r" + nav_name).Visibility = "Collapsed";
    hdr2 = s.findName("tb" + nav_name).Visibility = "Collapsed";
    
}

function checkSub(str) {


    var mainRef = main.findName(str)
    var subRef = main.findName("sub_" + str)
    mainRef.children.getItem(0).fill = "#CCC"


    var subRefObj = objsArr["sub_" + str]

    subRefObj.tweenY.stop()

    var cur_prop = subRef["Canvas.Top"]

    subRefObj.tweenY2 = new Tween(new Object(), 'y', Tween.elasticEaseOut, cur_prop, subRefObj.top, 0.2)

    subRefObj.tweenY2.onMotionChanged = function(event) {
        subRef["Canvas.Top"] = event.target._pos
    }

    subRefObj.tweenY2.start()

}


function subConEnter(s, e) {
    var name_to_find = s.name.substr(4, s.name.length)
    clearTimeout(objsArr[name_to_find].checkSubTO)
}

function subConLeave(s) {
    var name_to_find = s.name.substr(4, s.name.length)
    objsArr[name_to_find].checkSubTO = setTimeout("checkSub('" + name_to_find + "')", menu_hide_time)
    //objsArr[name_to_find].checkSubTO = setTimeout("checkSub('" + name_to_find + "')", 10)
}


function subEnter(s, e) {
    s.children.getItem(0).fill = colFill
    s.children.getItem(1).foreground = "#000"
    s.children.getItem(1).FontSize = "11"
}

function subLeave(s, e) {
    //s.children.getItem(0).effect = "Fade(duration=0.2);Alpha(style=0,opacity=70);Shadow(color='#777777', Direction=135, Strength=5)"
    s.children.getItem(0).fill = "transparent"
    s.children.getItem(1).foreground = colForeground //"#FFF"
    s.children.getItem(1).FontSize = "11"
}




function whenMouseMoves(s, e) {
    _root_xmouse = e.getPosition(null).x
    _root_ymouse = e.getPosition(null).y
    //window.status=_root_xmouse+" - "+_root_ymouse
}


function navMenuPress(s) {

    var hl = ""
    var id = s.name.split("_")[1]

    var menuid = s.name.split("_")[2]
    var submenuid = s.name.split("_")[3]
    
    //alert("menuid: " + menuid)
    //alert("submenuid: " + submenuid)
    //alert(hl)
    hl = hlroot + subNavLinksArr[menuid][submenuid]
    //alert(hl)
    window.location = hl
}

function MouseEnter(sender, args) {

    alert(sender.name);
    sender.findName("ColorAnimationItem2").Begin();
     
    }