/*
	This code is to allow Javascript to communcted to the Server in order to update it
*/

//
// Define a list of Microsoft XML HTTP ProgIDs.
//
var XMLHTTPREQUEST_MS_PROGIDS = new Array(
  "Msxml2.XMLHTTP.7.0",
  "Msxml2.XMLHTTP.6.0",
  "Msxml2.XMLHTTP.5.0",
  "Msxml2.XMLHTTP.4.0",
  "MSXML2.XMLHTTP.3.0",
  "MSXML2.XMLHTTP",
  "Microsoft.XMLHTTP"
);

//
// Define ready state constants.
//
var XMLHTTPREQUEST_READY_STATE_UNINITIALIZED = 0;
var XMLHTTPREQUEST_READY_STATE_LOADING       = 1;
var XMLHTTPREQUEST_READY_STATE_LOADED        = 2;
var XMLHTTPREQUEST_READY_STATE_INTERACTIVE   = 3;
var XMLHTTPREQUEST_READY_STATE_COMPLETED     = 4;
//

//
// Returns XMLHttpRequest object. 
//
function getXMLHttpRequest()
{
  var httpRequest = null;

  // Create the appropriate HttpRequest object for the browser.
  if (window.XMLHttpRequest != null)
    httpRequest = new window.XMLHttpRequest();
  else if (window.ActiveXObject != null)
  {
    // Must be IE, find the right ActiveXObject.
    var success = false;
    for (var i = 0;i < XMLHTTPREQUEST_MS_PROGIDS.length && !success;i++)
    {
      try
      {
        httpRequest = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);
        success = true;
      }
      catch (ex)
      {}
    }
  }

  // Display an error if we couldn't create one.
  if (httpRequest == null)
    alert("Error in HttpRequest():\n\n"
      + "Cannot create an XMLHttpRequest object.");

  // Return it.
  return httpRequest;
}

//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 colour of tagTarget to be more dim or removes it
function changeColour(tagTarget)
{
	//gets the properties of tagTarget
	tagTarget = getDocID(tagTarget);

	//checks if there is a tagTarget on the page
	if(tagTarget != null)
	{
		//sets the style to be dim or to remove it
		if(tagTarget.style.opacity == "")
		{
			tagTarget.style.opacity = "0.5";
			tagTarget.style.filter = "alpha(opacity=50)";
		}//end of if
		else
		{
			tagTarget.style.opacity = "";
			tagTarget.style.filter = "";
		}//end of else
	}//end of if
}//end of changeColour()

//changes the embed object of object tag
function changeFlashMovie(tagMovie,tagEmbed,tagVideoAction,strHeight,strWidth,strWmode,strPluginspage,strController,strType,strAutostart,strSRC)
{			
	//gets the properties of the tags (This is for IE)
	tagMovie = getDocID(tagMovie);
	tagEmbed = getDocID(tagEmbed);
	tagVideoAction = getDocID(tagVideoAction);
	
	//checks if tagMoive and tagEmded has some value (This is for IE)
	if(tagMovie != null && tagEmbed != null)
	{
		tagMovie.value = strSRC;
		//tagEmbed.src = strSRC;
				//alert(tagEmbed.src);
		tagEmbed.innerHTML = "<embed height=\"" + strHeight + "\" width=\"" + strWidth + "\" wmode=\"" + strWmode + "\" pluginspage=\"" + strPluginspage + "\" controller=\"" + strController + "\" type=\"" + strType + "\" autostart=\"" + strAutostart + "\" src=\"" + strSRC + "\"/>";
		//tagVideoAction.Play();
	}//end of if
}//end of changeFlashMovie()

//changes two images are the beginning and end
function changeTwoImages(tagBeginImage,tagEndImage,strBeginImage,strEndImage)
{
	//gets the properties of the tags
	tagBeginImage = getDocID(tagBeginImage);
	tagEndImage = getDocID(tagEndImage);
	
	//checks if there is a tagTarget on the page
	if(tagBeginImage != null && tagEndImage != null)
	{
		//sets the style to be the new iamge
		if(strBeginImage != "" && strEndImage != "")
		{
			tagBeginImage.src = strBeginImage;
			tagEndImage.src = strEndImage;
		}//end of if
	}//end of if
}//end of changeTwoImages()

