
function addbookmark()
{
bookmarkurl=document.location.href;
bookmarktitle=document.title;
if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
}



function doDropDownChange(iIndex){

    var newCriteria = "";
    var dropObject;
    var delimiter   = "||";

    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;

    }

    //alert(document.forms[0].elements["values_"+newCriteria+"_"+iIndex].value);

    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("||");

	  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;
	  
    }

/**/

}



function buyNowDropDown(iIndex){


        //Spawn_win_nav('/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, 800, 600);

        //hwm 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;
        document.location.href = 'http://www.seatsandstools.com/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 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 = "";  
}
}


