var oldHomePage = "http://www.justscratchit.com/classic/index.html";

var slidesPlayed = false;
var increment = 1;
var refreshRate = 50;

var imgCount = 36;
var liCount = 12;
var imgTyp = ".jpg";
var imgBaseName = "JSI-Slider-Images_";
var imgFolder = "cards_repository/";
var selectColor = '#b76e14';
var highlightColor = 'black';
var hoverColor = '#CBDB2B';
var bckColor = '#CBDB2B';
var hoverColorOrig = '';

var samplesDir = 'imagesamples';
var fileExt = '.jpg';

var lbvuerstates = new Array('f','s','b');
var lbvuersorder = new Array('img_pre','img_act','img_nxt');
var lbvuerdelim = '_';

//HAVE TO USE JS to overcome a css problem in IE7							
//ie7 has a bug that does not hide a page element fully with display:none so 
//below is the code needed to strip out the offfending code and replace with the new code
var popNavs = {
	navAnatomy:{ itsId:'popnav-scratchanat',
			 	 itsHTML:'<ul><li><a href=\"#\" id=\"vu_popanatomy\">A Just Scratch It!&reg; Scratcher</a></li><li><a href=\"#\" id=\"vu_popdesign\">Design &#62;</a><ul><li><a href=\"#\" id=\"vu_popdesign-seeing\">Seeing is Believing</a></li>	<li><a href=\"#\" id=\"vu_popdesign-mockup\">Get a Free Mockup!</a></li><li><a href=\"#\" id=\"vu_popdesign-specs\">Artwork Specs</a></li>	<li><a href=\"#\" id=\"vu_popdesign-custom\">Custom Shapes</a></li>	</ul></li><li><a href=\"#\" id=\"vu_poplayouts\">Prize Layout &#62;</a><ul><li><a href=\"#\" id=\"vu_poplayouts-qty500\">500 Qty</a></li>	<li><a href=\"#\" id=\"vu_poplayouts-qty1000\">1,000 Qty</a></li>	<li><a href=\"#\" id=\"vu_poplayouts-qty2500\">2,500 Qty</a></li>	<li><a href=\"#\" id=\"vu_poplayouts-qty5000\">5,000 Qty</a></li>	<li><a href=\"#\" id=\"vu_poplayouts-qty10000\">10,000 Qty</a></li>	<li><a href=\"#\" id=\"vu_poplayouts-qtylarge\">Large Quantities</a></li>	</ul></li><li><a href=\"#\" id=\"vu_popgames\">Choose your game &#62;</a><ul><li><a href=\"#\" id=\"vu_popgames-scratchwin\">Scratch ONE & WIN!</a></li>	<li><a href=\"#\" id=\"vu_popgames-matchwin\">Match & WIN!</a></li>	<li><a href=\"#\" id=\"vu_popgames-createown\">Create your own</a></li>	</ul></li><li><a href=\"#\" id=\"vu_poppricingsizes\">Pricing and Sizes</a></li><li><a href=\"#\" id=\"vu_popvariabledata\">Variable Data?</a></li><li><a href=\"#\" id=\"vu_popbackside\">Backside</a></li></ul>'},
	navStuff:{ 	 itsId:'popnav-freestuff',
			 	 itsHTML:'<ul><li><a href=\"#\" id=\"vu_popidea\">Scratcher Ideas</a></li><li><a href=\"#\" id=\"vu_popfaq\">FAQ&#8217;s &#62;</a><ul><li><a href=\"#\" id=\"vu_popfaq-pt1\">FAQ\'s Part 1</a></li><li><a href=\"#\" id=\"vu_popfaq-pt2\">FAQ\'s Part 2</a></li></ul></li><li><a href=\"#\" id=\"vu_popsuggest\">Prize Suggestions</a></li><li><a href=\"#\" id=\"vu_poptestimonial\">Testimonials &#62;</a><ul><li><a href=\"#\" id=\"vu_poptestimonial-pt1\">Testimonials Part 1</a></li><li><a href=\"#\" id=\"vu_poptestimonial-pt2\">Testimonials Part 2</a></li><li><a href=\"#\" id=\"vu_poptestimonial-pt3\">Testimonials Part 3</a></li><li><a href=\"#\" id=\"vu_poptestimonial-pt4\">Testimonials Part 4</a></li></ul></li><li><a href=\"#\" id=\"vu_popaward\">Awards</a></li><li><a href=\"#\" id=\"vu_popupload\">Upload Files</a></li></ul>'},
	navStart:{ 	 itsId:'popnav-start',
			 	 itsHTML:'<ul><li><a href=\"#\" id=\"vu_popfreemockup\">Request Mockup</a></li><li><a href=\"#\" id=\"vu_popreqquote\">Request Quote</a></li></ul>'},
	popNavId: 'popnav-holder'
}

							


window.onload = initializePage;
window.onresize = centerPage;
document.onclick = _dealWithOnclick;
document.onmouseover = _dealWithMover;
document.onmouseout = _dealWithMout;
//window.onchange = _dealWithOnChange;

function _doSampleCatagoryChg(){
	theLBSelectObj = document.getElementById('samplecat');
	chosenGrp = theLBSelectObj.selectedIndex;
	initializeVuer(chosenGrp);
}


function getFormFields(aForm){

alert('here');

	if(aFrom != undefined){
		allInputFields = aForm.getElementsByTagName('INPUT');
		var inputValsArr = new Array();
		for (var anElem in allInputFields){
			(allInputFields[anElem].value != '' || allInputFields[anElem].value != null) ? inputValsArr.push([allInputFields[anElem].id,allInputFields[anElem].value]): '';
		}
		return inputValsArr;
	}
}


