var screenWidth = screen.width;
var screenHeight = screen.height;
var exp = new Date();
exp.setTime (exp.getTime() + (24 * 60 * 60 * 1000 * 365));
var exp5hr = new Date();
exp5hr.setTime (exp5hr.getTime() + (10 * 60 * 60 * 1000 * 1));

var bookmarkurl="http://www.trianglelingerie.com"
var bookmarktitle="Triangle Lingerie - quality, wholesale, lowest prices"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function killCC(cookieName){
var i
var strName = ""
var chipText
var chipArray
chipText = getCookie(cookieName)
if (chipText != null){
chipArray = chipText.split("+")
// alert("TESTING: chipArray = " + chipArray)
// chipArray[13] = "empty"
// chipArray[14] = "empty"
// chipArray[15] = "empty"
// chipArray[16] = "empty"
// chipArray[17] = "empty"
// below for new version with seperate shipTo address.
chipArray[26] = "empty"
chipArray[27] = "empty"
chipArray[28] = "empty"
chipArray[29] = "empty"
chipArray[30] = "empty"
chipArray[31] = "empty"
for (var i = 0; i < chipArray.length-1 ; i++){
strName +=  chipArray[i] + "+"
}
delCookie(cookieName)
setCookie(cookieName, strName, exp5hr)
}
}