//changes the Text Header and the Image in order for Picture Gallery can display the image fully
function changeImageLightBox(tagImage,tagLightBoxTitle,strImage,strLightBoxTitle,tagTitleBar,strStyleName)
{
	//gets the properties of the tags
	tagImage = getDocID(tagImage);
	tagLightBoxTitle = getDocID(tagLightBoxTitle);
	tagTitleBar = getDocID(tagTitleBar);
	
	//checks if there is a tagTarget on the page
	if(tagImage != null && tagLightBoxTitle != null && tagTitleBar != null)
	{
		//sets the style to be the new iamge
		if(strImage != "")
		{
			var intTitleBarStyle = 0;
			
			tagImage.src = strImage;
			tagLightBoxTitle.innerHTML = strLightBoxTitle;
			
			//checks if the width is bigger then height
			if(tagImage.width > tagImage.height)
				tagImage.width = 325;
			else
				tagImage.height = 325;
			
			//checks if the form is IE or the other broswers this is to see if it is need to grow th size to
			//fit the boarder and removes the px at the end of the area
			if (tagTitleBar.currentStyle)
				//IE
				intTitleBarStyle = parseInt(tagTitleBar.currentStyle[strStyleName].substring(0,tagTitleBar.currentStyle[strStyleName].length - 2));
			else
				//other broswers
				intTitleBarStyle = parseInt(document.defaultView.getComputedStyle(tagTitleBar,null).getPropertyValue(strStyleName).substring(0,document.defaultView.getComputedStyle(tagTitleBar,null).getPropertyValue(strStyleName).length - 2));

			//checks if it is need size needs to grow
			if(tagImage.width > intTitleBarStyle)
				tagTitleBar.style.width = (tagImage.width) + "px";
			else
				//removes the style
				tagTitleBar.style.width = '';
		}//end of if
	}//end of if
}//end of changeDymaicLightBox()

//removes from view all tags in tagContainer with the expection of tagActive but goes the other way from classToggleLayer
//It assumes the tagActive and tagContiner already have the properties
function classRevToggleLayer(tagContainer,tagActive,strClassName,strTAGName)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName and it is not active if it is active then change the dispaly to block
		if(arrTAG[intIndex].className == strClassName && arrTAG[intIndex].id != tagActive.id)
			arrTAG[intIndex].style.display = arrTAG[intIndex].style.display? "":"block";
		else if(arrTAG[intIndex].id == tagActive.id && tagActive.style.display == "")
			arrTAG[intIndex].style.display = arrTAG[intIndex].style.display? "":"";
	}//end of for loop
}//end of classToggleLayer()

//removes from view all tags in tagContainer with the expection of tagActive
//It assumes the tagActive and tagContiner already have the properties
function classToggleLayer(tagContainer,tagActive,strClassName,strTAGName)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName and it is not active if it is active then change the dispaly to block
		if(arrTAG[intIndex].className == strClassName && arrTAG[intIndex].id != tagActive.id)
			arrTAG[intIndex].style.display = arrTAG[intIndex].style.display? "":"";
		else if(arrTAG[intIndex].id == tagActive.id && tagActive.style.display == "")
			arrTAG[intIndex].style.display = arrTAG[intIndex].style.display? "":"block";
	}//end of for loop
}//end of classToggleLayer()

//removes from view all tags in tagContainer with the expection of tagActive and adds color if the user choose to
//It assumes the tagActive and tagContiner already have the properties
function classToggleLayerColor(tagContainer,tagActive,strClassName,strTAGName,strNonActiveColor,strActiveColor)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName
		if(arrTAG[intIndex].className == strClassName && arrTAG[intIndex].id != tagActive.id)
		{
			//if strNonActiveColor is blank then it will remove the style.color
			arrTAG[intIndex].style.color = strNonActiveColor;
		}//end of if
		else if(arrTAG[intIndex].id == tagActive.id && tagActive.style.display == "")
		{
			//checks if the user wants to change color of the strTAGName
			if(strActiveColor != "")
				arrTAG[intIndex].style.color = strActiveColor;
		}//end of if else
	}//end of for loop
}//end of classToggleLayerColor()