function buildFormFields(aForm,formDetails){
	allInputFields = aForm.getElementsByTagName('INPUT');
	
	for(i=0; i < formDetails.length; i++){
	
		thisDetailNam = formDetails[i][0];
		uOffset = (thisDetailNam.lastIndexOf('_') + 1);
		thisDetailNamLength = thisDetailNam.length;
    	thisDetailName = thisDetailNam.substring(uOffset,thisDetailNamLength);

		thisDetailVal = formDetails[i][1];
		
		if(thisDetailVal != '' && thisDetailVal != undefined && thisDetailVal != null){
	
			for(j=0; j < allInputFields.length; j++){
				
				inputFieldId = allInputFields[j].id;
				ifOffset = (inputFieldId.lastIndexOf('_') + 1);
				inputFieldIdLength = inputFieldId.length;
		    	inputFieldIdName = inputFieldId.substring(ifOffset,inputFieldIdLength);
				
				if(thisDetailName == inputFieldIdName){
					allInputFields[j].value = thisDetailVal;
				}
			}
		}
	}
}


function changeAllInputs(anObj){
	var formDetails = new Array();
	formDetails.push([anObj.id,anObj.value]);

//put code here to duplicate form fields into other forms	
	allForms = document.getElementsByTagName('FORM');
	buildFormFields(allForms[0],formDetails);
	buildFormFields(allForms[1],formDetails);
	buildFormFields(allForms[2],formDetails);
}

function checkform(theForm){
    var why = "";
	formName = theForm.name;
	allInputFields = theForm.getElementsByTagName('INPUT');
	
/*
	atLeastOneFilled = true;
	atLeastOneFilled = false;
	for(i=0; i<allInputFields.length;i++){
		thisElem = allInputFields[i];
		thisElemId = thisElem.id;
		thisElemVal = thisElem.value;
		thisLabelElem = getLabelElem(thisElem);	
		thisElemNam = getInnerText(thisLabelElem);
		if(thisElemId.lastIndexOf('_email') > -1 || thisElemId.lastIndexOf('_phone') > -1){
			if(thisElemVal.length != 0){
				atLeastOneFilled = true;
			}		
		}
	}

	if(atLeastOneFilled == false){
		for(i=0; i<allInputFields.length;i++){
			thisElem = allInputFields[i];
			thisElemId = thisElem.id;
			thisElemVal = thisElem.value;
			thisLabelElem = getLabelElem(thisElem);	
			thisElemNam = getInnerText(thisLabelElem);
			if(thisElemId.lastIndexOf('_email') > -1 || thisElemId.lastIndexOf('_phone') > -1){
				changeElemColor(thisLabelElem,'red');
			}
		}
		why += 'At least one form of contact info is required!\n\n';
	}
*/





	for(i=0; i<allInputFields.length;i++){
		thisElem = allInputFields[i];
		thisElemId = thisElem.id;
		thisElemVal = thisElem.value;
		thisLabelElem = getLabelElem(thisElem);	
		thisElemNam = getInnerText(thisLabelElem);


		if (thisElemId.lastIndexOf('_firstname') > -1){
			newText = isEmpty(thisElemVal,thisElemNam)
			if (newText != ""){
				why += newText;
				changeElemColor(thisLabelElem,'red');
			}else{
				changeElemColor(thisLabelElem,'#CBDB2B');
			}

		}else if(thisElemId.lastIndexOf('_lastname') > -1){
			newText = isEmpty(thisElemVal,thisElemNam)
			if (newText != ""){
				why += newText;
				changeElemColor(thisLabelElem,'red');
			}else{
				changeElemColor(thisLabelElem,'#CBDB2B');
			}

		}else if(thisElemId.lastIndexOf('_email') > -1){
			newText = checkEmail(thisElemVal,thisElemNam);
			if (newText != ""){
				why += newText;
				changeElemColor(thisLabelElem,'red');
			}else{
//				if(atLeastOneFilled == true){
					changeElemColor(thisLabelElem,'#CBDB2B');
//				}
			}

		}else if(thisElemId.lastIndexOf('_project') > -1){
			newText = isEmpty(thisElemVal,thisElemNam);
			if (newText != ""){
				why += newText;
				changeElemColor(thisLabelElem,'red');
			}else{
//				if(atLeastOneFilled == true){
					changeElemColor(thisLabelElem,'#CBDB2B');
//				}
			}

		}else if(thisElemId.lastIndexOf('_phone') > -1){
			newText = checkPhone(thisElemVal,thisElemNam);
			if (newText != ""){
				why += newText;
				changeElemColor(thisLabelElem,'red');
			}else{
//				if(atLeastOneFilled == true){
					changeElemColor(thisLabelElem,'#CBDB2B');
//				}
			}
		}










		if(formName == 'samples_form'){
			if (thisElemId.lastIndexOf('_address1') > -1){
				newText = isEmpty(thisElemVal,thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if(thisElemId.lastIndexOf('_city') > -1){
				newText = isEmpty(thisElemVal,thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if(thisElemId.lastIndexOf('_zip') > -1){
				newText = checkZip(thisElemVal,thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}
		}
	}

	allSelectFields = theForm.getElementsByTagName('SELECT');
	//theForm.choose.selectedIndex
	for(i=0; i<allSelectFields.length;i++){
		thisElem = allSelectFields[i];
		thisElemId = thisElem.id;
		thisElemVal = thisElem.value;
		thisLabelElem = getLabelElem(thisElem);	
		thisElemNam = getInnerText(thisLabelElem);
		
		if(formName == 'samples_form'){
			if (thisElemId.lastIndexOf('_state') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}
		}else if(formName == 'mockup_form'){
			if (thisElemId.lastIndexOf('_cardsize') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_projqty') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_theme') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_needby') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_logo') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_images') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}
		}else if(formName == 'quote_form'){
			if (thisElemId.lastIndexOf('_cardsize') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_projqty') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_printing') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_needby') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_prizelevels') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}else if (thisElemId.lastIndexOf('_variable') > -1){
				newText = checkDropdown(thisElem.selectedIndex, thisElemNam);
				if (newText != ""){
					why += newText;
					changeElemColor(thisLabelElem,'red');
				}else{
					changeElemColor(thisLabelElem,'#CBDB2B');
				}
			}
		}
	}
    if (why != "") {
       alert(why);
       return false;
    }else{
		uploadField01 = document.getElementById('fileupload_01').value;
		uploadField02 = document.getElementById('fileupload_02').value;
		uploadField03 = document.getElementById('fileupload_03').value;
		uploadField04 = document.getElementById('fileupload_04').value;
	    if(uploadField01 != "" || uploadField02 != "" || uploadField03 != "" || uploadField04 != "")
	    {
		   subBut = document.getElementById('upload_submit_p');
		   subBut.style.display = 'none';
	    }else{
			alert("Please select some files to upload...Thanks!");
	       return false;
	    }
    }
//alert(typeof(uploadField01));
}

// email
function checkEmail (strng, aFieldName) {

	var error="";
	if (strng != "") {
		//	if (strng == "") {
		//	   error = "Please enter an email address for - \"" + aFieldName +  "\" - field.\n\n";
		//	}
		
	    var emailFilter=/^.+@.+\..{2,3}$/;
	    if (!(emailFilter.test(strng))) { 
	       error = "Please enter a valid email address for - \"" + aFieldName +  "\" - field.\n\n";
	    }
    }else{

	    error = "The mandatory text field - \"" + aFieldName +  "\" - has not been filled in.\n\n"

		/*
		test email for illegal characters
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters for - \"" + aFieldName +  "\" - field.\n\n";
        }
        */
	}
	return error;    
}


// phone number - strip out delimiters and check for 10 digits
function checkPhone (strng, aFieldName) {
	var error = "";
	if (strng != "") {
		//if (strng == "") {
		//   error = "A Phone number for - \"" + aFieldName +  "\" - is needed.\n\n";
		//}
	
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	    if (isNaN(parseInt(stripped))) {
			error = "Phone number for - \"" + aFieldName +  "\" - contains illegal characters.\n\n";
	    }
	    if (!(stripped.length == 10)) {
			error = "Phone number for - \"" + aFieldName +  "\" - is the wrong length. Make sure you included an area code.\n\n";
	    } 
	}else{
	
	    error = "The mandatory text field - \"" + aFieldName +  "\" - has not been filled in.\n\n"
	
	}
	return error;
}

// zip code - strip out delimiters and check for 5 or 9 digits
function checkZip (strng, aFieldName) {
var error = "";
if (strng == "") {
   error = "A Zip number for - \"" + aFieldName +  "\" - is needed.\n\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "Zip number for - \"" + aFieldName +  "\" - contains illegal characters.\n\n";
  
    }
    if (!(stripped.length == 5 || stripped.length == 9)) {
	error = "Zip number for - \"" + aFieldName +  "\" - is the wrong length.\n\n";
    } 
return error;
}







// non-empty textbox
function isEmpty(strng, aFieldName) {
	var error = "";
	if (strng.length == 0) {
	     error = "The mandatory text field - \"" + aFieldName +  "\" - has not been filled in.\n\n"
	}else{
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]\/]/
		if (strng.match(illegalChars)) {
			error = "The field contains illegal characters for - \"" + aFieldName +  "\".\n\n";
		}
	}
	return error;	  
}









