
function addbookmark()
{
bookmarkurl=document.location.href;
bookmarktitle=document.title;
if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


var gIndex = 0;

function newLink(){
    
    if(document.forms[0].compositePix == '[object]'){

        if(document.forms[0].compositePix.value == '1'){
            DropDownChange(gIndex, 1);
            return false;
        }else{

            return true;
        }
    }else{

        return true;

    }
}


function doDropDownChange(iIndex){
    
    DropDownChange(iIndex, -1);

}

function DropDownChange(iIndex, iFlag){
    

    //init for next function to use as global variable last state
    gIndex = iIndex;

    var newCriteria = "";
    var dropObject;
    var delimiter   = "||";
    var iCounter    = 0;
    var preFix      = '';
    

    //alert(document.forms[0].elements["dropDownCount_" + iIndex].value);

    for(i=0; i < document.forms[0].elements["dropDownCount_" + iIndex].value; i++){

        dropObject = document.forms[0].elements["dropSelect" + i + "_" + iIndex];
        
        if(i == document.forms[0].elements["dropDownCount_" + iIndex].value - 1)
            delimiter = "";

        newCriteria += dropObject.options[dropObject.selectedIndex].value + delimiter;
        
        iCounter++;
       
    }
    
    
    //alert(dropObject.options[dropObject.selectedIndex].value);
    //alert(document.forms[0].elements["values_"+newCriteria+"_"+iIndex].value);
    //alert("values_"+newCriteria+"_"+iIndex);
    if(document.forms[0].elements["values_"+newCriteria+"_"+iIndex] + "" == "undefined"){

        alert("Sorry this option is not valid . . .\n\nPlease select different option!");
        
        document.forms[0].elements["SKU_" + iIndex].value                     = "";
        document.forms[0].elements["Weight_" + iIndex].value                  = "0";
        document.forms[0].elements["price_" + iIndex].value                   = "$0.00";
        document.forms[0].elements["ProductUniqueIdentifier_" + iIndex].value = "";
        document.forms[0].elements["btBuy_" + iIndex].disabled 			= true;

    }else{    
        
        var valuesArray = document.forms[0].elements["values_"+newCriteria+"_"+iIndex].value.split("||");
        
        //alert(document.getElementsByTagName['mainProductPix']);

        //valuesArray[4] == iCounter 
       
        if( document.forms[0].compositePix == '[object]' ){
            

            //alert(document.forms[0].compositePix.value);

            if(document.forms[0].compositePix.value == "1"){
            
                if(document.forms[0].enlargePix.value == 1)
                    preFix = 'thumbz__';

                document.Main_Product_Image.src = '/constructor/users/' + document.forms[0].username.value + '/' + preFix + document.forms[0].ProductName.value + valuesArray[4] + '.jpg';

            }


        }

	document.forms[0].elements["SKU_" + iIndex].value                     = valuesArray[0];
        document.forms[0].elements["Weight_" + iIndex].value                  = valuesArray[1];
	document.forms[0].elements["price_" + iIndex].value                   = valuesArray[2];
        document.forms[0].elements["ProductUniqueIdentifier_" + iIndex].value = valuesArray[3];
        document.forms[0].elements["btBuy_" + iIndex].disabled                = false;
        
        if(iFlag==1){
                
                if(document.forms[0].enlargePix.value == 1)
                    preFix = 'thumbz__';

            
                view('/constructor/users/' + document.forms[0].username.value + '/Thumbz/' + preFix + document.forms[0].ProductName.value  + valuesArray[4] + '.jpg');
        }
  
    }

/**/

}



function buyNowDropDown(iIndex){

        document.location.href = '/constructor/cart/inventory1.jsp?uniqueID=' + document.forms[0].elements["ProductUniqueIdentifier_" + iIndex].value +  '&iQuantity=' + document.forms[0].elements["iQuantity_" + iIndex].value  + '&iwebsiteID=' + document.forms[0].iwebsiteID.value;

}


function registryAddone(){

    //alert(document.forms[0].ProductUniqueIdentifier.value);
    //alert(document.forms[0].iwebsiteID.value);
    //alert(document.forms[0].elements("iQuantity" + document.forms[0].referenceUID.value).value);

    document.location.href = '/constructor/cart/registryManage.jsp?uniqueID=' + document.forms[0].ProductUniqueIdentifier.value +  '&iQuantity=' + document.forms[0].elements("iQuantity" + document.forms[0].referenceUID.value).value  + '&iwebsiteID=' + document.forms[0].iwebsiteID.value;

}

function registryAddComposite(productUID, productUIDCleaned, siteID, iCounter){
       //alert("iQuantity" + productUIDCleaned);

       if(iCounter == '0')
            iCounter = '';
            
       //alert(iCounter + "---" + "iQuantity" + productUIDCleaned + iCounter + "---" + document.forms[0].elements["iQuantity" + productUIDCleaned + iCounter])

       document.location.href = '/constructor/cart/registryManage.jsp?uniqueID=' + productUID +  '&iQuantity=' + document.forms[0].elements["iQuantity" + productUIDCleaned + iCounter].value  + '&iwebsiteID=' + siteID;
}

function registryAdd(iIndex){
        
        //alert(iIndex);

        //alert(document.forms[0].elements["ProductUniqueIdentifier_" + iIndex]);
        //alert(document.forms[0].elements["iQuantity_" + iIndex]);

        document.location.href = '/constructor/cart/registryManage.jsp?uniqueID=' + document.forms[0].elements["ProductUniqueIdentifier_" + iIndex].value +  '&iQuantity=' + document.forms[0].elements["iQuantity_" + iIndex].value  + '&iwebsiteID=' + document.forms[0].iwebsiteID.value;

}



function buyNow(){
        document.location.href = '/constructor/cart/inventory1.jsp?uniqueID=' + document.forms[0].ProductUniqueIdentifier.value +  '&iQuantity=' + document.forms[0].iQuantity.value  + '&iwebsiteID=' + document.forms[0].iwebsiteID.value;
}

function goNext(){
    
    var sNextUID = document.forms[0].sNext.value;
    var sCurrentUID = document.forms[0].sCurrentUID.value
    
    if(sNextUID==sCurrentUID)
        sNextUID = document.forms[0].sFirstUID.value

    sURL        = "/servlet/constructor.includeHTTP?iwebsiteID="        +   document.forms[0].iwebsiteID.value
                                                + "&isectionTypeID="    +   document.forms[0].isectionTypeID.value
                                                + "&isectionID="        +   document.forms[0].isectionID.value
                                                + "&ipageID="           +   document.forms[0].ipageID.value
                                                + "&skeywords="         +   sNextUID;
                
    location.href  = sURL;               


}


function goPrev(){
    
    var sPrevious = document.forms[0].sPrevious.value;
    var sCurrentUID = document.forms[0].sCurrentUID.value
    
    if(sPrevious==sCurrentUID)
        sPrevious = document.forms[0].sLastUID.value
    
    sURL        = "/servlet/constructor.includeHTTP?iwebsiteID="        +   document.forms[0].iwebsiteID.value
                                                + "&isectionTypeID="    +   document.forms[0].isectionTypeID.value
                                                + "&isectionID="        +   document.forms[0].isectionID.value
                                                + "&ipageID="           +   document.forms[0].ipageID.value
                                                + "&skeywords="         +   sPrevious;
                
    location.href  = sURL;               


}

function goToGallery(){
    
    sURL        = "/servlet/constructor.includeHTTP?iwebsiteID="        +   document.forms[0].iwebsiteID.value
                                                + "&isectionTypeID="    +   document.forms[0].isectionTypeID.value
                                                + "&isectionID="        +   document.forms[0].isectionID.value
                                                + "&ipageID="           +   document.forms[0].ipageID.value;
                
    location.href  = sURL;               


}


function logout(websiteID){

    if(confirm("Are you sure you want to log out?")){
        
        location.href = "/constructor/Security/logout.jsp?iwebsiteID=" + websiteID;
    }
}

function viewThisPage(pageID, websiteID, isectionTypeID){

    sURL        = "/servlet/constructor.includeHTTP?iwebsiteID="        +   websiteID
                                                + "&isectionTypeID="    +   isectionTypeID
                                                + "&ipageID="           +   pageID;
    
                
    location.href  = sURL;               


}

function doLink(iType){
    
    sURL        = "/servlet/constructor.includeHTTP?iwebsiteID="        +   document.forms[0].iwebsiteID.value      
                                                + "&isectionID="        +   document.forms[0].isectionID.value  
                                                + "&isectionTypeID="    +   iType                                   
                                                + "&ipageID="           +   document.forms[0].ipageID.value
                                                + "&previousSection="   +   document.forms[0].previousSection.value
                                                + "&skeywords="         +   document.forms[0].skeywords.value;
    
    //alert(sURL);
                
    location.href  = sURL;               

}


function getGenPage(iType){
	
	document.forms[0].action = "/constructor/wiz/main.jsp?iStatus=131313&iPageType=" + iType;
	document.forms[0].submit();

}


function checkFields(){

	
	var sTemp = "";
	
	//alert(document.forms.feedback.last.value);
	
	if(document.forms.feedback.last.value == "")
		sTemp =1;
	
	if(document.forms.feedback.email.value == "")
		sTemp =1;
	
	if(sTemp  == 1)
		alert("Please provide the required fields denoted by an asterix '*'");
	else
	   document.forms.feedback.submit();
}





//Array function
function makeArray(len){
for(var i=0; i < len; i++) this[i] = null;
this.length = len;
}

function getDate(){

var now = new Date();
var day = now.getDay();
var second = now.getSeconds();
var minute = now.getMinutes();
var hour = now.getHours();
var year = now.getYear();
var date = now.getDate();
var month = now.getMonth();

var dayname;
	if (day == 0) dayname ="Sunday";
	if (day == 1) dayname ="Monday";
	if (day == 2) dayname ="Tuesday";
	if (day == 3) dayname ="Wednesday";
	if (day == 4) dayname ="Thursday";
	if (day == 5) dayname ="Friday";
	if (day == 6) dayname ="Saturday";

var monthNames = new makeArray(12);
monthNames[0]= "January";
monthNames[1]= "February";
monthNames[2]= "March";
monthNames[3]= "April";
monthNames[4]= "May";
monthNames[5]= "June";
monthNames[6]= "July";
monthNames[7]= "August";
monthNames[8]= "September";
monthNames[9]= "October";
monthNames[10]= "November";
monthNames[11]= "December";


document.write(dayname + ", " + monthNames[month] + " " + date + ", " + year);

}

   function Spawn_win_nav(linkto, winWidth, winHeight){  
   var str;  
   str = "width=" + winWidth + ",height=" + winHeight + ",scrollbars=yes,resizable=1";  
   spawn10  = window.open(linkto, 'viewStyle', str );  
   //spawn10.window.moveTo(10,10);   

   if (spawn10.blur) spawn10.focus();  
   
   } 

   


function getParameter ( queryString, parameterName ) {
// Add "=" to the parameter name (i.e. parameterName=value)
var parameterName = parameterName + "=";
if ( queryString.length > 0 ) {
// Find the beginning of the string
begin = queryString.indexOf ( parameterName );
// If the parameter name is not found, skip it, otherwise return the value
if ( begin != -1 ) {
// Add the length (integer) to the beginning
begin += parameterName.length;
// Multiple parameters are separated by the "&" sign
end = queryString.indexOf ( "&" , begin );
if ( end == -1 ) {
end = queryString.length
}
// Return the string
return unescape ( queryString.substring ( begin, end ) );
}
// Return "null" if no parameter has been found
return "0";
}
}

function getObject(objName){

	return getParameter(document.location.href, objName); 
}

var gwebsiteID = 0;
gwebsiteID = getParameter(document.location.href, "iwebsiteID"); 


	function dolink(sLink){
		
		sLink = "/constructor/wiz/popframes.jsp?sURL=" + sLink
		
		Spawn_win_nav(sLink, 640, 480); //'calcs.asp?calc=autoloan'
	}
	
	
	
	
	
	var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
}  
return null;
}