//removes from view all tags in tagContainer with the expection of Image Active and adds the images to the non active image
//It assumes the tagActive and tagContiner already have the properties
function classToggleLayerImg(tagContainer,tagActive,strClassName,strTAGName,strActiveImg,strNonActiveImg)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName
		if(arrTAG[intIndex].className == strClassName && arrTAG[intIndex].id != tagActive.id)
			arrTAG[intIndex].src = strNonActiveImg;
		else if(arrTAG[intIndex].id == tagActive.id)
			arrTAG[intIndex].src = strActiveImg;
	}//end of for loop
}//end of classToggleLayerImg()

//removes from view all tags in tagContainer with the expection of tagActive and creates a link for the active and a label for the none 
//active also remove the old tag
//It assumes the tagActive and tagContiner already have the properties
function classToggleLayerTag(tagContainer,tagActive,strClassName,strTAGName,strName,strLink,strOnClick)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1; intIndex--)
	{		
		//checks if the class name is the same as strClassName and it is not active if it is active then change the dispaly to block
		if(arrTAG[intIndex].className == strClassName && arrTAG[intIndex].id != tagActive.id)
		{
			//remove the tag from arrTAG[intIndex}
			arrTAG[intIndex].removeChild(arrTAG[intIndex].childNodes[0]);
			
			//create link and for the nonActive
			createLink(tagContainer,strLink,strOnClick,strName,strClassName);
		}//end of if
		else if(arrTAG[intIndex].id == tagActive.id && tagActive.style.display == "")
			addNode(tagContainer.id,strName,false,true)
	}//end of for loop
}//end of classToggleLayerTag()

//sets up the basic Links since they are so many of them for Links ONLY
function createLink(tagTD,strLink,strOnClick,strNameTag,strClassName)
{
	//sets the Attributes for the tagA then adds it to the table
	tagA = document.createElement('a');//holds the Linking tag
	tagA.setAttribute('href',strLink);
	if (strClassName != '') tagA.setAttribute('class', strClassName);
	if (strOnClick != '') tagA.setAttribute('onclick',strOnClick);
	tagA.appendChild(document.createTextNode(strNameTag));
	tagTD.appendChild(tagA);
	
	return true;
}//end of createLink()

//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()

//gives the user the message has been sent or not and changes the pop area
function endMessage(strEndMessage,strID,tagMessage,tagGrayOut,tagEMailBody)
{
	var tagPopUpArea = getDocID(strID);//holds the pop up area
	var arrActullyEndMassage = strEndMessage.split("</head>");//gets the acrtully end message because ASP.NET has alot of useless overhead
	
	//adds some text to the div tag and then displays it to the user
	displayMessage(tagMessage,arrActullyEndMassage[1],true,true);
	
	//adds in the new line
	tagPopUpArea.appendChild(document.createElement('br'));
	
	//checks if there is the finction was called by the Contact form which does not have a CSS Pop-Up Window
	if (strID != "")
	{
		var tagDIV = document.createElement('div');//holds the DIV tag
		
		//holds the real time div and give its name and align and the link that will close the pop up
		tagDIV.setAttribute('id', "divClose" + strID);
		tagDIV.setAttribute('align', "center");
		tagPopUpArea.appendChild(tagDIV);
	}//end of if
}//end of endMessage()

//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()

//gets the document properties in order to use them as there are many types of browers with different versions by the Name
function getDocName(tagLayer)
{
	var tagProp = "";//holds the proerties of tagLayer

	tagProp = document.getElementsByName(tagLayer);
		
	return tagProp;
}//end of getDocName()

//does a group tigger that hides or displays tags
function groupToggleLayer(tagUpperPrice,tagRecommend,tagLine,boolIsShowing)
{
	//gets the properties
	tagUpperPrice = getDocID(tagUpperPrice);
	tagRecommend = getDocID(tagRecommend);
	tagLine = getDocID(tagLine);
	
	if (tagUpperPrice != null && boolIsShowing == false)
		tagUpperPrice.style.display = "none";
	else if(tagUpperPrice != null && boolIsShowing == true)
		tagUpperPrice.style.display = "";
		
	if (tagRecommend != null && boolIsShowing == false)
		tagRecommend.style.display = "none";
	else if(tagRecommend != null && boolIsShowing == true)
		tagRecommend.style.display = "";
		
	if (tagLine != null && boolIsShowing == false)
		tagLine.style.display = "none";
	else if(tagLine != null && boolIsShowing == true)
		tagLine.style.display = "";    
}//end of groupToggleLayer()