// was textbox altered
function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n\n";
  }
return error;
}

// exactly one radio button is chosen
function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n\n";
    }
return error;
}

// valid selector from dropdown list
function checkDropdown(choice, aFieldName) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option for - \"" + aFieldName +  "\" - drop-down list.\n\n";
    }    
return error;
}    

function getLabelElem(anElem){
	theParentNode = anElem.parentNode;
	if(theParentNode.getElementsByTagName('LABEL')[0] != undefined){
		return theParentNode.getElementsByTagName('LABEL')[0];
	}
	return false;
}

function changeElemColor(anElem,aColor){
	anElem.style.color = aColor;

}


function _dealWithOnclick(e){
	var anObj = window.event ? window.event.srcElement : e ? e.target : null;
	var objId = anObj.id;

	//SHOW POPUP DIV - START
	if(objId.lastIndexOf('vu_') > -1){
		depthLevels = objId.split('_').length;
		if(depthLevels == 4){
		
//display the fade background
			document.getElementById('fade').style.display='block';

//the array to store the tag element id to be vued
			popupsArray = new Array();

//find the div container element for the base page rollovers
			if (anObj.id.lastIndexOf('-') > -1 && anObj.id.lastIndexOf('_low') > -1){
				colElem = anObj.parentNode.parentNode.parentNode.parentNode.parentNode;
			}else{
				colElem = anObj.parentNode.parentNode.parentNode;
			}

//split the parent div element id tag into the separate sections to match the navigation popup divs
//			colArraySplit = colElem.id.split('_');
//			popNavId = colArraySplit[1];
			popNavId = colElem.id.split('_')[1];
			
//split the actual object id sent to the event into the separate sections to match the popups
			objidArraySplit = objId.split('_'); //popBaseId = objidArraySplit[1]; popBodyId = objidArraySplit[2]; 
			
			popupBackId = objidArraySplit[1];
			popupBack = document.getElementById(popupBackId);
			popupNavs = popupBack.getElementsByTagName('div');
			for(i=0;i<popupNavs.length;i++){
				if(popupNavs[i].id.lastIndexOf('popnav-') > -1){
					if (popupNavs[i].className.lastIndexOf(' novue') > -1) {
						strippedCname = stripString(popupNavs[i].className,' novue');
						popupNavs[i].className = strippedCname + ' yesvue';
			}}}

//get the title from the div containing the popup content
			colHeaderElem = document.getElementById(objidArraySplit[depthLevels-2]).title;
			document.getElementById('popbasetitleid').innerHTML = colHeaderElem;

//fill the vued array with all abject ids that need to be displayed
			popupsArray.push(objidArraySplit[1], objidArraySplit[2]);
			for (i=0; i<popupsArray.length; i++) {
				thisElemId = popupsArray[i];
				thisElem = document.getElementById(thisElemId);

//if an element has class of novue then swap it to yesvue
				if (thisElem.className.lastIndexOf(' novue') > -1) {
					strippedCname = stripString(thisElem.className,' novue');
					thisElem.className = strippedCname + ' yesvue';
			}}

//find the parent div to the popup nav bar so that the rollover state can be initiated
			switch (popNavId) {
				case 'popnav-scratchanat': 
					navHTML = popNavs.navAnatomy.itsHTML;break;
				case 'popnav-freestuff':
					navHTML = popNavs.navStuff.itsHTML;break;
				case 'popnav-start':
					navHTML = popNavs.navStart.itsHTML;break;
				default: navHTML = 'unknown';
			}

			navParent = document.getElementById(popNavs.popNavId);
			theChosenId = objidArraySplit[2];
			(theChosenId.lastIndexOf('-' > -1)) ? theParentId = theChosenId.split('-')[0] : theParentId = theChosenId;
			populateDomElem(navHTML,navParent);
			cxClassOfTag(navParent,' novue',' yesvue');

//doing in css for now
			highlightNav(('vu_' + theParentId),navParent,'a');

		}else if(depthLevels == 2){

//popBaseId = objidArraySplit[1]; popBodyId = objidArraySplit[2]; 
			objidArraySplit = objId.split('_');
			colHeaderElem = document.getElementById(objidArraySplit[depthLevels-1]).title;
			document.getElementById('popbasetitleid').innerHTML = colHeaderElem;			
			if (objId.indexOf('-') > -1){
				elderElem = anObj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;	
				navParent = anObj.parentNode.parentNode.parentNode.parentNode.parentNode;
			}else{
				elderElem = anObj.parentNode.parentNode.parentNode.parentNode;	
				navParent = anObj.parentNode.parentNode.parentNode;
			}
			cxClassOfTagsInside(elderElem,' yesvue',' novue','div');
			if (navParent.className.lastIndexOf(' novue') > -1) {
				strippedCname = stripString(navParent.className,' novue');
				navParent.className = strippedCname + ' yesvue';
			}

	
//doing in css for now
			(objId.lastIndexOf('-' > -1)) ? theParentId = objId.split('-')[0] : theParentId = objId;
			highlightNav(theParentId,navParent,'a');
			popToVueId = objId.split('_')[1];
			//objidArraySplit = objId.split('_'); //popBaseId = objidArraySplit[1]; popBodyId = objidArraySplit[2]; 
			popToVue = document.getElementById(popToVueId);
			if (popToVue.className.lastIndexOf(' novue') > -1) {
				strippedCname = stripString(popToVue.className,' novue');
				popToVue.className = strippedCname + ' yesvue';
			}
			
//since hover state does not work correctly in IE7 then this block will hide the sub-menu after the menu has been clicked
			if(objId.split('_')[0] == 'vu' && objId.split('_').length == 2 && objId.split('_')[1].split('-').length == 2){
				thisElem = document.getElementById(objId);
				ulElem = thisElem.parentNode.parentNode;
				ulElem.style.display = 'none';	
			}
			
		}
	}
	//SHOW POPUP DIV - END

	//CLOSE POPUP DIV - START
	if(objId.lastIndexOf('closerbox') > -1){
		elderElem = anObj.parentNode.parentNode;
		cxClassOfTag(elderElem,' yesvue',' novue');
		cxClassOfTagsInside(elderElem,' yesvue',' novue','div');
		cxClassOfTagsInside(elderElem,' yesvue',' novue','li');
		document.getElementById('fade').style.display='none';
	}
	//CLOSE POPUP DIV - END

	//Sample page nav selector browsers - START
	if(objId.lastIndexOf('lbvue') > -1){
		imageVuerElem = document.getElementById('lightboxvuer');
		myDivs = getLBVuerDivs(imageVuerElem,'img_act');
		actDivText = getTextOfTagInElem(myDivs[1],"h3",0);
		actImgInfo = getImgDetails(actDivText);
		switch (objId) {
			case 'lbvue_pre':
				imageVuerWidth = imageVuerElem.style.width;
				mvAmount = getNumValue(imageVuerWidth)-0;

				nxtDiv = myDivs[2];
				nxtDivMLInt = (getNumValue(getML(nxtDiv))-0);
				jumpDiv(nxtDiv,nxtDivMLInt,mvAmount*2,"minus");					
				
				preDiv = myDivs[0];
				preDivHTML = getTextOfTagInElem(preDiv,'h3',0);
				preDivInfo = stringSplitWithDelim(preDivHTML,',');
				preDivIndex = preDivInfo[0];
				grpValue = preDivInfo[2];
				grpVar = eval(grpValue);
				myNums = getImgNums((grpVar.length-1),(preDivIndex-0));
				imgName = grpVar[myNums[0]];
				initializeVuerDiv(nxtDiv,myNums[0],grpValue,imgName);
				nxtDiv.title = 'img_pre'; 

				actDiv = myDivs[1];
				actDivMLInt = (getNumValue(getML(actDiv))-0);
				jumpDiv(actDiv,actDivMLInt,mvAmount,"plus");					
				actDiv.title = 'img_nxt'; 

				preDiv = myDivs[0];
				preDivMLInt = (getNumValue(getML(preDiv))-0);
				jumpDiv(preDiv,preDivMLInt,mvAmount,"plus");					
				preDiv.title = 'img_act'; 
				
				browseID = 'cardider';
				newText = (myNums[0] + 1) + ' OF ' + grpQty;
				updateCounter(browseID,newText);
				break;
			case 'lbvue_nxt':
				imageVuerWidth = imageVuerElem.style.width;
				mvAmount = getNumValue(imageVuerWidth)-0;

				preDiv = myDivs[0];
				preDivMLInt = (getNumValue(getML(preDiv))-0);
				jumpDiv(preDiv,preDivMLInt,mvAmount*2,"plus");	
								
				nxtDiv = myDivs[2];
				nxtDivHTML = getTextOfTagInElem(nxtDiv,'h3',0);
				nxtDivInfo = stringSplitWithDelim(nxtDivHTML,',');
				nxtDivIndex = nxtDivInfo[0];

				grpValue = nxtDivInfo[2];
				grpVar = eval(grpValue);
				
				myNums = getImgNums((grpVar.length-1),(nxtDivIndex-0));
				
				imgName = grpVar[myNums[0]];
				initializeVuerDiv(preDiv,myNums[2],grpValue,imgName);
				preDiv.title = 'img_nxt'; 

				actDiv = myDivs[1];
				actDivMLInt = (getNumValue(getML(actDiv))-0);
				jumpDiv(actDiv,actDivMLInt,mvAmount,"minus");					
				actDiv.title = 'img_nxt'; 

				nxtDiv = myDivs[2];
				nxtDivMLInt = (getNumValue(getML(nxtDiv))-0);
				jumpDiv(nxtDiv,nxtDivMLInt,mvAmount,"minus");					
				nxtDiv.title = 'img_act'; 
				
				browseID = 'cardider';
				newText = (myNums[0] + 1) + ' OF ' + grpQty;
				updateCounter(browseID,newText);
				break;
			case 'lbvue_front':
				cxDivState(myDivs[1],lbvuerstates[0],'h3',0);
				break;
			case 'lbvue_scratch':
				cxDivState(myDivs[1],lbvuerstates[1],'h3',0);
				break;
			case 'lbvue_back':
				cxDivState(myDivs[1],lbvuerstates[2],'h3',0);
				break;
			default: navHTML = 'unknown';
		}
	}
	//Sample page nav selector browsers - END

}

