//Adds text to any part of the body of a HTML
function addNode(tagParent,strText,boolAddToBack, boolRemoveNode)
{
  var strNode = document.createTextNode(strText);//holds the test which will be added
     
  //gets the properties of the node
  tagParent = getDocID(tagParent);
  
  //checks if the user whats to replace the node in order to start with a clean slate
  //it also checks if there is a chode node to replace
  if (boolRemoveNode == true && tagParent.childNodes.length > 0)
	//replaces the current node with what the user wants
	tagParent.replaceChild(strNode,tagParent.childNodes[0]);
  else
  {
  	//checks if the user whats to added to the back of the id or the front
  	if(boolAddToBack == true)
		tagParent.appendChild(strNode);
  	else
		//This is a built-in function of Javascript will add text to the beginning of the child
  		insertBefore(strNode,tagParent.firstChild);
  }//end of if else
  
  //returns the divParent in order for the user to use it for more uses
  return tagParent;
}//end of addNode()

//changes the image of tagImage to what is in strImageSrc
function changeImage(tagImage,strImageSrc)
{
    //gets the properties of tagImage
    tagImage = getDocID(tagImage);
    
    //checks if there is a properties
    if(tagImage != null)
        tagImage.src = strImageSrc;
}//end of changeImage()

//changes the video of tagVideo to what is in strVideoSrc or strVideoFFSrc
function changeVideo(tagVideo,strVideoSrc,strVideoFFSrc,strVideoNoHTML5)
{
    //gets the properties of tagVideo
    tagVideo = getDocID(tagVideo);
    
    //checks if there is a properties
    if(tagVideo != null)
	{
		/*"<video width='640' height='360' controls='controls' autoplay='autoplay'>" + 
		"<source src='/wp-content/themes/blueprint/video/" + strVideoSrc + "' />" + 
		"<source src='/wp-content/themes/blueprint/video/" + strVideoFFSrc + "' />" + 
	    "<div class='divFallback'>" + */
        /*tagVideo.innerHTML = "<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab' width='640' height='360'>" + 
      "<param name='src' value='/wp-content/themes/blueprint/video/" + strVideoNoHTML5 + "'>" + 
      "<param name='autoplay' value='true'></param>" + 
      "<param name='CONTROLLER' value='true'></param>" + 
      "<embed src='/wp-content/themes/blueprint/video/" + strVideoNoHTML5 + "' width='640' height='360' autoplay='true'  CONTROLLER='true' type='video/mp4' pluginspage='http://www.apple.com/quicktime/download/'></embed>" + 
      "</object>";*/
	  //+ "</div></video>";
	  tagVideo.innerHTML = '<object width="640" height="360" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="/wp-content/themes/blueprint/video/' + strVideoNoHTML5 + '"> <param name="autoplay" value="true"> <param name="controller" value="true"> <embed src="/wp-content/themes/blueprint/video/' + strVideoNoHTML5 + '" width="640" height="360" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
	}//end of if
}//end of changeVideo()

//decodes str to be a normal string in order to read it
function decodeURL(strDecode)
{
     return unescape(strDecode.replace(/\+/g, " "));
}//end of decodeURL()

//does the display the a message in a on the page weather then an alert
function displayMessage(tagMessage,strMessText,boolAddToBack, boolRemoveNode)
{
	//gets the message properties and sets the text furthermore it does the display
	tagMessage = addNode(tagMessage,strMessText,boolAddToBack, boolRemoveNode);
	tagMessage.style.display = "block";	
	
	return tagMessage;
}//end of displayMessage()

//encodes str to a URL so it can be sent over the URL address
function encodeURL(strEncode)
{
    var strResult = "";
   
    for (intIndex = 0; intIndex < strEncode.length; intIndex++) {
        if (strEncode.charAt(intIndex) == " ") strResult += "+";
        else strResult += strEncode.charAt(intIndex);
    }
   
    return escape(strResult);
}//end of encodeURL()

//gets the document properties in order to use them as there are many types of browers with different versions
function getDocID(tagLayer)
{
	var tagProp = "";//holds the proerties of tagLayer

	//gets the whichLayer Properties depending of the differnt bowers the user is using
	if (document.getElementById)//this is the way the standards work
		tagProp = document.getElementById(tagLayer);
	else if (document.all)//this is the way old msie versions work
		tagProp = document.all[tagLayer];
	else if (document.layers)//this is the way nn4 works
		tagProp = document.layers[tagLayer];
		
	return tagProp;
}//end of getDocID()

//Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;//holds the valuable value from the URL
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');//holds the section of of the value and valuable

	//goes around for each valuable in the URL
    for(var i = 0; i < hashes.length; i++)
    {
		//splites the value and valuable into half
        hash = hashes[i].split('=');
		
		//adds the valuable into first part ant the value into the secound pard
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }//end of for loop

    return vars;
}//end of getUrlVars()

//starts up the page
function startUp()
{
	var oldonload=window.onload;//holds any prevs onload function from the js file

 
	//gets the onload window event checks if there is a function that is already in there
	window.onload=function(){
		if(typeof(oldonload)=='function')
			oldonload();
			
		  var hash = getUrlVars();
		  
		  //checks if the page is on the Video Testimonials and if so then checks if there is a video for it
		  //or just use the default
		  if(hash != null && hash['page_id'] != null && hash['page_id'] == "58")
		  {
			  //checks if therere is a Video peraminter in the url and if so then gets it in order to display it to the user
			  if(hash['video'] != null)
			  {
				  changeVideo('divVideo',hash['video'] + '.m4v',hash['video'] + '.ogv',hash['video'] + '.mov');
			  }//end of if
			  else
				changeVideo('divVideo','DianeDupuyTestimonial.m4v','DianeDupuyTestimonial.ogv','DianeDupuyTestimonial.mov');
		  }//end of if
		 
		  //finds which browser the user is using for Firefox it is the defult
		  //for IE 
		  if (navigator.userAgent.indexOf('MSIE') != -1)
		  {
			  if(navigator.appVersion.indexOf('MSIE 7') != -1)
			  {
			  }//end of if	  
		  }//end of if
		  //for Safari and Mac
		  else if (navigator.userAgent.indexOf('Safari') !=-1 || navigator.platform.indexOf("Mac") > -1)
		  {
			  //for Firefox for the Mac
			  if (navigator.userAgent.indexOf('Firefox') !=-1)
			  {
			  }//end of if else	
			  
			  var tagOurClients = getDocID('divOurClients');//holds divOurClients
				  
			  if(tagOurClients != null && navigator.platform.indexOf("Mac") > -1)
			  {
				 tagOurClients.style.height = "146px";
			  }//end of if
		  }//end of if else
		  //for Firefox
		  else if (navigator.userAgent.indexOf('Firefox') !=-1)
		  {
		  }//end of if else*/
		  //for Opera
		  else if (navigator.userAgent.indexOf('Opera') !=-1)
		  {
		  }//end of if else
	}//end of window.onload=function()
}//end of startUp()