//Changes the layers of the information section of item detail
function infoDetailLayer(whichLayer,layer1,layer2,layer3)
{
	var activeLayer = "";//holds the active Layer	
	var style2 = "";//holds the style of layer1
	var style3 = "";//holds the style of layer2
	var style4 = "";//holds the style of layer3

	// this is the way the standards work
	if (whichLayer != ''){activeLayer = getDocID(whichLayer);}
	if (layer1 != ''){style2 = getDocID(layer1);}
	if (layer2 != ''){style3 = getDocID(layer2);}
	if (layer3 != ''){style4 = getDocID(layer3);}

	//Checks if there is an active layer
	if (activeLayer != "" && activeLayer != null)
	{
		//checks if the activeLayer is already active and if so then skips code
		//since the layer cannot be turn off and leave a hole in the review layer
		if (activeLayer.style.display == "")
		{
			//removes the block from the display in order to make the layer to disapper	
			if (style2 != '')
				style2.style.display = style2.style.display? "":"";

			//checks if there is a style3
			if (style3 != '')
				style3.style.display = style3.style.display? "":"";
				
			//checks if there is a style3
			if (style4 != '')
				style4.style.display = style4.style.display? "":"";
	
			//displays the new active Layer and updates its id
			activeLayer.style.display = activeLayer.style.display? "":"block";
		}//end of if
	}//end of if
}//end of infoDetailLayer()

//removes all new lines and replaces them with a <br/> html tag
function nl2br(strText)
{
	//checks if there is anything inside strText
	if (strText != "")
	{
 		var re_nlchar = "";//holds the different newlines that the OS uses
		strText = escape(strText);//in codes strText to be more like a URL to find the newlines
			
		//finds the either \r or \n or both since \r is for Linex and Apple and \n is for MS
		if(strText.indexOf('%0D%0A') > -1)
			re_nlchar = /%0D%0A/g ;
		else if(strText.indexOf('%0A') > -1)
			re_nlchar = /%0A/g ;
		else if(strText.indexOf('%0D') > -1)
			re_nlchar = /%0D/g ;
	
		//checks if there is any new lines in strText
		if (re_nlchar != "")
			//changes the strText back to normal with all of the newlines changes to <br/> tag
			return unescape(strText.replace(re_nlchar,'<br />'));
	}//end of if
	
	return strText;
}//end of nl2br()

//set up the form to not be used while sending the message
function preSendEMail(tagMessage,tagEMailBody)
{
	//display to the user their message is beening sent and disables the textbox area
	displayMessage(tagMessage,'Sending Message...',true,true);
	tagEMailBody.style.display = 'none';
}//end of preSendEMail()

//rejects 2 tags to mach one another hieght wiase
function rejustHeight(tagCotentHolder,tagActionLinkHolder)
{
	//check if action already has a hieght and if so then removes it
	if(getDocID(tagActionLinkHolder).style.height != "") 
		getDocID(tagActionLinkHolder).style.height = "";
	
	//checks if tagContentHolder the one with all of the content of the Product is
	//longer then the action link holder and if so then do the funciton
	//to make them equal
	if(getDocID(tagCotentHolder).offsetHeight > 716)
		//makes sure that both the div for the action and the div for the content are equal
		P7_equalCols2(0,tagCotentHolder,'label',tagActionLinkHolder,'div');
	else
		//floors the height to a min amount
		getDocID(tagActionLinkHolder).style.height = "716px";
}//end of rejustHeight()

//removes all contorls from tagContent
function removeAll(tagContent)
{
	tagContent = getDocID(tagContent);//holds the Content that 
		
	if (tagContent != null)
	{		
		for(var intIndex = 0; intIndex < tagContent.childNodes.length; intIndex++)
		{
			tagContent.removeChild(tagContent.childNodes[intIndex]);
		}//end of for loop
		
	}//end of if	
}//end of removeAll()

