
//This code defines a function that will toggle the visibility of an element based on its ElementID
function ToggleVisibility(ElementID)
{
    var CurrentDisplaySetting = document.getElementById(ElementID).style.display;
    if(CurrentDisplaySetting.indexOf("none") >= 0)
    {
        // The current display is hidden ... so show it.
        document.getElementById(ElementID).style.display = "";
    }
    else
    {
        // The current display currently shown ... so hide it.
        document.getElementById(ElementID).style.display = "none";
    }
}

// This function is a "work around" to allow users to view embedded content in MSIE without first having
// to click on the embedded object to activate it
function ShowEmbeddedContent(objecttag)
{
    document.write(objecttag);
}

// This function opens a popup in the center of the screen and assigned the given parameters to it
function OpenCenterPopUp(url, title, width, height)
{
	var TopLeftX = Math.round(screen.width/2 - width/2);
	var TopLeftY = Math.round(screen.height/2 - height/2);
	var NewWindow = window.open(url,title,'top='+TopLeftY+', left='+TopLeftX+', width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
	NewWindow.focus();
}

// This function opens a popup in the center of the screen and assigned the given parameters to it
function OpenCenterPopUpScroll(url, title, width, height)
{
	var TopLeftX = Math.round(screen.width/2 - width/2);
	var TopLeftY = Math.round(screen.height/2 - height/2);
	var NewWindow = window.open(url,title,'top='+TopLeftY+', left='+TopLeftX+', width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
	NewWindow.focus();
}

// This function is similiar to OpenCenterPopUp, except that it allows the user to see things like the toolbar, location, etc.
function OpenNewWindow(url, title, width, height)
{
	var TopLeftX = screen.width/2 - width/2;
	var TopLeftY = screen.height/2 - height/2;
	var NewWindow = window.open(url,title,'top='+TopLeftY+', left='+TopLeftX+', width='+width+',height='+height+',directories=yes,location=yes,menubar=yes,status=yes,toolbar=yes,resizable=yes');
	NewWindow.focus();
}

function OpenWindow(url,name,attributes) 
{
    var windowHandle = '';
    windowHandle = window.open(url,name,attributes);
}

function OpenCalendarPopUp(FormElement)
{
	OpenCenterPopUp('/Calendar.aspx?FormElement=' + FormElement, 'CalendarWindow', 175, 135);
}

function ChangeClass(TableName, CellIndex, NewClass)
{
	var TableElement, TableCells;
	
	if(document.getElementById)
		TableElement = document.getElementById(TableName);
	else 
		TableElement = document.all(TableName);
	
	if(TableElement == null)
		return;
		
	if(TableElement.getElementsByTagName)
		TableCells = TableElement.getElementsByTagName("td");
	else 
		TableCells = TableElement.all.tags("td");
	
	if(TableCells == null)
		return;
		
	if(TableCells.length <= CellIndex)
		return;
	
	TableCells[CellIndex].className = NewClass;
}

function SetDefaultButton(btn, event)
{
    if(document.all)
    {
		if(event.keyCode == 13)
		{
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
    else if(document.getElementById)
    {
        if(event.which == 13)
        {
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
    else if(document.layers)
    {
        if(event.which == 13)
        {
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
}

// Set the focus to the first textbox
function SetFocus()
{
	var NumElements = document.forms[0].elements.length;
	for (i=0; i < NumElements; i++)
	{
   		if (document.forms[0].elements[i].type == "textarea" ||  document.forms[0].elements[i].type == "text")
		{
			document.forms[0].elements[i].focus();
		    break;
   		}
	}
}

function SetFocus(Element)
{
	if(Element != null)
	{
		if(document.getElementById(Element) != null)
		{
			document.getElementById(Element).focus();
		}
	}
}

function ValidateUSNumber(sender, args)
{
	var SelectedCountryID = document.getElementById("ddlCountry").value;

	// Check to see if the United States is the selected country, and if it is perform the validation
	if(SelectedCountryID == document.getElementById("hdnUSCountryID").value)
	{
		// Check thisNumber against the regular expression for valid U.S. Numbers
		var thisNumber = new String(args.Value); 
		var thisExp = new RegExp("(^1?[-.]?\\d{10}$)|(^1?[-.]?\\d{3}[-.]\\d{3}[-.]\\d{4}$)|(^1?[-.]?[-.]?\\(\\d{3}\\)\\d{3}[-.]\\d{4}$)|(^1?[-.]?\\(\\d{3}\\) \\d{3}[-.]\\d{4}$)");
		if(!thisNumber.match(thisExp))
		{
			args.IsValid = false;
			return;
		}
	}
	args.IsValid = true;
}

//This function resets all the controls form.
function ResetForm()
{
	if (document.getElementById('hdnSubmitted').value == 1)
	{
		var form, elements, i, elm; 
		form = document.getElementById("Form1");
				
		elements = form.elements;
		for( i=0, elm; i < elements.length; i++)
		{
			elm = elements[i];
			if (elm.getAttribute('type') == "text")
			{
				elm.value = '';
			}
			else if (elm.getAttribute('type') == "checkbox" || elm.getAttribute('type') == "radio")
			{
				elm.checked = false;
			}
			else if (elm.name.indexOf("ddl") > -1)
			{
				elm.options[0].selected = true;
			}
		}
	}
}

function ScrollIt()
{
	window.scrollTo(document.Form1.PageX.value, document.Form1.PageY.value);
}

function setcoords()
{
	var myPageX;
	var myPageY;
	if (document.all)
	{
		myPageX = document.body.scrollLeft;
		myPageY = document.body.scrollTop;
	}
	else
	{
		myPageX = window.pageXOffset;
		myPageY = window.pageYOffset;
	}
	document.Form1.PageX.value = myPageX;
	document.Form1.PageY.value = myPageY;
}

function MaxLength(field, maxlimit)
{
	// This function sets MaxLength for the MultiLine Textbox that it is passed.
	// It is called in the asp:TextBox tag like this: onKeyDown="MaxLength(this,500);" 
	// Created by Cal Zant
	if (field.value.length >= maxlimit)
		field.value = field.value.substring(0, maxlimit-1);
}

function ConfirmDelete(Command, Title, Resource)
{
	if(confirm('Are you sure that you want to delete "' + Title + '" from your ' + Resource + '?')) 
	{
		eval(Command);
	}		
}

function RefreshPage(URL)
{
	setTimeout("window.location.replace('" + URL + "')", 750);
}

function IsDaylightSavings(thisDate)
{
	var S2005 = new Date("April 3, 2005 02:00:00");
	var E2005 = new Date("October 30, 2005 02:00:00");
	var S2006 = new Date("April 2, 2006 02:00:00");
	var E2006 = new Date("October 29, 2006 02:00:00");
	var S2007 = new Date("April 1, 2007 02:00:00");
	var E2007 = new Date("October 28, 2007 02:00:00");
	var S2008 = new Date("April 6, 2008 02:00:00");
	var E2008 = new Date("October 26, 2008 02:00:00");
	var S2009 = new Date("April 5, 2009 02:00:00");
	var E2009 = new Date("October 25, 2009 02:00:00");
	var S2010 = new Date("April 4, 2010 02:00:00");
	var E2010 = new Date("October 31, 2010 02:00:00");
	
	var IsDS = false;
	if(thisDate > S2005 && thisDate < E2005) IsDS = true;
	else if(thisDate > S2006 && thisDate < E2006) IsDS = true;
	else if(thisDate > S2007 && thisDate < E2007) IsDS = true;
	else if(thisDate > S2008 && thisDate < E2008) IsDS = true;
	else if(thisDate > S2009 && thisDate < E2009) IsDS = true;
	else if(thisDate > S2010 && thisDate < E2010) IsDS = true;
	
	return IsDS;
}

// Appends the given content to the div tag with the given DivTagID.
function AppendToDivTag(DivTagID, Content)
{
	if (document.layers)
	{
		var oLayer = document.layers[DivTagID].document;
		oLayer.open();
		oLayer.write(document.layers[DivTagID].value + Content);
		oLayer.close();
	}
	else if(parseInt(navigator.appVersion)>=5 && navigator.appName == "Netscape")
		document.getElementById(DivTagID).innerHTML = document.getElementById(DivTagID).innerHTML + Content;
	else if (document.all)
		document.all[DivTagID].innerHTML = document.all[DivTagID].innerHTML + Content;
}

// Write the given content to the div tag with the given DivTagID, and replace any content that is already there.
function WriteToDivTag(DivTagID, Content)
{
	if (document.layers)
	{
		var oLayer = document.layers[DivTagID].document;
		oLayer.open();
		oLayer.write(Content);
		oLayer.close();
	}
	else if(parseInt(navigator.appVersion)>=5 && navigator.appName == "Netscape")
		document.getElementById(DivTagID).innerHTML = Content;
	else if (document.all)
		document.all[DivTagID].innerHTML = Content;
}

function GetDivTagContents(DivTagID)
{
	if (document.layers)
		return oLayer = document.layers[DivTagID].value;
	else if(parseInt(navigator.appVersion)>=5 && navigator.appName == "Netscape")
		return document.getElementById(DivTagID).innerHTML;
	else if (document.all)
		return document.all[DivTagID].innerHTML;
}

function Replace(string, OldValue, NewValue)
{
	// Replaces OldValue with NewValue in string
	var strLength = string.length;
	var OldLength = OldValue.length;
	if ((strLength == 0) || (OldLength == 0)) return string;

	var i = string.indexOf(OldValue);
	if ((!i) && (OldValue != string.substring(0,OldLength))) return string;
	if (i == -1) return string;

	var NewString = string.substring(0,i) + NewValue;

	if (i+OldLength < strLength)
		NewString += Replace(string.substring(i+OldLength,strLength),OldValue,NewValue);

	return NewString;
}


// This function looks for form element who's ClientID contains the given ElementID.  If a
// ContentPlaceHolderID parameter is provided it will also require that the ClientID also contain that value
// as well.  It returns the first match.  NOTE: It is really designed for use with MasterPages in ASP.NET 2.0
// ... but will work with any version or site.
// Example: GetElement("btnSubmit");
// It would try to find an element who's ClientID contained the text "btnSubmit". Any of the following
// ClientIDs would result in a match: "btnSubmit", "ctl00_Header_btnSubmit", "ctl00_MainContent_btnSubmit",
// "k3hf75btnSubmitjfh493", , "btnSubmitPage".
// Example: GetElement("btnSubmit", "MainContent");
// It would try to find an element who's ClientID contained the text "btnSubmit", and "MainContent".  An
// element with the ClientID of "ctl00_MainContent_btnSubmit" would result in a match, but
// "ctl00_Header_btnSubmit" would not.
function GetElement(ElementID, ContentPlaceHolderID)
{
    var Element;
    if(ContentPlaceHolderID == null)
    {
        // Try to find the element the old fashioned way ... before master pages put a prefix on the id.
        Element = OldSchoolSearch(ElementID);
        if(Element != null)
            return Element;
    }
    
    var FormCount = document.forms.length;
    for(FormIndex = 0; FormIndex < FormCount; FormIndex++)
    {
	    var ElementCount = document.forms[FormIndex].elements.length;
	    for(ElementIndex = 0; ElementIndex < ElementCount; ElementIndex++)
	    {
	        Element = document.forms[FormIndex].elements[ElementIndex];
    		
            if(ContentPlaceHolderID == null)
            {
		        if(Element.id.indexOf(ElementID) >= 0)
			        return Element;
	        }
	        else
	        {
		        if(Element.id.indexOf(ElementID) >= 0 && ElementName.indexOf(ContentPlaceHolderID) > 0)
			        return Element;
	        }
	    }
    }
    
	return null;
}

function OldSchoolSearch(ElementID)
{
    // Tries to find the element the old fashioned way ... before master pages put a prefix on the id.
    var Element;
    
	if (document.layers)
	{
		Element = document.layers[ElementID]
	}
	else if(parseInt(navigator.appVersion)>=5 && navigator.appName == "Netscape")
		Element = document.getElementById(ElementID);
	else if (document.all)
		Element = document.all[ElementID];
		
    return Element;    
}

function AdvancePhoneFields(CurrentField, NextField)
{
    if (CurrentField.value.length == 3)
	{
		NextField.focus()
	}
}




// the following functions are used for in page popup boxes
function move_box(an, box, height)   
{   
    var cleft = 0;   
    var ctop = 0;   
    var obj = an;   
  
    while (obj.offsetParent)   
    {   
        cleft += obj.offsetLeft;   
        ctop += obj.offsetTop;   
        obj = obj.offsetParent;   
    }   
  
    box.style.left = cleft + 'px';   
  
    ctop += an.offsetTop - height - 35;   
  
    // Handle Internet Explorer body margins,   
    // which affect normal document, but not   
    // absolute-positioned stuff.   
    if (document.body.currentStyle &&   
        document.body.currentStyle['marginTop'])   
    {   
        ctop += parseInt(   
            document.body.currentStyle['marginTop']);   
    }   
  
    box.style.top = ctop + 'px';   
}   
  
// Hides other alone popup boxes that might be displayed   
function hide_other_alone(obj)   
{   
    if (!document.getElementsByTagName)   
        return;   
  
    var all_divs = document.body.getElementsByTagName("DIV");   
  
    for (i = 0; i < all_divs.length; i++)   
    {   
        if (all_divs.item(i).style.position != 'absolute' ||   
            all_divs.item(i) == obj ||   
            !all_divs.item(i).alonePopupBox)   
        {   
            continue;   
        }   
  
        all_divs.item(i).style.display = 'none';   
    }   
    return;   
}   
  
// Shows a box if it wasn't shown yet or is hidden   
// or hides it if it is currently shown   
function show_hide_box(an, width, height, borderStyle, type)   
{   
    document.getElementById('testlink').href =  'email_selections.aspx?type=' + type + '&outerbumper=' + window.escape(document.getElementById('outside_bumper').innerHTML) + '&innerbumper=' + window.escape(document.getElementById('inside_bumper').innerHTML) + '&ties=' + window.escape(document.getElementById('ties').innerHTML) + '&ruffle=' + window.escape(document.getElementById('ruffle').innerHTML) + '&sheet=' + window.escape(document.getElementById('sheet').innerHTML) + '&skirt=' + window.escape(document.getElementById('skirt').innerHTML);

    var href = an.href;   
    var boxdiv = document.getElementById(href);   
  
    if (boxdiv != null)   
    {   
        if (boxdiv.style.display=='none')   
        {   
            hide_other_alone(boxdiv);   
            // Show existing box, move it   
            // if document changed layout   
            move_box(an, boxdiv, height);   
            boxdiv.style.display='block';   
  
            // Workaround for Konqueror/Safari   
            if (!boxdiv.contents.contentWindow)   
                boxdiv.contents.src = href;   
        }   
        else  
            // Hide currently shown box.   
            boxdiv.style.display='none';   
        return false;   
    }  

  
    hide_other_alone(null);   
  
    // Create box object through DOM   
    boxdiv = document.createElement('div');   
  
    // Assign id equalling to the document it will show   
    boxdiv.setAttribute('id', href);   
  
    // Add object identification variable   
    boxdiv.alonePopupBox = 1;   
  
    boxdiv.style.display = 'block';   
    boxdiv.style.position = 'absolute';   
    boxdiv.style.width = width + 'px';   
    boxdiv.style.height = height + 'px';   
    boxdiv.style.border = borderStyle;   
    boxdiv.style.textAlign = 'right';   
    boxdiv.style.padding = '4px';   
    boxdiv.style.background = '#FFFFFF';
    boxdiv.style.zIndex = 50;  
    document.body.appendChild(boxdiv);   
  
    var offset = 0;   
  
    // Remove the following code if 'Close' hyperlink   
    // is not needed.   
    var close_href = document.createElement('a');   
    close_href.href = 'javascript:void(0);';   
    close_href.onclick = function()   
        { show_hide_box(an, width, height, borderStyle, type); }   
    close_href.appendChild(document.createTextNode('Close'));   
    boxdiv.appendChild(close_href);   
    offset = close_href.offsetHeight;   
    // End of 'Close' hyperlink code.   
  
    var contents = document.createElement('iframe');   
    //contents.scrolling = 'no';   
    contents.overflowX = 'hidden';   
    contents.overflowY = 'scroll';   
    contents.frameBorder = '0';   
    contents.style.width = width + 'px';   
    contents.style.height = (height - offset) + 'px';   
  
    boxdiv.contents = contents;   
    boxdiv.appendChild(contents);   
  
    move_box(an, boxdiv, height);   
  
    if (contents.contentWindow)   
        contents.contentWindow.document.location.replace(   
            href);   
    else  
        contents.src = href; 
  
    // The script has successfully shown the box,   
    // prevent hyperlink navigation.   
    return false;   
}   


// Shows a box if it wasn't shown yet or is hidden   
// or hides it if it is currently shown   
function show_hide_box2(an, width, height, borderStyle)   
{   
    document.getElementById('testlink').href =  'email_selections.aspx?type=kidsgirl&bedskirt=' + window.escape(document.getElementById('bedskirt').innerHTML) + '&comftop=' + window.escape(document.getElementById('comftop').innerHTML) + '&comftrim=' + window.escape(document.getElementById('comftrim').innerHTML) + '&comfunder=' + window.escape(document.getElementById('comfunder').innerHTML) + '&pillow=' + window.escape(document.getElementById('pillow').innerHTML) + '&pillowruff=' + window.escape(document.getElementById('pillowruff').innerHTML) + '&sham=' + window.escape(document.getElementById('sham').innerHTML) + '&shamruff=' + window.escape(document.getElementById('shamruff').innerHTML);

    var href = an.href;   
    var boxdiv = document.getElementById(href);   
  
    if (boxdiv != null)   
    {   
        if (boxdiv.style.display=='none')   
        {   
            hide_other_alone(boxdiv);   
            // Show existing box, move it   
            // if document changed layout   
            move_box(an, boxdiv, height);   
            boxdiv.style.display='block';   
  
            // Workaround for Konqueror/Safari   
            if (!boxdiv.contents.contentWindow)   
                boxdiv.contents.src = href;   
        }   
        else  
            // Hide currently shown box.   
            boxdiv.style.display='none';   
        return false;   
    }  

  
    hide_other_alone(null);   
  
    // Create box object through DOM   
    boxdiv = document.createElement('div');   
  
    // Assign id equalling to the document it will show   
    boxdiv.setAttribute('id', href);   
  
    // Add object identification variable   
    boxdiv.alonePopupBox = 1;   
  
    boxdiv.style.display = 'block';   
    boxdiv.style.position = 'absolute';   
    boxdiv.style.width = width + 'px';   
    boxdiv.style.height = height + 'px';   
    boxdiv.style.border = borderStyle;   
    boxdiv.style.textAlign = 'right';   
    boxdiv.style.padding = '4px';   
    boxdiv.style.background = '#FFFFFF';
    boxdiv.style.zIndex = 50;  
    document.body.appendChild(boxdiv);   
  
    var offset = 0;   
  
    // Remove the following code if 'Close' hyperlink   
    // is not needed.   
    var close_href = document.createElement('a');   
    close_href.href = 'javascript:void(0);';   
    close_href.onclick = function()   
        { show_hide_box2(an, width, height, borderStyle); }   
    close_href.appendChild(document.createTextNode('Close'));   
    boxdiv.appendChild(close_href);   
    offset = close_href.offsetHeight;   
    // End of 'Close' hyperlink code.   
  
    var contents = document.createElement('iframe');   
    //contents.scrolling = 'no';   
    contents.overflowX = 'hidden';   
    contents.overflowY = 'scroll';   
    contents.frameBorder = '0';   
    contents.style.width = width + 'px';   
    contents.style.height = (height - offset) + 'px';   
  
    boxdiv.contents = contents;   
    boxdiv.appendChild(contents);   
  
    move_box(an, boxdiv, height);   
  
    if (contents.contentWindow)   
        contents.contentWindow.document.location.replace(   
            href);   
    else  
        contents.src = href; 
  
    // The script has successfully shown the box,   
    // prevent hyperlink navigation.   
    return false;   
}   



// Shows a box if it wasn't shown yet or is hidden   
// or hides it if it is currently shown   
function show_hide_box3(an, width, height, borderStyle)   
{   
    document.getElementById('testlink').href =  'email_selections.aspx?type=kidsboy&bedskirt=' + window.escape(document.getElementById('bedskirt').innerHTML) + '&comftop=' + window.escape(document.getElementById('comftop').innerHTML) + '&comfunder=' + window.escape(document.getElementById('comfunder').innerHTML) + '&pillow=' + window.escape(document.getElementById('pillow').innerHTML) + '&pillowruff=' + window.escape(document.getElementById('pillowruff').innerHTML) + '&sham=' + window.escape(document.getElementById('sham').innerHTML) + '&shamruff=' + window.escape(document.getElementById('shamruff').innerHTML);

    var href = an.href;   
    var boxdiv = document.getElementById(href);   
  
    if (boxdiv != null)   
    {   
        if (boxdiv.style.display=='none')   
        {   
            hide_other_alone(boxdiv);   
            // Show existing box, move it   
            // if document changed layout   
            move_box(an, boxdiv, height);   
            boxdiv.style.display='block';   
  
            // Workaround for Konqueror/Safari   
            if (!boxdiv.contents.contentWindow)   
                boxdiv.contents.src = href;   
        }   
        else  
            // Hide currently shown box.   
            boxdiv.style.display='none';   
        return false;   
    }  

  
    hide_other_alone(null);   
  
    // Create box object through DOM   
    boxdiv = document.createElement('div');   
  
    // Assign id equalling to the document it will show   
    boxdiv.setAttribute('id', href);   
  
    // Add object identification variable   
    boxdiv.alonePopupBox = 1;   
  
    boxdiv.style.display = 'block';   
    boxdiv.style.position = 'absolute';   
    boxdiv.style.width = width + 'px';   
    boxdiv.style.height = height + 'px';   
    boxdiv.style.border = borderStyle;   
    boxdiv.style.textAlign = 'right';   
    boxdiv.style.padding = '4px';   
    boxdiv.style.background = '#FFFFFF';
    boxdiv.style.zIndex = 50;  
    document.body.appendChild(boxdiv);   
  
    var offset = 0;   
  
    // Remove the following code if 'Close' hyperlink   
    // is not needed.   
    var close_href = document.createElement('a');   
    close_href.href = 'javascript:void(0);';   
    close_href.onclick = function()   
        { show_hide_box3(an, width, height, borderStyle); }   
    close_href.appendChild(document.createTextNode('Close'));   
    boxdiv.appendChild(close_href);   
    offset = close_href.offsetHeight;   
    // End of 'Close' hyperlink code.   
  
    var contents = document.createElement('iframe');   
    //contents.scrolling = 'no';   
    contents.overflowX = 'hidden';   
    contents.overflowY = 'scroll';   
    contents.frameBorder = '0';   
    contents.style.width = width + 'px';   
    contents.style.height = (height - offset) + 'px';   
  
    boxdiv.contents = contents;   
    boxdiv.appendChild(contents);   
  
    move_box(an, boxdiv, height);   
  
    if (contents.contentWindow)   
        contents.contentWindow.document.location.replace(   
            href);   
    else  
        contents.src = href; 
  
    // The script has successfully shown the box,   
    // prevent hyperlink navigation.   
    return false;   
}   



// Shows a box if it wasn't shown yet or is hidden   
// or hides it if it is currently shown   
function show_hide_image(an, width, height, borderStyle)   
{   
    document.getElementById('testlink').href =  'email_selections.aspx?outerbumper=' + document.getElementById('outside_bumper').innerHTML + '&?innerbumper=' + document.getElementById('inside_bumper').innerHTML + '&?ties=' + document.getElementById('ties').innerHTML + '&?ruffle=' + document.getElementById('ruffle').innerHTML + '&?sheet=' + document.getElementById('sheet').innerHTML + '&?skirt=' + document.getElementById('skirt').innerHTML;

    var href = an.href;   
    var boxdiv = document.getElementById(href);   
  
    if (boxdiv != null)   
    {   
        if (boxdiv.style.display=='none')   
        {   
            hide_other_alone(boxdiv);   
            // Show existing box, move it   
            // if document changed layout   
            move_box(an, boxdiv, height);   
            boxdiv.style.display='block';   
  
            // Workaround for Konqueror/Safari   
            if (!boxdiv.contents.contentWindow)   
                boxdiv.contents.src = href;   
        }   
        else  
            // Hide currently shown box.   
            boxdiv.style.display='none';   
        return false;   
    }  

  
    hide_other_alone(null);   
  
    // Create box object through DOM   
    boxdiv = document.createElement('div');   
  
    // Assign id equalling to the document it will show   
    boxdiv.setAttribute('id', href);   
  
    // Add object identification variable   
    boxdiv.alonePopupBox = 1;   
  
    boxdiv.style.display = 'block';   
    boxdiv.style.position = 'absolute';   
    boxdiv.style.width = width + 'px';   
    boxdiv.style.height = height + 'px';   
    boxdiv.style.border = borderStyle;   
    boxdiv.style.textAlign = 'right';   
    boxdiv.style.padding = '4px';   
    boxdiv.style.background = '#FFFFFF';
    boxdiv.style.zIndex = 50;  
    document.body.appendChild(boxdiv);   
  
    var offset = 0;   
  
    // Remove the following code if 'Close' hyperlink   
    // is not needed.   
    var close_href = document.createElement('a');   
    close_href.href = 'javascript:void(0);';   
    close_href.onclick = function()   
        { show_hide_box(an, width, height, borderStyle); }   
    close_href.appendChild(document.createTextNode('Close'));   
    boxdiv.appendChild(close_href);   
    offset = close_href.offsetHeight;   
    // End of 'Close' hyperlink code.   
  
    var contents = document.createElement('iframe');   
    //contents.scrolling = 'no';   
    contents.overflowX = 'hidden';   
    contents.overflowY = 'scroll';   
    contents.frameBorder = '0';   
    contents.style.width = width + 'px';   
    contents.style.height = (height - offset) + 'px';   
  
    boxdiv.contents = contents;   
    boxdiv.appendChild(contents);   
  
    move_box(an, boxdiv, height);   
  
    if (contents.contentWindow)   
        contents.contentWindow.document.location.replace(   
            href);   
    else  
        contents.src = href; 
  
    // The script has successfully shown the box,   
    // prevent hyperlink navigation.   
    return false;   
}   



function ChangeDiv(divHide1, divHide2, divHide3, divHide4, divHide5, divShow)
{ 
    var obj1 = document.getElementById(divHide1)
    var obj2 = document.getElementById(divHide2)
    var obj3 = document.getElementById(divHide3)
    var obj4 = document.getElementById(divHide4)
    var obj5 = document.getElementById(divHide5)
    var obj6 = document.getElementById(divShow)
    obj1.style.visibility='hidden'
    obj2.style.visibility='hidden'
    obj3.style.visibility='hidden'
    obj4.style.visibility='hidden'
    obj5.style.visibility='hidden'
    obj6.style.visibility='visible'
    obj6.style.top = "0";
}


function ChangeDiv2(divHide1, divHide2, divHide3, divHide4, divHide5, divHide6, divHide7, divShow)
{ 
    var obj1 = document.getElementById(divHide1)
    var obj2 = document.getElementById(divHide2)
    var obj3 = document.getElementById(divHide3)
    var obj4 = document.getElementById(divHide4)
    var obj5 = document.getElementById(divHide5)
    var obj6 = document.getElementById(divHide6)
    var obj7 = document.getElementById(divHide7)
    var obj8 = document.getElementById(divShow)
    obj1.style.visibility='hidden'
    obj2.style.visibility='hidden'
    obj3.style.visibility='hidden'
    obj4.style.visibility='hidden'
    obj5.style.visibility='hidden'
    obj6.style.visibility='hidden'
    obj7.style.visibility='hidden'
    obj8.style.visibility='visible'
    obj8.style.top = "0";
}


function showPreviewImage(imgSrc, e)
{
    var xCoord = 0;
    var yCoord = 0;
    var oScreenWidth = 0;
    var oScreenHeight = 0;
    var myElement;

    myElement = document.getElementById('divPreviewImage');

    if (myElement != null && myElement != "undefined")
    {
        oScreenWidth = document.body.clientWidth;
        oScreenHeight = document.body.clientHeight;
    
        if (!e)
            var e = window.event;

        if (e.pageX || e.pageY)
        {
            xCoord = e.pageX + 5;
            yCoord = e.pageY - 255;
        }   
        else if (e.clientX || e.clientY)
        {
          xCoord = e.clientX + document.body.scrollLeft + 5;
          yCoord = e.clientY + document.body.scrollTop - 255;
        }
     
        if (xCoord + 160 > oScreenWidth)
        {
            xCoord = xCoord - 260;
        }
        if (yCoord - 155 < 0)
        {
            yCoord = yCoord + 260;
        }
    }

    if (xCoord != 0 && yCoord != 0 && myElement != null && myElement != "undefined")
    {
        document.images['imgPreviewImage'].src = imgSrc;
        if (document.layers)
        {
            alert("Here");
            if (typeof myElement.style.top != 'number')
            { 
                eval("myElement.moveTo(xCoord, yCoord)");
            }
            else
            { 
                myElement.style.top = yCoord;
                myElement.style.left = xCoord;
            }

            if ((myElement.style.visibility == null) || (myElement.style.visibility == "undefined"))
            { 
                myElement.visibility = 'visible';
            }
            else
            {
                myElement.style.visibility = 'visible';
            }
        }
        else
        {
            myElement.style.top = yCoord + 'px';
            myElement.style.left = xCoord + 'px';
            myElement.style.visibility = 'visible';
        }
    }
}

function hidePreviewImage()
{
if (document.layers)
{
// old Netscape versions
var myElement = document.divPreviewImage;
if ((myElement == null) || (myElement == "undefined"))
{ myElement = document.getElementById('divPreviewImage'); }
if ((myElement.style.visibility == null) ||
(myElement.style.visibility == "undefined"))
{ myElement.visibility = 'hidden'; }
else
// IE and newer versions of Netscape
{ myElement.style.visibility = 'hidden'; }
}
else
{ document.getElementById('divPreviewImage').style.visibility = 'hidden'; }
}