function __YOU_ARE_BELOW(){
	/**/				
	//get active div by title and not margin left
	/***************************/
	/*    __YOU_ARE_BELOW      */
	/*    __YOU_ARE_BELOW      */
	/*    __YOU_ARE_BELOW      */
	/***************************/
	//alert(actDivText);
	theLength = myDivs.length;
	for(i=0;i<theLength;i++){
		//alert(myDivs[i].title);
	}
}

function buildThePreloader(imgNums){
	listReturn = new Array();
    for(i = 0; i < liCount; i++){
    	listReturn[i] = imgFolder + imgBaseName + imgNums[i] + imgTyp;
	    imageObj = new Image();
		imageObj.src = listReturn[i];
	}
	return listReturn;
} 
				
function buildTheRandNumArr(aNum){
	randNumArr = new Array();
	do {
		thisRandNum = genRanNumCeil(aNum);
		(thisRandNum <= 9) ? thisRandNum = "0" + (thisRandNum + 0) : thisRandNum = (thisRandNum + 0);
		if (randNumArr.indexOf(thisRandNum) == -1){
			randNumArr.push(thisRandNum);
		}
	}
	while (randNumArr.length < liCount);
	return randNumArr;
}

function buildTheUL(thisImgList){
	htmlReturn = "";
	for (i=0; i< thisImgList.length; i++){
		imgSRC = thisImgList[i];
		htmlReturn +="<li>";
//		htmlReturn += i;
		htmlReturn +="<img src='" + imgSRC + "' alt='Scratcher Card'></li>";
	}
	return htmlReturn;
}