//does the search bar onForcus Event
function searchBarForce(tagContainer,strClassName,strTAGName,strColor,strValue)
{
	//gets the search bar properties
	var arrTAG = getDocID(tagContainer).getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer

	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName
		if(arrTAG[intIndex].className == strClassName)
		{
			//changes the color and text to blank when the user frocus on the textbox
		    arrTAG[intIndex].style.color = strColor;
    		arrTAG[intIndex].value = strValue;
		}//end of if
	}//end of for loop
}//end of searchBarForce()

//does the search bar onblur Event(focus off)
function searchBarFocusOff(tagContainer,strClassName,strTAGName)
{
	//gets the search bar properties
	var arrTAG = getDocID(tagContainer).getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer

	//goes around the for each tag that getElementsByTagName found in tagContainter
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--) 
	{
		//checks if the class name is the same as strClassName
		if(arrTAG[intIndex].className == strClassName)
		{
			if(arrTAG[intIndex].value=="")
			{
				//changes the color and text when the user leave the textbox
	    		arrTAG[intIndex].style.color = "#C0c0c0";
   				arrTAG[intIndex].value = " title/series/ISBN/author";
			}//end of if	
		}//end of if
	}//end of for loop
}//end of searchBarFocusOff()

//sends an email to a Friend of the user who ment what a Product
function sendShareEMail(strFileName,tagGrayOut,tagMessage,strPopUpID,tagEMailBody,tagName,tagSendTo,tagEMail,tagComm,strProductName,strProductNameURL)
{		
	var strFilter = /^.+@.+\..{2,3}$/;//holds the filtter for the Email
	var htmlJavaServerObject = getXMLHttpRequest();//holds the object of the server
	var arrSendTo = tagSendTo.value.split(';');//holds all of the e-mail address that are going to be sent out

	//checks if they have a E-Mail
	if (tagSendTo.value=="")
  		{displayMessage(tagMessage,'You must have e-mail address, that you are sending to',true,true);
			return false;}
		
	//goes around each e-mail the user entered
	for(var intIndex = arrSendTo.length - 1; intIndex > -1;intIndex--)
	{
		//checks if there the E-Mail Format is current
		if (strFilter.test(arrSendTo[intIndex]) == false)
  			{displayMessage(tagMessage,"Please input Valid e-mail address for " + arrSendTo[intIndex],true,true);
				return false;}
		else if (arrSendTo[intIndex].match(/[\(\)\<\>\,\;\:\\\/\"\[\]]/))
  			{displayMessage(tagMessage,"The e-mail address, " + arrSendTo[intIndex]  + ", that you are sending to, contains illegal Characters.",true,true);
				return false;}
	}//end of for loop

	//checks if there is a Name
	if (tagName.value=="")
  		{displayMessage(tagMessage,'You must have a name entered',true,true);
			return false;}
				
	//checks if there is E-Mail
	if (tagEMail.value=="")
  		{displayMessage(tagMessage,'You must have e-mail address',true,true);
			return false;}	
			
	//checks if there the E-Mail Format is current
	if (strFilter.test(tagEMail.value) == false)
  		{displayMessage(tagMessage,'Please input valid e-mail address, for yourself!',true,true);
			return false;}
	else if (tagEMail.value.match(/[\(\)\<\>\,\;\:\\\/\"\[\]]/))
  		{displayMessage(tagMessage,'Your e-mail address contains illegal characters.',true,true);
			return false;}
		
	//Abort any currently active request.
	htmlJavaServerObject.abort();
	
	//prepers the form for sending a e-mail
	preSendEMail(tagMessage,tagEMailBody);
	
	// Makes a request
 	htmlJavaServerObject.open("Post", strFileName, true);
	htmlJavaServerObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	htmlJavaServerObject.onreadystatechange = function(){
    	if(htmlJavaServerObject.readyState == 4 && htmlJavaServerObject.status == 200)
		{
			//closes the pop up and removes the textbox so the user cannot use them again until they refresh the page
			endMessage(htmlJavaServerObject.responseText,strPopUpID,tagMessage,tagGrayOut,tagEMailBody);
							
			//resets the fields and disables the field area
            tagSendTo.value = "";
			tagName.value = "";
			tagEMail.value = "";
			tagComm.value = "";
			
			//means dispapire
			tagEMailBody.style.display = "";
		}//end of if
		else if(htmlJavaServerObject.readyState == 2 && htmlJavaServerObject.status == 500)
		{
			//closes the pop up and removes the textbox so the user cannot use them again until they refresh the page
			endMessage('<head></head>Unable to Connect to the Server.</head>',strPopUpID,tagMessage,tagGrayOut,tagEMailBody);
		}//end of else if
	}//end of function()
	
	htmlJavaServerObject.send("txtName=" + encodeURL(tagName.value) + "&txtFromEMail=" + encodeURL(tagEMail.value) + "&txtComm=" + encodeURL(nl2br(tagComm.value)) + "&txtSendTo=" + encodeURL(tagSendTo.value) + "&ProductName=" + encodeURL(strProductName) + "&ProductNameURL=" + encodeURL(strProductNameURL));
			
	return true;
}//end of sendShareEMail()

//starts up the page
//tagContainer,strClassName,strTAGName
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();
														
		//finds which browser the user is using for Firefox it is the defult
		//for IE 
		if (navigator.userAgent.indexOf('MSIE') != -1)
		{
			/*//checks if IE is 7 as IE 8 is more standards compliated

			if(navigator.appVersion.indexOf('MSIE 7') != -1)
			{*/
				var tagCSI = getDocID('divCSI');//holds LD of the Product Details
				var tagEMailBuy = getDocID('ctl00_wpm_ShowProduct_ctl03_divProductPriceFooter');//holds the Option CSS of the Product has two options
				var tagTempOptionsOne = getDocID('ctl00_wpm_ShowProduct_ctl03_divTempOptionsOneFooter');//holds the Option CSS of the Product has one options
				var tagTempOptionsZero = getDocID('divTempOptionsZero');//holds the Option CSS of the Product has ero options
				var tagFooterLodgeNavigation = getDocID('divFooterLodgeNavigation');//holds the Option CSS of the Product has ero options
				
				//checks if there the page is in the Product Details
				if(tagCSI != null)
				{
					tagCSI.style.marginLeft = "150px";
					tagCSI.style.left = "-1px";
				}//end of if
					
				//checks if there the page is in the has two options
				if(tagEMailBuy != null)
					tagEMailBuy.style.paddingTop = "15px";
		
				//checks if there the page is in the Product has one option
				if(tagTempOptionsOne != null)
					tagTempOptionsOne.style.paddingTop = "3px";
						
				//checks if there the page is in the Product has no options
				if(tagTempOptionsZero != null)
					tagTempOptionsZero.style.paddingTop = "15px";
						
				//checks if there the page has a Italo Store display
				if(tagFooterLodgeNavigation!= null)
				{
					var tagFooterLodgeContent = getDocID('divFooterLodgeContent');//holds the Option CSS of the divFooterLodgeContent
					
					tagFooterLodgeNavigation.style.width = "50px";
					tagFooterLodgeContent.style.marginRight = "13px";
				}//end of if
				
				var tagLodgeSidebar = getDocID('divLodgeSidebar');//holds the LodgeSidebar For the Wordpress area
				
				//checks if there the page is in the Product has no options
				if(tagLodgeSidebar != null && navigator.appVersion.indexOf('MSIE 7') != -1)
						tagLodgeSidebar.style.marginRight = "0";

			//}//end of if
		}//end of if
		//for Safari and Mac
		else if (navigator.userAgent.indexOf('Safari') !=-1 || navigator.platform.indexOf("Mac") > -1)
		{
			var tagEMailBuy = getDocID('ctl00_wpm_ShowProduct_ctl03_divProductPriceFooter');//holds the Option CSS of the Product has two options
			var tagTempOptionsOne = getDocID('ctl00_wpm_ShowProduct_ctl03_divTempOptionsOneFooter');//holds the Option CSS of the Product has one options
			var tagTempOptionsZero = getDocID('divTempOptionsZero');//holds the Option CSS of the Product has ero options
			var tagLodgeSidebar = getDocID('divLodgeSidebar');//holds the LodgeSidebar For the Wordpress area
				
			//checks if there the page is in the Product has no options
			if(tagLodgeSidebar != null)
			{
					//tagLodgeSidebar.style.width = "0";
					tagLodgeSidebar.style.padding = "0 0 7px 675px";
					tagLodgeSidebar.style.backgroundColor = "#FFF";
			}//end of if
			
			//checks if there the page is in the has two options
			if(tagEMailBuy != null)
					tagEMailBuy.style.paddingTop = "0px";
	
			//checks if there the page is in the Product has one option
			if(tagTempOptionsOne != null)
					tagTempOptionsOne.style.paddingTop = "0px";
					
			//checks if there the page is in the Product has no options
			if(tagTempOptionsZero != null)
					tagTempOptionsZero.style.paddingTop = "0px";
		}//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)
		{
			var tagEMailBuy = getDocID('ctl00_wpm_ShowProduct_ctl03_divProductPriceFooter');//holds the Option CSS of the Product has two options
			var tagTempOptionsOne = getDocID('ctl00_wpm_ShowProduct_ctl03_divTempOptionsOneFooter');//holds the Option CSS of the Product has one options
			var tagTempOptionsZero = getDocID('divTempOptionsZero');//holds the Option CSS of the Product has ero options
				
			//checks if there the page is in the has two options
			if(tagEMailBuy != null)
					tagEMailBuy.style.paddingTop = "18px";
	
			//checks if there the page is in the Product has one option
			if(tagTempOptionsOne != null)
					tagTempOptionsOne.style.paddingTop = "5px";
					
			//checks if there the page is in the Product has no options
			if(tagTempOptionsZero != null)
					tagTempOptionsZero.style.paddingTop = "10px";
		}//end of if else	
	}//end of window.onload=function()
}//end of startUp()

//shoes and hides a <div> using display:block/none from the CSS
function toggleLayer(tagLayer,tagGrayOut,tagMedia)
{
	var tagStyle = '';//holds the style of tagLayer

	//gets the tagLayer and tagGrayOut Properties
	tagStyle = getDocID(tagLayer);
	tagGrayOut = getDocID(tagGrayOut);
	tagMedia = getDocID(tagMedia);
		
	if (tagStyle != null)
	{tagStyle.style.display = tagStyle.style.display? "":"block";}
	
	if (tagGrayOut != null)
	{
		tagGrayOut.style.display = tagGrayOut.style.display? "":"block";

		//for IE
		if (navigator.userAgent.indexOf('MSIE') != -1)
		{
			tagGrayOut.attachEvent('onclick',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id)
				
				//specal case pleace remove when REUSING THIS FUNCTION 
				infoDetailLayer('divShareFriendsBody','divShareMessage','','');
				
				//checks if there is any Media to stop also pleace remove when REUSING THIS FUNCTION 
				if (tagMedia != null)
					tagMedia.Stop();
			});
		}//end of if
		//for the other browsers
		else
		{
			tagGrayOut.addEventListener('click',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id);
				
				//specal case pleace remove when REUSING THIS FUNCTION 
				infoDetailLayer('divShareFriendsBody','divShareMessage','','');
			},false);
		}//end of else
	}//end of if
}//end of toggleLayer()

//shoes and hides a <div> using display:block/none from the CSS
function toggleLayerDisplayNone(tagLayer)
{
	var tagStyle = '';//holds the style of tagLayer

	//gets the tagLayer and tagGrayOut Properties
	tagStyle = getDocID(tagLayer);
	
	if (tagStyle != null){tagStyle.style.display = "none";}
}//end of toggleLayer()

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com

    var c,e,el;if(document.getElementById){document.p7eqc=new Array();
    document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
    c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
    if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
    document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
    setInterval("P7_eqT2()",10);}
   
    
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

/* test */
function alertSize() {
  var myWidth = 0;//, myHeight = 0;
//  if( typeof( window.innerWidth ) == 'number' ) {
//    //Non-IE
//    myWidth = window.innerWidth;
//    myHeight = window.innerHeight;
//  } else 
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    //myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    //myHeight = document.body.clientHeight;
  }
  
  return myWidth;
  //window.alert( 'Height = ' + myHeight );
}