var MailingList = GetCookie("mailinglist");

function writeMailingBox(sUserName){
	
	if(MailingList != "true"){	
		document.write("<IFRAME SRC=\"/constructor/wiz/PartofMailingList.jsp?websiteUser=" + sUserName + "\" FRAMEBORDER=0 WIDTH=130 HEIGHT=120 TITLE=\"Join Mailing list\"></IFRAME>");
	}
}

function writeLoginBox(sUserName, bgColor, iWebsiteID){
    
    document.write("<IFRAME   SRC=\"/constructor/Security/loginBox.jsp?iWebsiteID=" + iWebsiteID + "&bgColor=" + bgColor + "&websiteUser=" + sUserName + "\" FRAMEBORDER=0 WIDTH=175 HEIGHT=80 TITLE=\"Join Mailing list\"></IFRAME>");
    
}

function Spawn_win_nav(linkto, winWidth, winHeight){  

   displayPopup(2,linkto,'win2',winHeight,winWidth,null);
     
} 



        var version4 = (navigator.appVersion.charAt(0) == "4");
        var popupHandle;
        function closePopup() {
        if(popupHandle != null && !popupHandle.closed) popupHandle.close()
        }


        function displayPopup(position,url,name,height,width,evnt)
        {
        // Nannette Thacker http://www.shiningstar.net
        // position=1 POPUP: makes screen display up and/or left,
        //    down and/or right
        // depending on where cursor falls and size of window to open
        // position=2 CENTER: makes screen fall in center

        var properties = "toolbar=0,scrollbars=yes,resizable=1,location=0,height="+height
        properties = properties+",width="+width

        var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

        if(navigator.appName == "Microsoft Internet Explorer")
        {
                screenY = document.body.offsetHeight
                screenX = window.screen.availWidth
        }
        else
        { // Navigator coordinates
        //		screenY = window.outerHeight
        //		screenX = window.outerWidth
                // change made 3/16/01 to work with Netscape:
                        screenY = screen.height;
                        screenX = screen.width;
        }

        if(position == 1)	// if POPUP not CENTER
        {
                cursorX = evnt.screenX
                cursorY = evnt.screenY
                padAmtX = 10
                padAmtY = 10

                if((cursorY + height + padAmtY) > screenY)	
                // make sizes a negative number to move left/up
                {
                        padAmtY = (-30) + (height*-1);	
                        // if up or to left, make 30 as padding amount
                }
                if((cursorX + width + padAmtX) > screenX)
                {
                        padAmtX = (-30) + (width*-1);	
                        // if up or to left, make 30 as padding amount
                }

                if(navigator.appName == "Microsoft Internet Explorer")
                {
                        leftprop = cursorX + padAmtX
                        topprop = cursorY + padAmtY
                }
                else
                { // adjust Netscape coordinates for scrolling
                        leftprop = (cursorX - pageXOffset + padAmtX)
                        topprop = (cursorY - pageYOffset + padAmtY)
                }
        }
        else	// CENTER
        {
                leftvar = (screenX - width) / 2
                rightvar = (screenY - height) / 2

                if(navigator.appName == "Microsoft Internet Explorer")
                {
                        leftprop = leftvar
                        topprop = rightvar
                }
                else
                { // adjust Netscape coordinates for scrolling
                        leftprop = (leftvar - pageXOffset)
                        topprop = (rightvar - pageYOffset)
                }
        }

        if(evnt != null)
        {
        properties = properties+",left="+leftprop
        properties = properties+",top="+topprop
        }
        closePopup()
        popupHandle = open(url,name,properties)
        }


 

    function prepareOrdering(){
    
        var Form1 = document.sendeMail;
        
        var sDelimiter = "";
        var formIndex;
        
        //alert(document.sendeMail.OrderedValue);

        for (formIndex = 0; formIndex < Form1.length; formIndex++)
        {

            //if(document.sendeMail.OrderedValue == '[object]'){

                if(document.sendeMail.elements[formIndex].name != "OrderedValue"){

                    document.sendeMail.OrderedValue.value =     document.sendeMail.OrderedValue.value + 
                                                                sDelimiter + 
                                                                document.sendeMail.elements[formIndex].name

                    sDelimiter = "|";
                }
            //}
            

        }

        //alert(document.sendeMail.OrderedValue.value);

    }


    function deleteItem(){

        if(confirm("Are you sure that you would like to remove this message?")){
            
            document.forms[0].actionID.value = "-3";
            document.forms[0].submit();
          
        }
    }

    function saveItem(){

        if(document.forms[0].subject.value == ""){
            alert("Please provide a Subject for your posting . . .");
            document.forms[0].subject.focus();

        }else{
            document.frames['contentFrame'].docSave();
            if(document.forms[0].Content.value == "<P>&nbsp;</P>" || document.forms[0].Content.value == "")
                alert("Please provide a Message for your posting . . .");
            else    
                document.forms[0].submit();
        }
    }

	