function centerElem(elemId,aWidth) {
	pageW=pgW();
	sizediff=pageW-aWidth;
	sizediff > 0 ? pagePos(sizediff,elemId) : pagePos(0,elemId);
}

function centerPage(){
	backimgW=1038;
	centerElem('divouterid',backimgW);
	popupElem = document.getElementById('popbckid')
	if(popupElem){
	
		popoutW=888;
		centerElem('popbckid',popoutW);
	}
}

function cxClassOfTagsInside(anElem,origId,newId,aTag){
	elemArray = anElem.getElementsByTagName(aTag);
	for (i=0; i<elemArray.length; i++){
		if(elemArray[i].className.lastIndexOf(origId) > -1){
			strippedCname = stripString(elemArray[i].className,origId);
			elemArray[i].className = strippedCname + newId;
}}}

function cxClassOfTag(forElem,origId,newId){
	if(forElem.className.lastIndexOf(origId) > -1){
		strippedCname = stripString(forElem.className,origId);
		forElem.className = strippedCname + newId;
}}

function cxDivState(anElem,aState,aTag,anIndex){
	tagInnerText = getTextOfTagInElem(anElem,aTag,anIndex);
	actImgInfo = getImgDetails(tagInnerText);
	actImgNum = actImgInfo[0][0];
	actImgName = actImgInfo[0][1];
	actImgGrp = actImgInfo[0][2];
	actCardState = actImgInfo[0][3];
	if(actCardState != aState){
		prePath = samplesDir + '/' + actImgGrp + '/';
		postPath = lbvuerdelim + aState + fileExt;
		imgActPath = mkImgPath(prePath,actImgName,postPath);
		innerText =  actImgNum + ',' + actImgName + ',' + actImgGrp + ',' + aState;
		putTextInElemTag(innerText,anElem,'h3');
		putBackgroundImage(anElem,imgActPath);
}}


function repCallingMsg(anObj){
//alert(msgElem.style.display);
	objValue = anObj.options[anObj.selectedIndex].value;
	msgElem = document.getElementById('uploadimgmsg');
	if(objValue.lastIndexOf('-yes') > -1 ){
		(msgElem.style.display == 'none' || msgElem.style.display == '') ? msgElem.style.display = 'block' : '' ;
	}else if (objValue.lastIndexOf('-no') > -1 ){
		(msgElem.style.display == 'block' || msgElem.style.display == '') ? msgElem.style.display = 'none' : '' ;
	}

}



function _dealWithOnChange(e){
	var anObj = window.event ? window.event.srcElement : e ? e.target : null;
	var objId = anObj.id;
	
	if (objId.lastIndexOf('logo') > -1 || objId.lastIndexOf('images') > -1){
		objValue = anObj.value;
		msgElem = document.getElementById('uploadimgmsg');
		if(objValue.lastIndexOf('-yes') > -1 ){
			(msgElem.style.display == 'none' || msgElem.style.display == '') ? msgElem.style.display = 'block' : '' ;
		}else if (objValue.lastIndexOf('-no') > -1 ){
			(msgElem.style.display == 'block' || msgElem.style.display == '') ? msgElem.style.display = 'none' : '' ;
		}
	}
}

function _dealWithMout(e){
	var anObj = window.event ? window.event.srcElement : e ? e.target : null;
	var objId = anObj.id;
	
	if (objId.lastIndexOf('vu_') > -1){
		if(objId.split('_')[0] == 'vu' && objId.split('_').length == 2 && objId.split('_')[1].split('-').length < 2){
			thisElem = document.getElementById(objId);
			thisElemParent = thisElem.parentNode;
			
			//make sure that this swapping is correct in IE since the rgb number is not recognised by IE it looks like
			//alert(thisElemParent.style.backgroundColor);
			
			if(thisElemParent.style.backgroundColor == 'rgb(222, 222, 222)'){
				thisElemParent.style.backgroundColor = 'white';		
			}
		}
	}
}

