﻿// JScript File
// global variables
var StoreLocation;

function GetDate(CtrlName)
{
/****************************************************

Use Javascript method (window.open) to PopUp a new window 
which contain a Calendar Control. In the meantime, we'll 
pass the Parent Form Name and Request Control Name in the QueryString!

*****************************************************/

ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
}

function CheckWindow()
{
ChildWindow.close();
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function initialize(){
    preloadImages();
    localize();
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
function getlocationfromurl(){
    //this function looks for loc= in the calling url,
    //then pieces together the two letters representing the store location
    temp = new String(location.search);
    stringindex = temp.indexOf("loc=",0)    
    letter1 = temp.charAt(stringindex+4);
    //letter1 = 'r'
    letter2 = temp.charAt(stringindex+5);
   // letter2 = 'c'
    StoreLocation = letter1 + letter2;
    //alert(StoreLocation);
}

function localize(){

	//get store location code from URL
	getlocationfromurl();
	
	//wait for stuff
	if (document.images && (preloadFlag == true)) {

	//These are the header image and the top image of the side menu with store location in text
	switch(StoreLocation){
	    case "rc":
	        //localize the necessary graphics...
	        document['HeaderGraphic'].src="../images/ranchocucamonga/other/header_loc_rc.jpg"
	        document['SideMenuHeader'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc1.jpg"
	        document['SideMenuBottom'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_07.jpg"
	       	document['JJTop_what'].src = "../images/ranchocucamonga/Menus/Top/JJTop_what.jpg"
			document['JJTop_location'].src = "../images/ranchocucamonga/Menus/Top/JJTop_location.jpg"

			//These next five will probably be the same for all locations, but we'll do 'em this way
	        //any way
	        document['maplinkimage'].src="../images/ranchocucamonga/Menus/Side/smenu_rc_map.jpg"
	        document['optionslinkimage'].src="../images/ranchocucamonga/Menus/Side/smenu_rc_options.jpg"
	        document['schedulerlinkimage'].src="../images/ranchocucamonga/Menus/Side/smenu_rc_schedule-over.jpg"
	        document['photolinkimage'].src="../images/ranchocucamonga/Menus/Side/smenu_rc_photo.jpg"
	        document['downloadlinkimage'].src="../images/ranchocucamonga/Menus/Side/smenu_rc_download.jpg"
	        //Now we change the accompanying links to match the store location...
	        document.getElementById('maplink').href="../RanchoCucamonga/rancho_locmap.html"
	        document.getElementById('optionslink').href="../RanchoCucamonga/rancho_options.html"
	        document.getElementById('schedulerlink').href="DateSchedule.aspx?loc=rc"
	        document.getElementById('photoslink').href="../RanchoCucamonga/rancho_photos.html"
	        document.getElementById('downloadlink').href="../RanchoCucamonga/rancho_downloads.html"
			document['Arena1'].src = "../images/ranchocucamonga/other/Arena1.jpg"  //interesting. when these 2 calls appear earlier in the order it breaks the side menu init
			document['Arena2'].src = "../images/ranchocucamonga/other/Arena2.jpg"
			//if (document.title == "JJ Scheduler: Credit Card Process Start"){ //not sure this test works yet name= or id= ???
            //       document.getElementByID('LinkpointDataForm').Hidden1.value = "1164737" //notsure this call works yet. Linkpoint store number
                   //document.forms[0].Hidden2.value = "eci"
            //       document.getElementByID('LinkpointDataForm').Hidden3.value = "75.00" //amount to charge
            //       document.getElementByID('LinkpointDataForm').Hidden6.value = "rc" //JJ location code
	        //}	
			break;
	    case "sd":
	        //first localize the necessary graphics...
	        document['HeaderGraphic'].src="../images/sandimas/other/header_loc_sd.jpg"
	        document['SideMenuHeader'].src = "../images/sandimas/Menus/Side/smenu_sd1.jpg"
	        document['SideMenuBottom'].src = "../images/sandimas/Menus/Side/smenu_sd_07.jpg"
	       	document['JJTop_what'].src = "../images/sandimas/Menus/Top/JJTop_what.jpg"
			document['JJTop_location'].src = "../images/sandimas/Menus/Top/JJTop_location.jpg"

		   //These next five will probably be the same for all locations, but we'll do 'em this way
	        //any way
	        document['maplinkimage'].src="../images/sandimas/Menus/Side/smenu_sd_map.jpg"
	        document['optionslinkimage'].src="../images/sandimas/Menus/Side/smenu_sd_options.jpg"
	        document['schedulerlinkimage'].src="../images/sandimas/Menus/Side/smenu_sd_schedule-over.jpg"
	        document['photolinkimage'].src="../images/sandimas/Menus/Side/smenu_sd_photo.jpg"
	        document['downloadlinkimage'].src="../images/sandimas/Menus/Side/smenu_sd_download.jpg"
	        //Now we change the accompanying links to match the store location...
	        document.getElementById('maplink').href="../SanDimas/sandimas_locmap.html"
	        document.getElementById('optionslink').href="../SanDimas/sandimas_options.html"
	        document.getElementById('schedulerlink').href="DateSchedule.aspx?loc=sd"
	        document.getElementById('photoslink').href="../SanDimas/sandimas_photos.html"
	        document.getElementById('downloadlink').href="../SanDimas/sandimas_download.html"
			document['Arena1'].src = "../images/sandimas/other/Arena1.jpg"
			document['Arena2'].src = "../images/sandimas/other/Arena2.jpg"
			
			//if (document.title == "JJ Scheduler: Credit Card Process Start"){
			//alert("Here we Are!!!!");
           // var inputs = document.getElementByID('LinkpointDataForm').elements
			//document.write(inputs);
            //document.LinkpointDataForm.Hidden1.value = "Manalapan1" //Linkpoint store number
            //document.getElementByID('LinkpointDataForm').elements.Hidden1.value = "Manalapan1" //Linkpoint store number
            //document.forms[0].Hidden1.value = "Manalapan1"
            //document.forms[0].Hidden1.value = "1164737"
            //document.forms[0].Hidden3.value = "0.01" //amount to charge
            //document.forms[0].Hidden6.value = "sd" //JJ location code
	        // }	
			break;
	    default:
	    	//document['JJTop_what'].src = "../images/ranchocucamonga/Menus/Top/JJTop_what.jpg"
			//document['JJTop_location'].src = "../images/ranchocucamonga/Menus/Top/JJTop_location.jpg"

	}// close switch()
	}//close if(images && preload)
	
	//if (document.title == "JJ Scheduler: Credit Card Process Start"){
	//    CCLocalize();
	//}
	
}//close localize()


function CCLocalize(){
	        //dynamically set variables for credit card processing based on which store is active
	    	//alert(document.forms[0].id);
	    	
	    	//document.GetFormByID("LinkpointDataForm");	
			//get store location code from URL
			getlocationfromurl();

			
	    	
	        switch (StoreLocation){
	            case "rc":
                   document.forms[0].Hidden1.value = "1164737" //Linkpoint store number
                   //document.forms[0].Hidden2.value = "eci"
                   document.forms[0].Hidden3.value = "75.00" //amount to charge
                   document.forms[0].Hidden6.value = "rc" //JJ location code
					break;
	            case "sd":
                   document.forms[0].Hidden1.value = "1164737"
                   //document.forms[0].Hidden2.value = "eci"
				   document.forms[0].Hidden3.value = "0.01"
                   document.forms[0].Hidden6.value = "sd"
					break;
                default:
            } //close switch
            //force the variable set without the switch
            //document.forms[0].Hidden1.value = "1164737" //Linkpoint store number
            //document.forms[0].Hidden3.value = "0.01" 
            //document.forms[0].Hidden6.value = "sd"

} //close CCLocalize


var preloadFlag = false;
function preloadImages() {
	if (document.images) { //this tests whether the page has any images in it
		JTop_home_over = newImage("../images/JTop_home-over.jpg");
		JTop_whatis_over = newImage("../images/JTop_whatis-over.jpg");
		JTop_sched_over = newImage("../images/JTop_sched-over.jpg");
		JTop_location_over = newImage("../images/JTop_location-over.jpg");
		JTop_gallery_over = newImage("../images/JTop_gallery-over.jpg");
		preloadFlag = true;
	}	
}

var popUp; 

function OpenCalendar(idname, postBack)
{
	popUp = window.open('calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=170,height=240,left=200,top=250');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}		
//Takes one argument: an id for a menu item on the side menu. It figures out how to find the highlight image based on menu item, and store location
function highlightsidemenuitem() {
	 if (document.images && (preloadFlag == true)) {
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				//var menuitem = document[highlightsidemenuitem.arguments[0]]; //read the (only) argument of the function which is the menu item to highlight
		switch (document[highlightsidemenuitem.arguments[0]]) {
			case maplinkimage:
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				switch(StoreLocation) {
					case "rc":
						document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_map-over.jpg" //rancho map-over blah blah .jpg
						break;
					case "sd":
						document['maplinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_map-over.jpg" //san dimas map-over blah blah .jpg
						break;
					default:
				}
				break;
			case optionslinkimage:
				switch(StoreLocation) {
					case "rc":
						document['optionslinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_options-over.jpg"
						break;
					case "sd":
						document['optionslinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_options-over.jpg"
						break;
					default:
				}
				break;
			case schedulerlinkimage:
				switch(StoreLocation) {
					case "rc":
						document['schedulerlinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_schedule-over.jpg"
						break;
					case "sd":
						document['schedulerlinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_schedule-over.jpg"
						break;
					default:
				}
				break;
			case photolinkimage:
				switch(StoreLocation) {
					case "rc":
						document['photolinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
						break;
					case "sd":
						document['photolinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_photo-over.jpg"
						break;
					default:
				}
				break;
			case downloadlinkimage:
				switch(StoreLocation) {
					case "rc":
						document['downloadlinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_download-over.jpg"
						break;
					case "sd":
						document['downloadlinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_download-over.jpg"
						break;
					default:
				}
				break;
			default:
		} //close switch
	} //close if
} //close function
function unhighlightsidemenuitem() {
	 if (document.images && (preloadFlag == true)) {
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				//var menuitem = document[highlightsidemenuitem.arguments[0]]; //read the (only) argument of the function which is the menu item to highlight
		switch (document[unhighlightsidemenuitem.arguments[0]]) {
			case maplinkimage:
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				switch(StoreLocation) {
					case "rc":
						document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_map.jpg" //rancho map-over blah blah .jpg
						break;
					case "sd":
						document['maplinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_map.jpg" //san dimas map-over blah blah .jpg
						break;
					default:
				}
				break;
			case optionslinkimage:
				switch(StoreLocation) {
					case "rc":
						document['optionslinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_options.jpg"
						break;
					case "sd":
						document['optionslinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_options.jpg"
						break;
					default:
				}
				break;
			case schedulerlinkimage:
				switch(StoreLocation) {
					case "rc":
						document['schedulerlinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_schedule.jpg"
						break;
					case "sd":
						document['schedulerlinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_schedule.jpg"
						break;
					default:
				}
				break;
			case photolinkimage:
				switch(StoreLocation) {
					case "rc":
						document['photolinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo.jpg"
						break;
					case "sd":
						document['photolinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_photo.jpg"
						break;
					default:
				}
				break;
			case downloadlinkimage:
				switch(StoreLocation) {
					case "rc":
						document['downloadlinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_download.jpg"
						break;
					case "sd":
						document['downloadlinkimage'].src = "../images/sandimas/Menus/Side/smenu_sd_download.jpg"
						break;
					default:
				}
				break;
			default:
		} //close Switch
	} //close if
} //close function
//Takes one argument: an id for a menu item on the top menu. It figures out how to find the highlight image based on menu item, and store location
function highlighttopmenuitem() {
	 if (document.images && (preloadFlag == true)) {
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				//var menuitem = document[highlightsidemenuitem.arguments[0]]; //read the (only) argument of the function which is the menu item to highlight
		switch (document[highlighttopmenuitem.arguments[0]]) {
			case JJTop_what:
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				switch(StoreLocation) {
					case "rc":
						document['JJTop_what'].src = "../images/ranchocucamonga/Menus/Top/JJTop_what-over.jpg" //rancho map-over blah blah .jpg
						break;
					case "sd":
						document['JJTop_what'].src = "../images/sandimas/Menus/Top/JJTop_what-over.jpg" //san dimas map-over blah blah .jpg
						break;
					default:
				}
				break;
			case JJTop_location:
				switch(StoreLocation) {
					case "rc":
						document['JJTop_location'].src = "../images/ranchocucamonga/Menus/Top/JJTop_location-over.jpg"
						break;
					case "sd":
						document['JJTop_location'].src = "../images/sandimas/Menus/Top/JJTop_location-over.jpg"
						break;
					default:
				}
				break;

			default:
		}
	} 
}
function unhighlighttopmenuitem() {
		 if (document.images && (preloadFlag == true)) {
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				//var menuitem = document[highlightsidemenuitem.arguments[0]]; //read the (only) argument of the function which is the menu item to highlight
		switch (document[unhighlighttopmenuitem.arguments[0]]) {
			case JJTop_what:
				//document['maplinkimage'].src = "../images/ranchocucamonga/Menus/Side/smenu_rc_photo-over.jpg"
				switch(StoreLocation) {
					case "rc":
						document['JJTop_what'].src = "../images/ranchocucamonga/Menus/Top/JJTop_what.jpg" //rancho map-over blah blah .jpg
						break;
					case "sd":
						document['JJTop_what'].src = "../images/sandimas/Menus/Top/JJTop_what.jpg" //san dimas map-over blah blah .jpg
						break;
					default:
				}
				break;
			case JJTop_location:
				switch(StoreLocation) {
					case "rc":
						document['JJTop_location'].src = "../images/ranchocucamonga/Menus/Top/JJTop_location.jpg"
						break;
					case "sd":
						document['JJTop_location'].src = "../images/sandimas/Menus/Top/JJTop_location.jpg"
						break;
					default:
				}
				break;

			default:
		}
	}
}


