/*
	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
//It assumes the tagMovie and tagEmbed already have the properties
function changeFlashMovie(tagMovie,tagEmbed,strHeight,strWidth,strWmode,strPluginspage,strController,strType,strAutostart,strSRC)
{
	tagMovie.value = strSRC;
	tagEmbed.innerHTML = "<embed height=\"" + strHeight + "\" width=\"" + strWidth + "\" wmode=\"" + strWmode + "\" pluginspage=\"" + strPluginspage + "\" controller=\"" + strController + "\" type=\"" + strType + "\" autostart=\"" + strAutostart + "\" src=\"" + strSRC + "\"/>";
}//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 LightBox Title to Change
	if(tagLightBoxTitle != null)
		tagLightBoxTitle.innerHTML = strLightBoxTitle;
		
	//checks if there is a tagTarget on the page
	if(tagImage != null)
	{
		//sets the style to be the new iamge
		if(strImage != "")
		{			
			tagImage.src = strImage;
						
			//checks if the width is bigger then height
			/*if(tagImage.width > tagImage.height)
				tagImage.width = 325;
			else
				tagImage.height = 325;*/	
		}//end of if
	}//end of if
	
	//checks if there is a TItle Bar to move in order for the Image to be as big as it wants to be
	if(tagTitleBar != null)
	{
		var intTitleBarStyle = 0;
		
		//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 changeImageLightBox()

//select or unselected all checkboxs in tagContainer
//It assumes the tagContiner already have the properties
//REMOVE strQTY IF REUSING THIS FUNCTION
function checkAll(tagContainer,boolSelect,strQTY,strTAGName)
{
	var arrTAG = tagContainer.getElementsByTagName(strTAGName);//holds all strTAGName in tagContainer
	
	//goes around and finds each checkbox on the page and selected
	for(var intIndex = arrTAG.length - 1; intIndex > -1 ; intIndex--)
	{
		//gest the tag Properties
		tagProperties = arrTAG[intIndex];
		
		//checkc which type the tag is
		if (tagProperties.type == 'checkbox')
			tagProperties.checked = boolSelect;
		//REMOVE THIS ELSE IF REUSING THIS FUNCTION
		else (tagProperties.type == 'text')
			tagProperties.value = strQTY;
	}//end of for loop
}//end of checkAll()

//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 classRevToggleLayer()

//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()

//changes strClassName with strActiveClassName
//It assumes the tagActive and tagContiner already have the properties
function classToggleLayerChangeClass(tagContainer,tagActive,strActiveClassName,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].className = strActiveClassName;
	}//end of for loop
}//end of classToggleLayerChangeClass()

//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()

//this is for the duel layers that sometimes is need
function duelToggleLayer(whichLayer,layer1,layer2)
{
	var activeLayer = "";//holds the active Layer	
	var style2 = "";//holds the style of layer1
	var style3 = "";//holds the style of layer2

	// this is the way the standards work
	if (whichLayer != ''){activeLayer = getDocID(whichLayer);}
	if (layer1 != ''){style2 = getDocID(layer1);}
	if (layer2 != ''){style3 = getDocID(layer2);}

	//Checks if there is an active layer
	if (activeLayer != "")
	{
		//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? "":"";}
	
			//displays the new active Layer and updates its id
			activeLayer.style.display = activeLayer.style.display? "":"block";
		}//end of if
	}//end of if
}//end of duelToggleLayer()

//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()

//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,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)
		{
			if(arrTAG[intIndex].value=="")
			{
				//changes the color and text when the user leave the textbox
	    		arrTAG[intIndex].style.color = strColor;
   				arrTAG[intIndex].value = strValue;
			}//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
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)
		  {
			  if(navigator.appVersion.indexOf('MSIE 7') != -1)
			  {
			  }//end of if
			  
			  var tagBuyFoundationContainer = getDocID('divBuyFoundationContainer');//holds divBuyFoundationContainer
				  
			  if(tagBuyFoundationContainer != null)
			  {
				 classToggleLayerChangeClass(tagBuyFoundationContainer,'',"customContainer divIECheckAddBasketContainer","customContainer divCheckAddBasketContainer","div");
			  }//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 tagBuyArea = getDocID('divBuyArea');//holds divBuyArea
				  
			  if(tagBuyArea != null)
			  {
				 classToggleLayerChangeClass(tagBuyArea,'',"customNavigation divShadesNavigation divSafProductQTY","customNavigation divShadesNavigation divProductQTY","div");
			  }//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()

//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 it an item needs to close and reload the page as some of the pages use HTML to change the look of the Lightbox but ASP.NET's viewstate changes to much for Postback to work
				if(getDocID('divShadeFaces') != null || getDocID('divSkinRosaceaVideo') != null || getDocID('divSkinAcneVideo') != null || getDocID('divSkinUnderEyeVideo') != null || getDocID('divSkinTattooVideo') != null || getDocID('divSkinMelasmaVideo') != null || getDocID('divSkinVitiligoVideo') != null || getDocID('divSkinBruisingVideo') != null || getDocID('divSkinScarsVideo') != null || getDocID('divSkinEczemaVideo') != null || getDocID('divSkinPsoriasisVideo') != null || getDocID('divSkinBirthmarksVideo') != null || getDocID('divSkinBurnsVideo') != null || getDocID('divSkinSkinCancerVideo') != null)
					window.location.reload();
				
				//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);
				
			//checks if it an item needs to close and reload the page as some of the pages use HTML to change the look of the Lightbox but ASP.NET's viewstate changes to much for Postback to work
			if(getDocID('divShadeFaces') != null)
				window.location.reload();
				
				//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()



/*kamila*/


function layerSetup(id,visibility){
if(document.getElementById){
this.obj = document.getElementById(id).style;
this.obj.visibility = visibility;
return this.obj;}
else if(document.all){
this.obj = document.all[id].style;
this.obj.visibility = visibility;
return this.obj;}
else if(document.layers){
this.obj = document.layers[id];
this.obj.visibility = visibility;
return this.obj;}
}
function visVisible(param){
new layerSetup(param,'visible');
}

function visHidden(param){
new layerSetup(param,'hidden');
}