function _dealWithMover(e){
	var anObj = window.event ? window.event.srcElement : e ? e.target : null;
	var objId = anObj.id;
	if (objId.lastIndexOf('vu_') > -1){
		if(objId.split('_')[0] == 'vu' && objId.split('_').length == 2 && objId.split('_')[1].split('-').length < 2){
			thisElem = document.getElementById(objId);
			thisElemParent = thisElem.parentNode;
			thisElemParent.style.backgroundColor = '#dedede';
			parentNav = thisElem.parentNode.parentNode;
			parentNavULs = parentNav.getElementsByTagName('UL');
			for (i=0; i<parentNavULs.length; i++){
				aSubNavUL = parentNavULs[i];
				aSubNavUL.style.display = 'none';
			}
			subNavULs = thisElemParent.getElementsByTagName('UL');
			if(subNavULs[0] != undefined){
				subNavULs[0].style.display = 'block';
			}
}}}

function getActiveDivByTitle(aNodesList,aTitle){
	returnDiv = '';
	for (i=0; i<aNodesList.length; i++){
		aNodeTitle = aNodesList[i].title;
		(aNodeTitle == aTitle) ? returnDiv = aNodesList[i] : '';
	}
	return returnDiv;
}

function getActiveDivByMLeft(aNodesList,aMLeft){
	returnDiv = '';
	for (i=0; i<aNodesList.length; i++){
		aNodeMLeft = aNodesList[i].style.marginLeft;
		(aNodeMLeft == aMLeft) ? returnDiv = aNodesList[i] : '';
	}
	return returnDiv;
}

function getImgDetails(actDivText){
	imgInfoArr = new Array();
	imgInfoArr.push(stringSplitWithDelim(actDivText,','));
	return imgInfoArr;
}

function getDivByTitle(aDivElem,aTag,aTitle){
	innerDivs = aDivElem.getElementsByTagName(aTag);
	for(i=0; i<innerDivs.length; i++){
		if(innerDivs[i].title == aTitle){
			return innerDivs[i];
		}
	}
}


function getLBVuerDivs(anElem,aTitle) {
	divsInElem = getTagsInElem(anElem,'div');
	activeDiv = getActiveDivByTitle(divsInElem,aTitle);				
	activeDivMLeft = getNumValue(activeDiv.style.marginLeft)-0;
	var divNumArr = new Array();
	for(i=0; i<divsInElem.length; i++){
		thisDiv = divsInElem[i];
		thisDivMLeft = thisDiv.style.marginLeft;
		thisDivMLeftNum = (getNumValue(thisDivMLeft)-0);
		if(thisDivMLeftNum < activeDivMLeft){
			preDiv = thisDiv;
		}else if(thisDivMLeftNum == activeDivMLeft){
			actDiv = thisDiv;
		}else if(thisDivMLeftNum > activeDivMLeft){
			nxtDiv = thisDiv;
		}
	}	
	divNumArr.push(preDiv,actDiv,nxtDiv);			
	return divNumArr;
}

function getElemFromId(anId){
	return (document.getElementById(anId));
}











function getImgNums(totQty,aNum){
	var numArr = new Array();
	if (aNum == totQty){
		nxtNum = 0; 
		actNum = aNum; 
		preNum = aNum - 1;			
	} else if(aNum == 0){			
		nxtNum = aNum + 1; 
		actNum = aNum; 
		preNum = totQty;
	} else if(aNum > 0 && aNum < totQty){			
		nxtNum = aNum + 1; 
		actNum = aNum; 
		preNum = aNum - 1;
	}
	numArr.push(preNum,actNum,nxtNum);
	return numArr;
}

function getML(anEl){
	return anEl.style.marginLeft;

}

function getModulusValue(pixVal){
	if(pixVal.lastIndexOf('-') ==0 ){
		newPixVal = pixVal.substr((pixVal.lastIndexOf('-') + 1),pixVal.length);
	}else{
		newPixVal = pixVal;
	}
	return newPixVal.substr(0,newPixVal.lastIndexOf('px'));
}

function genRanNumCeil(thisNum){
	randNum = Math.random() * thisNum;
	ranNumCeil = Math.ceil(randNum);
	return ranNumCeil;
}

function getTagsInElem(anElem,aTag){
	return (anElem.getElementsByTagName(aTag));
}

function getTextOfTagInElem(inElem,aTag,tagIndex){
	theseTags = getTagsInElem(inElem,aTag);
	firstTag = theseTags[tagIndex];
	return getInnerText(firstTag);
}

function getInnerText(inElem){
	return inElem.innerHTML;
}

function getNumValue(pixVal){
	return pixVal.substr(0,pixVal.lastIndexOf('px'));
}

function gotoPage(thisObj){
		thisNodeList = thisObj.getElementsByTagName('a');
		myElem = thisNodeList[0];
		location.href = myElem;
}

function highlightNav(anId,navNode,aTag){
	allPElems = navNode.getElementsByTagName(aTag);
	for(i=0; i<allPElems.length; i++){
		thisElemId = allPElems[i].id;
		if (thisElemId != anId){
//			allPElems[i].style.color = highlightColor;
			allPElems[i].style.backgroundColor = 'white';				
//			allPElems[i].style.color = selectColor;
		} else {
//			allPElems[i].style.color = highlightColor;				
			allPElems[i].style.backgroundColor = '#f7941e';				
}}}