//New version of print it print page
function doPrintPage(){
    
    var currentPageIs = document.location.href;

    //alert(currentPageIs);

    Spawn_win_nav('/constructor/templates/JSPs/cpns/Constructor_Printer.jsp', 800, 600); //?printing=' + currentPageIs , 800, 600);

}


function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

//Collapses all divs with class=Sublevel, or when class=Sublevel while autocollapsing is off

function collapseAllSubs() {

var tmp = document.getElementsByTagName('div');
icounter = 1;
for (i=0;i<tmp.length;i++) {
    if (tmp[i].className == 'Sublevel') {
            
            //alert('DIVexpNodeSub_' + icounter);

            tmp[i].style.display = 'none';

            //document.forms[0].elements['image_' + icounter].src = "/constructor/templates/graphics/clearpix.gif";

            document.getElementById('DIVexpNodeSub_' + icounter).className = "bgTabsDiv_off";

            icounter++;
        }
}

}



//Expands div selected
function stoggleSubs(idname) {
document.getElementById(idname).style.display = (document.getElementById(idname).style.display == 'none') ? 'block' : 'none';
//targetImage.src = "/constructor/templates/graphics/clearpix.gif";



document.getElementById(idname).className = "bgTabsDiv_on";

//document.getElementById(idname).className =  "bgTabs_on";

//alert( document.getElementById(idname).className  );

//bgTabs

//alert(document.getElementById(idname).className);
}