function whoisLoad(){
var w
if (screenWidth == "640"){
w = open("https://www.trianglelingerie.com/whois.htm","whois","left=18,top=4,screenX=18,screenY=4,width=590,height=432,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "800"){
w = open("https://www.trianglelingerie.com/whois.htm","whois","left=124,top=4,screenX=124,screenY=4,width=590,height=545,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1024"){
w = open("https://www.trianglelingerie.com/whois.htm","whois","left=224,top=4,screenX=224,screenY=4,width=590,height=710,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1280"){
w = open("https://www.trianglelingerie.com/whois.htm","whois","left=224,top=4,screenX=224,screenY=4,width=590,height=710,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
w = open("https://www.trianglelingerie.com/whois.htm","whois","left=124,top=4,screenX=124,screenY=4,width=590,height=442,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
}


function submitEmail(f){
var returnVal
var testEmail
var strLen
testEmail = f(0).email.value
// alert("f(1).email.value = " + testEmail)
strLen = testEmail.length
if ((strLen < 1) || (testEmail == "your email!")) {
   alert("you must enter a valid email address");
   returnVal = false;
}
else {
   returnVal = true;
}
return returnVal
}


function smallPop(htmlPageName){
var iPop
iPop = open(htmlPageName,"smlPop","left=15,top=100,screenX=15,screenY=100,,width=170,height=220,status=no,toolbar=no,menubar=no,scrollbars,resizable");
iPop.focus();
}
function smlPop(htmlPageName, mwn){
var iPop
var hb = 0
mwn = mwn.toLowerCase()
if (hb < 1){
hb = mwn.indexOf("home");
}
if (hb < 1){
hb = mwn.indexOf("contact");
}
if (hb < 1){
hb = mwn.indexOf("catalog");
}
if (hb < 1){
hb = mwn.indexOf("sizes");
}
if (hb < 1){
hb = mwn.indexOf("company");
}
if (hb < 1){
hb = mwn.indexOf("top_help");
}
if (hb < 1){
hb = mwn.indexOf("viewing");
}
if (hb > 1){
iPop = window.open("orderPop.htm","smlPop","left=15,top=100,screenX=15,screenY=100,,width=170,height=220,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
iPop = window.open("../orderPop.htm","smlPop","left=15,top=100,screenX=15,screenY=100,,width=170,height=220,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
iPop.focus();
}

function srchLoad(htmlPageName, mwn){
var iPop
var hb = 0
topPages = new Array("home","contact","catalog","sizes","company","top_help","viewing");
topLen = topPages.length
for (j = 0; j < topLen; j++){
mwn = mwn.toLowerCase()
hb = mwn.indexOf(topPages[j]);
if (hb > 1) j = topLen + 1;
}
if (hb > 1){
iPop = window.open(htmlPageName,"srch","status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
htmlPageName = "../" + htmlPageName
iPop = window.open(htmlPageName,"srch","status=no,toolbar=no,scrollbars,resizable");
}
iPop.moveTo(0,0)
iPop.resizeTo(screenWidth,screenHeight)
iPop.focus();
}

function finalLoad(htmlPageName, mwn, f){
var type
type = typeof f
if (type != "undefined"){
semi(f)
}
srchLoad('fsFinal800.htm', parent.frames[1].location.href)
}

function bigPicture(htmlPageName){
var big
if (screenWidth == "640"){
big = open(htmlPageName,"bugPict","left=40,top=20,screenX=40,screenY=20,,width=550,height=450,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "800"){
big = open(htmlPageName,"bugPict","left=60,top=3,screenX=60,screenY=3,,width=600,height=563,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1024"){
big = open(htmlPageName,"bugPict","left=90,top=15,screenX=90,screenY=15,,width=630,height=700,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1280"){
big = open(htmlPageName,"bugPict","left=90,top=15,screenX=90,screenY=15,,width=630,height=700,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
big = open(htmlPageName,"bugPict","left=60,top=20,screenX=60,screenY=20,,width=530,height=450,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
}
function midPicture(htmlPageName){
var big
if (screenWidth == "640"){
big = open(htmlPageName,"midPict","left=40,top=20,screenX=40,screenY=20,,width=450,height=430,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "800"){
big = open(htmlPageName,"midPict","left=60,top=3,screenX=60,screenY=3,,width=560,height=440,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1024"){
big = open(htmlPageName,"midPict","left=90,top=15,screenX=90,screenY=15,,width=560,height=460,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1280"){
big = open(htmlPageName,"midPict","left=90,top=15,screenX=90,screenY=15,,width=560,height=460,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
big = open(htmlPageName,"midPict","left=60,top=3,screenX=60,screenY=3,,width=560,height=440,status=no,toolbar=no,menubar=no,scrollbars,resizable");
}
}
//------------------------------------------------------------------------
// loads pop-up form displaying help (addl info) on packaging info.
function pkgInfoLoad(){
var w
if (screenWidth == "640"){
w = open("../pkgInfoLoad.htm","pl","left=48,top=14,screenX=48,screenY=14,width=590,height=432,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "800"){
w = open("../pkgInfoLoad.htm","pl","left=154,top=24,screenX=154,screenY=24,width=590,height=480,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1024"){
w = open("../pkgInfoLoad.htm","pl","left=254,top=24,screenX=254,screenY=24,width=590,height=600,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else if (screenWidth == "1280"){
w = open("../pkgInfoLoad.htm","pl","left=254,top=24,screenX=254,screenY=24,width=590,height=600,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
else {
w = open("../pkgInfoLoad.htm","pl","left=154,top=24,screenX=154,screenY=24,width=590,height=442,status=yes,toolbar=no,menubar=no,scrollbars,resizable");
}
}
//------------------------------------------------------------------------
function poPopUp(htmlPageName, col, rows){
var wW
var wH
var wShrink = false
var wStg = ""
wW = 360 + (120 * col)
wH = 240 + (48 * rows)
if (wH > 590){				// if window is too long we shorten it & add scrollbars
	wH = 590
	wW = wW + 20
	wShrink = true
}
if (wW > 660){
	wW = 660
	wShrink = true
}

if (wShrink == true){
	openWindow(htmlPageName,  "", wW, wH, 1, 1, 0, 0, 0, 0, 0, wStg)
}
else{
	openWindow(htmlPageName,  "", wW, wH, 1, 1, 0, 0, 0, 0, 0, wStg)
}
}
//*************************************************************************
function openWindow(name, handle, wW, wH, reSize, scrollBars, menuBar, toolBar, directories, location, status, wStg, hide){
var w
var wf = "";
wf = wf + "width=" + wW;
wf = wf + ",height=" + wH;
wf = wf + ",resizable=" + (reSize ? "yes" : "no");
wf = wf + ",scrollbars=" + (scrollBars ? "yes" : "no");
wf = wf + ",menubar=" + (menuBar ? "yes" : "no");
wf = wf + ",toolbar=" + (toolBar ? "yes" : "no");
wf = wf + ",directories=" + (directories ? "yes" : "no");
wf = wf + ",location=" + (location ? "yes" : "no");
wf = wf + ",status=" + (status ? "yes" : "no");
// alert(wf)
w = open(name,handle,wf);

if (wStg != ""){
	w.document.open();
	w.document.write(wStg);
	w.document.close();
}
// w.close()	// this works here
if (hide) w.blur(); // if true (1) we hide window
return w
}

//-------------------------------------------------------------------

function showSwatch(imgString){
w = open("","swatch","left=100,top=40,screenX=100,screenY=40,width=300,height=335,status=no,toolbar=no,menubar=no,scrollbars,resizable");
w.document.open();
w.document.write("<html>" + "\n" + "<head>" + "\n" + "<title>" + "</title>" + "\n" + "</head>" + "\n" + "<body>" + "\n");
w.document.write("<center>" +  "\n" + "<p>"  + "\n" + "<a href='javascript:self.close();'>" + "\n"  + "<IMG SRC='" + imgString + "'" +  " alt='PUSH ME GENTLY TO RETURN' border='0'></a>" + "\n" + "</p>")
w.document.write("</center>" + "\n" + "</body>" + "\n" + "</html>");
w.document.close();
}
function showImage(imgString){
w = open("","swatch","left=140,top=70,screenX=140,screenY=70,width=400,height=330,status=no,toolbar=no,menubar=no,scrollbars=no,resizable");
w.document.open();
w.document.write("<html>" + "\n" + "<head>" + "\n" + "<title>" + "</title>" + "\n" + "</head>" + "\n" + "<body>" + "\n");
w.document.write("<center>" +  "\n" + "<p>"  + "\n" + "<a href='javascript:self.close();'>" + "\n"  + "<IMG SRC='" + imgString + "'" +  " alt='PUSH ME GENTLY TO RETURN' border='0'></a>" + "\n" + "</p>")
w.document.write("</center>" + "\n" + "</body>" + "\n" + "</html>");
w.document.close();
}

function showImgBig(imgString){
w = open("","swatch","left=140,top=20,screenX=140,screenY=70,width=300,height=600,status=no,toolbar=no,menubar=no,scrollbars=no,resizable");
w.document.open();
w.document.write("<html>" + "\n" + "<head>" + "\n" + "<title>" + "</title>" + "\n" + "</head>" + "\n" + "<body>" + "\n");
w.document.write("<center>" +  "\n" + "<p>"  + "\n" + "<a href='javascript:self.close();'>" + "\n"  + "<IMG SRC='" + imgString + "'" +  " alt='PUSH ME GENTLY TO RETURN' border='0'></a>" + "\n" + "</p>")
w.document.write("</center>" + "\n" + "</body>" + "\n" + "</html>");
w.document.close();
}

function showImgHuge(imgString){
w = open("","swatch","left=240,top=10,screenX=120,screenY=10,width=720,height=650,status=no,toolbar=no,menubar=no,scrollbars=no,resizable");
w.document.open();
w.document.write("<html>" + "\n" + "<head>" + "\n" + "<title>" + "</title>" + "\n" + "</head>" + "\n" + "<body>" + "\n");
w.document.write("<center>" +  "\n" + "<p>" + "\n" + "<a href='javascript:self.close();'>" + "\n"  + "<IMG SRC='" + imgString + "'" + " alt='PUSH ME GENTLY TO RETURN' border='0'></a>" + "\n" + "</p>")
w.document.write("</center>" + "\n" + "</body>" + "\n" + "</html>");
w.document.close();
}

function showPrices(q1,q2,q3,p1,p2,p3){
w = open("","prices","left=400,top=120,screenX=400,screenY=120,width=160,height=230,status=no,toolbar=no,menubar=no,scrollbars=no,resizable");
w.document.open();
w.document.write("<html>" + "\n" + "<head>" + "\n" + "<title>" + "</title>" + "\n" + "</head>" + "\n" + "<body>" + "\n" + "<center>" + "\n");
w.document.write("<table border=0 cellpadding=0 cellspacing=0 width=125>" + "\n")
w.document.write("<caption><b>Volume Prices<br><br></b></caption>" + "\n" + "<tr>" + "\n")
w.document.write("<td width=70 align=center><u><b>quantity</b></u></td>" + "\n")
w.document.write("<td width=52 align=right><u><b>price</b></u></td>" + "\n" + "</tr>" + "\n")
w.document.write("<tr>" + "\n" + "<td width=70 align=center>" + q1 + "</td>" + "\n")
w.document.write("<td width=52 align=right>" + p1 + "</td>" + "\n" + "</tr>" + "\n")
w.document.write("<tr>" + "\n" + "<td width=70 align=center>" + q2 + "</td>" + "\n")
w.document.write("<td width=52 align=right>" + p2 + "</td>" + "\n" + "</tr>" + "\n")
w.document.write("<tr>" + "\n" + "<td width=70 align=center>" + q3 + "</td>" + "\n")
w.document.write("<td width=52 align=right>" + p3 + "</td>" + "\n" + "</tr>" + "\n")
w.document.write("<tr>" + "\n" + "<td width=122 align=center colspan=2 height=40>" + "\n" + "<font face=Arial size=1><br>" + "\n")
w.document.write("volume prices quoted <br> per color. Each color is<br>a seperate price entity." + "\n")
w.document.write("</font>" + "\n" + "</td>" + "\n" + "</tr>" + "\n")
w.document.write("</table>" + "\n" + "<br>" + "<a href='javascript:self.close();'><font size=4>Close</font></a>")
w.document.write("</center>" + "\n" + "</body>" + "\n" + "</html>")
w.document.close();
}

function semi(f){
var i
var cookieText
var cookieName = "FINAL"
var chipName
for (var i = 0; i < f.length; i++){
c = f.elements[i]
if ((c.type == "checkbox") && (c.checked)){
chipName = c.name
// alert("chipName = " + chipName)
delChip(cookieName, chipName)
setChip(cookieName, chipName, chipName)
}
}
cookieText = getCookie("FINAL")
}
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0){
begin = dc.indexOf(cname);
if (begin != -1){
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value, expires){
document.cookie = name + "=" + escape(value) + "; path=/" +
((expires == null) ? "" : "; expires=" + expires.toGMTString());
}
function delCookie(name){
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}
function setChip(cookie, name, value){
var dc = getCookie(cookie);
var cv = getChip(cookie, name);
var cn = name + '=';
if (cv != null){
var start = dc.indexOf(cn);
if (start != -1){
var end = dc.indexOf('|', start);
setCookie(cookie, dc.substring(0, start) + cn + value + '|' + dc.substring(end + 1, dc.length), exp5hr);
}
}
else {
if (dc != null) dc += cn + value + '|';
else dc = cn + value + '|';
setCookie(cookie, dc, exp5hr);
}
}
function getChip(cookie, name){
var cn = name + '=';
var dc = getCookie(cookie);
if (dc != null){
var start = dc.indexOf(cn);
if (start != -1){
start += cn.length;
var end = dc.indexOf('|', start);
if (end != -1) return unescape(dc.substring(start, end));
}
}
return null;
}
function delChip(cookie, name){
var dc = getCookie(cookie);
var cv = getChip(cookie, name);
var cn = name + '=';
if (cv != null){
var start = dc.indexOf(cn);
var end = dc.indexOf('|', start);
setCookie(cookie, dc.substring(0, start) + dc.substring(end + 1, dc.length), exp5hr);
}
}