function initializePage(){
	
	var theBrowser = identifyBrowser();
	if (theBrowser == 'ie6' || theBrowser == 'ie5' ){
		alert('This site has been optimized for Internet Explorer 7 or higher\n and you are opening this page with \"' + theBrowser + '\", We will redirect you\n to our classic site for better viewing... \n\nThank you and we apologize for any inconvenience!\n\nIf you are running Windows and wish to view the new site you\nmay download \"Safari\" or \"Firefox!\"' );
		navigate(oldHomePage);
	}
	
	centerPage();
	theImgNumbers = buildTheRandNumArr(imgCount);
	theImgList = buildThePreloader(theImgNumbers);
	theLIhtml = buildTheUL(theImgList);

//will not work correctly in ie so have placed it in the body of the html as page loads
	//	theSignElem =  document.getElementById('inforowman');
	//	if (theSignElem){
	//		placeRandomSign(theSignElem);	
	//	}


	theLBDivObj = document.getElementById('lightboxnavid');
	thePicsULObj = document.getElementById('rotoscopeul');
	if(thePicsULObj){
		thePicsULObj.innerHTML = theLIhtml;
		thePicsULObj.style.marginLeft = -(increment) + 'px';
		thePicsDiv = thePicsULObj.parentNode;
		setInterval(function(){updateSliderPics(thePicsULObj,thePicsDiv)},refreshRate);
	}else if(theLBDivObj){
		placeSampleCategories(theLBDivObj);
		theLBSelectObj = document.getElementById('samplecat');
		theLBSelectObj.onchange = _doSampleCatagoryChg;
		chosenGrp = theLBSelectObj.selectedIndex;
		if(chosenGrp == 0){
			catQty = (theLBSelectObj.length - 1);//totalGrps = 15;
			ranGrp = genRanNumCeil(catQty);
			initializeVuer(ranGrp);
		}else{
			initializeVuer(chosenGrp);
		}		
}}

function initializeVuer(aNum){

		cardState = lbvuerstates[0];//0 = f;
		theLBSelectObj.selectedIndex = aNum;			
		grpValue = theLBSelectObj.options[aNum].value;
		grpVar = eval(grpValue);
		grpQty = grpVar.length;

		grpRanNum = genRanNumCeil(grpQty-1);
		
		myNums = getImgNums((grpQty-1),(grpRanNum-0));
		
		prePath = samplesDir + '/' + grpValue + '/';
		postPath = lbvuerdelim + cardState + fileExt;
		
		imgPrePath = mkImgPath(prePath,grpVar[(myNums[0])],postPath);
		imgActPath = mkImgPath(prePath,grpVar[(myNums[1])],postPath);
		imgNxtPath = mkImgPath(prePath,grpVar[(myNums[2])],postPath);

		imageVuerElem = getElemFromId('lightboxvuer');
		imageVuerDivs = getTagsInElem(imageVuerElem,'div');
		
		
		for (i=0; i<imageVuerDivs.length; i++){
			//place card details in the innerhtml of the document h3 tag for retrieval later
			//details = group text, card number in list, actual card name from list, group value/dir its in, card state (front, scratched, back)
			switch (imageVuerDivs[i].title) {
				case 'img_pre': 
					newPath = imgPrePath;
					innerText = myNums[0] + ',' + grpVar[myNums[0]] + ',' + grpValue + ',' + cardState;
					break;
				case 'img_act':
					newPath = imgActPath;
					innerText = myNums[1] + ',' + grpVar[myNums[1]] + ',' + grpValue + ',' + cardState;
					break;
				case 'img_nxt':
					newPath = imgNxtPath;
					innerText =  myNums[2] + ',' + grpVar[myNums[2]] + ',' + grpValue + ',' + cardState;
					break;
			}
			putBackgroundImage(imageVuerDivs[i],newPath);
			putTextInElemTag(innerText,imageVuerDivs[i],'h3');
		}
		
		browseID = 'cardider';
		newText = (myNums[1] - 0) + ' OF ' + grpQty;
		updateCounter(browseID,newText);
}




function initializeVuerDiv(anEl,actImgNum,gVal,aName){
	aCardState = lbvuerstates[0];
	prePath = samplesDir + '/' + gVal + '/';
	postPath = lbvuerdelim + aCardState + fileExt;
	imgPath = mkImgPath(prePath,aName,postPath);
	putBackgroundImage(anEl,imgPath);
	innerText = actImgNum + ',' + aName + ',' + gVal + ',' + aCardState;
	putTextInElemTag(innerText,anEl,'h3');
}




function mkImgPath(preText,actualText,postText){
 return (preText + actualText + postText);
}

function mvDivSmooth(anElem,currMLeft,anAmount,aDirection){
	//alert('anAmount' + ':- ' + anAmount);
	switch(aDirection){
		case 'right':
			newMleft = (currMLeft + anAmount);
			break;
		case 'left':
			newMleft = (currMLeft - anAmount);
			break;
	}
	anElem.style.marginLeft = newMleft + 'px';
	//setElemMargin(anElem,newMleft,'px','left');
}











function jumpDiv(aDiv,locationInt,distanceInt,aBearing){
	if(aBearing == "plus"){
		newMargin = (locationInt + distanceInt);
		aDiv.style.marginLeft = newMargin + 'px';
	}else if(aBearing == "minus"){
		newMargin = (locationInt - distanceInt);
		aDiv.style.marginLeft = newMargin + 'px';
	}
}


















function mvDivLSmooth(anElem,currMLeft,anAmount,myIncrement,intDiff,refRate){

/***************************/
/*    __YOU_ARE_BELOW      */
/*    __YOU_ARE_BELOW      */
/*    __YOU_ARE_BELOW      */
/***************************/
//alert(activeDivMLeft);
//alert('START...' + 'currMLeft' + ':- ' + currMLeft);

	if(intDiff == anAmount){
	//alert('anElem.title' + ':- ' + anElem.title + '...currMLeft' + ':- ' + currMLeft + '...anAmount' + ':- ' + anAmount + '...myIncrement' + ':- ' + myIncrement + '...intDiff' + ':- ' + intDiff);
		clearTimeout(timeID);


	}else if(intDiff < anAmount){
		newMLeft = currMLeft - myIncrement;
		anElem.style.marginLeft = newMLeft + 'px';
		currMLeft = newMLeft;
		
		if (intDiff == 0){
		
			
			modMvAmount = (anAmount % myIncrement) -0;
			intDiff = intDiff + modMvAmount;
//	alert('START...' + 'intDiff' + ':- ' + intDiff);
		}else if(intDiff < anAmount){


			intDiff = intDiff + myIncrement;
//	alert('DURING...' + 'intDiff' + ':- ' + intDiff);
		}
		
		


		timeID = setTimeout(function(){mvDivLSmooth(anElem,currMLeft,anAmount,myIncrement,intDiff,refRate)},refRate);
	}
}