//Collapses div clicked
function CollapseContentSub(idname){

   divID = document.getElementById(idname)

   collapseAll();

   //targetImage.src = "/constructor/templates/graphics/corner_tab_left_on.gif";
   toggleSubs(idname);                          

}                 





var HidePrevious;
var HideAfterFreeze;
var CurrentObject;

function ToggleFreeze(){
    HidePrevious        = "";
    HideAfterFreeze     = "";

}

function DoHiddingOut(){
    
    //alert("out of the sub");
    setTimeout("DoHiddingOutTemp()", 1500);
    HideAfterFreeze = CurrentObject;
}

function DoHiddingOutTemp(){
    
    //alert("Hide After ..." + HideAfterFreeze);

    if("" + HideAfterFreeze != ''){

        var a_about = document.getElementById(HideAfterFreeze);
        a_about.style.top = -1000;
        CurrentObject       = "";   
    }

}


function DoHidding(){
    
    if("" + HidePrevious != ''){
        
        var a_about         = document.getElementById(HidePrevious);
      
        a_about.style.top   = -1000;  
        CurrentObject       = "";

    }
}

function Hide(idname){

    CurrentObject   = idname;
    HidePrevious    = idname;
    HideAfterFreeze = HidePrevious;

    setTimeout("DoHidding()", 1500);
    //alert(idname);
    
}





var iCounter                = 0;
var iXOffset                = -25;
var iYOffset                = 16;
var newX                    =  -200;
var newY                    =  -200;



function Show(idname, thisObj){

    initLayeredMenus();
    
    setLyr(thisObj);
    
    //alert(newX);
    //alert(newY);
    
    var objDiv = document.getElementById(idname);

    objDiv.style.top = newY + iYOffset;   
    objDiv.style.left = newX + iXOffset; 

    
    //setLyr(thisObj)

}




function initLayeredMenus(){
    

    var objDiv  = document.getElementsByTagName('div');
   
    //alert(objDiv.length);


    for (i=0;i<objDiv.length;i++) {
        
            if (objDiv[i].className == 'Sublevel2') {
            
                //put the layer on the top of the page (nobody can see it . . . 
                objDiv[i].style.top = -1000;

            }
            
    }


}









function setLyr(obj)
{
	newX = findPosX(obj);
	newY = findPosY(obj);

	//alert(newX);
	//alert(newY);

	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
}