function mvDivRSmooth(anElem,currMLeft,anAmount,myIncrement){
//alert('anElem.style.marginLeft' + ':- ' + anElem.style.marginLeft);
	newMargin = (currMLeft + anAmount);
	anElem.style.marginLeft = newMargin + 'px';
}




function pagePos(aNum,anId){
	thisObj = document.getElementById(anId);
	thisObj.style.left = (aNum/2) + "px";
}








function populateDomElem(someHTML,domElem){
	domElem.innerHTML = someHTML;
}

function putBackgroundImage(anElem,aPath){
	anElem.style.backgroundImage = 'url(' + aPath + ')';
}

function putTextInElemTag(someText,inElem,aTag){
	theseTags = getTagsInElem(inElem,aTag);
	firstTag = theseTags[0];
	firstTag.innerHTML = someText;
}

function pgW() {
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

function placeRandomSign(signElemId){	
signElem = document.getElementById(signElemId);
ranNum = genRanNumCeil(allsigns.length);
newSignHTML = '';
newSignHTML += '<img src=\"imagesigns\/';
newSignHTML += allsigns[ranNum-1];
newSignHTML += '\" title=\"Scratch Off Signs\">';
signElem.innerHTML = newSignHTML;
}

function placeSampleCategories(theElem){
//this text manipulation has to oocur since IE7 will not give access to an object id and changr its content unless it is a DIV tag
//in order to manipulate the DOM here we cannot meaarly cahnge the select object... we must change the inclosing div too... ARRRRRRRGHHHH!!!! IE SUCKS
	divPreSelectText = '<ul><li><select class=\"lbdropdown\" id=\"samplecat\" name=\"businesstype\">';
	divPostSelectText = '</select></li><li><a href=\"#\" class=\"lbprevious\" id=\"lbvue_pre\"></a></li><li style=\"text-align:center;\"><p>BROWSE</p><p id=\"cardider\">Position</p></li><li><a href=\"#\" class=\"lbnext\" id=\"lbvue_nxt\"></a></li><li><a href=\"#\" class=\"lbfront\" id=\"lbvue_front\">FRONT</a></li><li><a href=\"#\" class=\"lbscratched\" id=\"lbvue_scratch\">SCRATCHED</a></li><li><a href=\"#\" class=\"lbbackside\" id=\"lbvue_back\">BACK SIDE</a></li></ul>';

	initText = '<option value=\"';
	valText = '\">';
	endText = '</option>\n';
	newText = initText + '\" selected=\"selected' + valText + '--Choose--' + endText;
	for(i=0; i<allCategories.length; i++){
		thisCatVal = allCategories[i][0];
		thisCatText = allCategories[i][1];
		newText += initText + thisCatVal + valText + thisCatText + endText;
	}
	theElem.innerHTML = divPreSelectText + newText + divPostSelectText;		
}

function setElemMargin(anElm,newMargin,aUnit,aCompass){
	switch(aCompass){
		case 'left':
			anElem.style.marginLeft = newMargin + aUnit;
			break;
		case 'right':
			anElem.style.marginRight = newMargin + aUnit;
			break;
		case 'top':
			anElem.style.marginTop = newMargin + aUnit;
			break;
		case 'bottom':
			anElem.style.marginBottom = newMargin + aUnit;
			break;	
	}
}

function stripString(oStr,stripStr){
	oStrLen = oStr.length;
	stripStrLen = stripStr.length;
	stripStrPos = oStr.indexOf(stripStr);
	if(stripStrLen < oStrLen){
		strFront = oStr.substring(0,stripStrPos);
		strBack = oStr.substring((stripStrPos + stripStrLen), oStrLen);
	}
	return (strFront + strBack);
}

function stringSplitWithDelim(aString,aDelim){
	return (aString.split(aDelim));
}

function updateSliderPics(aUL,aULHolder){
	var picOffset = getNumValue(aUL.style.marginLeft);
	var picsWidth = getModulusValue(aUL.style.width);
	var holderWidth = getNumValue(aULHolder.style.width);
	if(slidesPlayed == false){
		if(picOffset < 0){
			newLocation = ((picOffset - 0) + increment);
			aUL.style.marginLeft = newLocation + 'px';
			if(picOffset == -1){
				slidesPlayed = true;
			}
		}
	}else if(slidesPlayed == true){
		ulHolderFront = -picsWidth + (holderWidth - 0);
		if (picOffset > ulHolderFront){
			newLocation = ((picOffset - 0) - increment);
			aUL.style.marginLeft = newLocation + 'px';
			if(picOffset == (ulHolderFront +1)){
				slidesPlayed = false;
}}}}

function updateCounter(anId,newText){
	//'cardider'
	browseElem = document.getElementById(anId);
	browseElem.innerHTML = newText;	
}

//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

function checkBrowser(){
//test
//DO NOT REMOVE
//alert("Yowser!");

	
var bName = navigator.appName;
var bVer = integer(navigator.appVersion);
var ver;
//DO NOT CHANGE ANYTHING BELOW THIS POINT
function browserCheck() {	

if (bName == "Netscape" && bVer == 1) ver = "n1";
	
else if (bName == "Netscape" && bVer == 2) ver = "n2";
	
else if (bName == "Netscape" && bVer == 3) ver = "n3";
	
else if (bName == "Netscape" && bVer == 4) ver = "n4";
	
else if (bName == "Netscape" && bVer == 5) ver = "n5";
	
else if (bName == "Netscape" && bVer == 6) ver = "n6";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 1) ver = "ie1";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 2) ver = "ie2";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 3) ver = "ie3";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 4) ver = "ie4";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 5) ver = "ie5";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 6) ver = "ie6";
	
else if (bName == "Microsoft Internet Explorer" && bVer == 7) ver = "ie7";
	
if (ver == "ie5" || "ie6" || "ie7" || "n4" || "n5" || "n6") {
	
}

	else if (ver == "ie4" || "ie3" || "ie2" || "ie1" || "n3" || "n2" || "n1") {
		//put wut you want to tell the user if their browser version is'nt high enough
		alert("It is strongly advised that you upgrade your browser.");
		
	}		
}	
}
