// JavaScript Document
// Routines written by Matzy

function ShopTableHTML(){
var t="";

t=t+'<table width="96%" border="0" cellspacing="0" cellpadding="0" align="center">'
t=t+'<tr>'
t=t+'<td>'
 
//=========================================================
// The main header table with shop name and vote totals
//=========================================================
t=t+'<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">'
t=t+' <tr>'
t=t+' <td class="cap-left"></td>'
t=t+'	<td class="cap-div">'
t=t+'	 <table width="100%" border="0" cellspacing="4">'
t=t+' <tr>'
t=t+' <td align="left" valign="middle" nowrap="nowrap" class="title_name_acidtech">'
t=t+'		 <a href="javascript:animatedcollapse.toggle(\'{SHOP_KEY}\')">{SHOP_NAME}</a>'
t=t+'		 </td>'
//t=t+'{VOTE_TITLE}'
t=t+'{VOTE_NEUTRAL}'
t=t+'{VOTE_GOOD}'
t=t+'{VOTE_BAD}'
t=t+'		</tr>'
t=t+' </table>'
t=t+' </td>'
t=t+' <td class="cap-right"></td>'
t=t+' </tr>'
t=t+'</table>'

//=========================================================
// The shop information table
//=========================================================
t=t+'<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">'
t=t+'<tr>'
t=t+'<td width="100%" align="left" valign="middle" nowrap="nowrap" class="row1_acidtech">'
	
t=t+'<table width="100%" border="0" cellpadding="0" cellspacing="0" class="shop_info">'
t=t+'<tr>'
 

t=t+'<td width="100%" nowrap="nowrap" class="shop_url_acidtech">'
t=t+'{BLOCK_SHOP_URL}'
t=t+'</td>'
 
t=t+'<td align="right" valign="middle" nowrap="nowrap" class="shop_score_acidtech">{SHOP_SCORE}</td>'
		
t=t+'<td align="right" valign="middle" nowrap="nowrap" class="title_flags_acidtech">'
t=t+'<img src="../images/acidtechgreen/16_blank_acidtech.png" alt="" border="0" align="absmiddle">'
t=t+'</td>'
		
t=t+'</tr>'
t=t+'</table>'
	
t=t+'</td>'
t=t+'</tr>'
t=t+'<tr>'
t=t+'<td align="left" valign="middle" class="row1_acidtech">'
t=t+'<div class="shop_body" id="{SHOP_KEY}" style="display:none">'

t=t+'<table border="0" cellpadding="0" cellspacing="1" class="shop_info">'
t=t+'{BLOCK_SHOP_ADDRESS}'
t=t+'{BLOCK_SHOP_PHONE}'
t=t+'{BLOCK_SHOP_EBAY}'
t=t+'{BLOCK_SHOP_INFO}'
t=t+'</table>'

t=t+'<table width="100%" border="0" cellpadding="0" cellspacing="4">'
t=t+'<tr>'
t=t+'<th class="review_title" scope="row"><hr size="1" noshade="noshade">'
t=t+'<table width="100%" border="0" cellpadding="0" cellspacing="0">'
t=t+'<tr>'
t=t+'<td align="left" valign="middle">Customer Comments...</td>'
t=t+'<td align="right" valign="middle"><a href="javascript:doReview(\'do_review.html\',\'{SHOP_NAME}\')">'
t=t+'<img src="images/submit_review.png" alt="" width="98" height="22" border="0"> </a></td>'
t=t+'</tr>'
t=t+'</table>'
t=t+'<hr size="1" noshade="noshade"></th>'
t=t+'</tr>'

t=t+'{SHOP_REVIEW}'

t=t+'</table>'
t=t+'</div>'
t=t+'</td>'
t=t+'</tr>'
t=t+'</table>'

t=t+'</td>'
t=t+'</tr>'
t=t+'</table>'

return t;
}

function writeShop(myShop,idx){

//0 = x|x|x|x|x Format = Shop score | BAD Total | NEUTRAL Total | GOOD Total | Total Reviews
//1 = Div Key
//2 = Shop Name
//3 = Site URL
//4 = Address
//5 = Phone number(s)
//6 = Ebay store URL
//7 = Extra Information
//? = x|x|x  Format = **0,1 or 2|Review Text|Reviewer & Date
//                   (**0 = BAD, 1 = NEUTRAL, 2 = GOOD)

myTotals = myShop[idx][0].split("|");
//'x|x|x|x|x',// Shop score | BAD Total | NEUTRAL Total | GOOD Total | Total Reviews
//myTotals[0] = '';	//0 = Shop Score
//myTotals[1] = '';	//1 = BAD Total
//myTotals[2] = '';	//2 = NEUTRAL Total
//myTotals[3] = '';	//3 = GOOD Total
//myTotals[4] = '';	//4 = Total Reviews

animatedcollapse.addDiv(myShop[idx][1], 'fade=1, speed=400, group=info')

var tpl=ShopTableHTML();

tpl=tpl.replace(/{SHOP_KEY}/gi, myShop[idx][1])			//1 = Div Key
tpl=tpl.replace(/{SHOP_NAME}/gi, myShop[idx][2])		//2 = Shop Name


var vote_icon='<td valign="middle" nowrap="nowrap" class="title_totals_acidtech">{VOTE_ICON}</td>'
var icon_new = ''
var vote_text='<td valign="middle" nowrap="nowrap" class="title_totals_acidtech">{VOTE_TEXT}</td>'
var text_new = ''
var block_text = ''

//if (myTotals[4]>0){
//  text_new=vote_text.replace(/{VOTE_TEXT}/gi, 'Votes: ')
//  tpl=tpl.replace(/{VOTE_TITLE}/gi, text_new)
//}else{
//  tpl=tpl.replace(/{VOTE_TITLE}/gi, '')
//}

// Add GOOD votes total
if (myTotals[3]>0){
  icon_new=vote_icon.replace(/{VOTE_ICON}/gi, '<img src="../images/acidtechgreen/vote_good.png" alt="" width="20" height="16">')
  text_new=vote_text.replace(/{VOTE_TEXT}/gi, myTotals[3] + ' Good')
  tpl=tpl.replace(/{VOTE_GOOD}/gi, icon_new + text_new)
}else{
  tpl=tpl.replace(/{VOTE_GOOD}/gi, '')
}

// Add NEUTRAL votes total
if (myTotals[2]>0){
  icon_new=vote_icon.replace(/{VOTE_ICON}/gi, '<img src="../images/acidtechgreen/vote_neutral.png" alt="" width="20" height="16">')
  text_new=vote_text.replace(/{VOTE_TEXT}/gi, myTotals[2] + ' Neutral')
  tpl=tpl.replace(/{VOTE_NEUTRAL}/gi, icon_new + text_new)
}else{
  tpl=tpl.replace(/{VOTE_NEUTRAL}/gi, '')
}

// Add BAD votes total
if (myTotals[1]>0){
  icon_new=vote_icon.replace(/{VOTE_ICON}/gi, '<img src="../images/acidtechgreen/vote_bad.png" alt="" width="20" height="16">')
  text_new=vote_text.replace(/{VOTE_TEXT}/gi, myTotals[1] + ' Bad')
  tpl=tpl.replace(/{VOTE_BAD}/gi, icon_new + text_new)
}else{
  tpl=tpl.replace(/{VOTE_BAD}/gi, '')
}

// myShop[idx][3] = Site URL
if (myShop[idx][3]){
  block_text='<a href="{SHOP_URL}" target="_blank" class="shop_info_acidtech">'
  block_text=block_text+'<img src="../images/acidtechgreen/16_firefox_acidtech.png" alt=""'
  block_text=block_text+'width="36" height="16" border="0" align="absmiddle">'
  block_text=block_text+'{SHOP_URL}'
  block_text=block_text+'</a>'
  block_text=block_text.replace(/{SHOP_URL}/gi, myShop[idx][3])			
  tpl=tpl.replace(/{BLOCK_SHOP_URL}/gi, block_text)			
}else{
  tpl=tpl.replace(/{BLOCK_SHOP_URL}/gi, '')
}

//This section adds the shop scores
if (myTotals[4] > 1){
    block_text = myTotals[4] + ' Reviews - Score = ' + myTotals[0]
  }else if (myTotals[4]==1){
    block_text = myTotals[4] + ' Review - Score = ' + myTotals[0]
  }else{
    block_text = 'Score = ' + myTotals[0]
}
tpl=tpl.replace(/{SHOP_SCORE}/gi, block_text)
// END of Shop scores


if (myShop[idx][4]){
  block_text=''
  block_text=block_text+'<tr>'
  block_text=block_text+'<td width="30" align="center" valign="top" class="shop_icons">'
  block_text=block_text+'<img src="../images/acidtechgreen/16_building_acidtech.png" alt="" width="36" height="16"></td>'
  block_text=block_text+'<td  class="shop_info">{SHOP_ADDRESS}</td>'
  block_text=block_text+'</tr>'
  block_text=block_text.replace(/{SHOP_ADDRESS}/gi, myShop[idx][4])		//4 = Address
  tpl=tpl.replace(/{BLOCK_SHOP_ADDRESS}/gi, block_text)
}else{
  tpl=tpl.replace(/{BLOCK_SHOP_ADDRESS}/gi, '')
}

if (myShop[idx][5]){
  block_text=''
  block_text=block_text+'<tr>'
  block_text=block_text+'<td width="30" align="center" valign="top" class="shop_icons">'
  block_text=block_text+'<img src="../images/acidtechgreen/16_phone_acidtech.png" alt="" width="36" height="16"></td>'
  block_text=block_text+'<td  class="shop_info">{SHOP_PHONE}</td>'
  block_text=block_text+'</tr>'
  block_text=block_text.replace(/{SHOP_PHONE}/gi, myShop[idx][5])		//5 = Phone number(s)
  tpl=tpl.replace(/{BLOCK_SHOP_PHONE}/gi, block_text)
}else{
  tpl=tpl.replace(/{BLOCK_SHOP_PHONE}/gi, '')
}

if (myShop[idx][6]){
  block_text=''
  block_text=block_text+'<tr>'
  block_text=block_text+'<td width="30" align="center" valign="middle"  class="shop_icons">'
  block_text=block_text+'<img src="../images/acidtechgreen/16_ebay_acidtech.png" alt="" width="36" height="16" '
  block_text=block_text+'border="0" align="absmiddle"></td>'
  block_text=block_text+'<td  class="shop_info">'
  block_text=block_text+'<a href="{SHOP_EBAY_URL}" target="_blank">{SHOP_EBAY_URL}</a></td>'
  block_text=block_text+'</tr>'
  block_text=block_text.replace(/{SHOP_EBAY_URL}/gi, myShop[idx][6])		//6 = Ebay store URL
  tpl=tpl.replace(/{BLOCK_SHOP_EBAY}/gi, block_text)
}else{
  tpl=tpl.replace(/{BLOCK_SHOP_EBAY}/gi, '')
}

if (myShop[idx][7]){
  block_text=''
  block_text=block_text+'<tr>'
  block_text=block_text+'<td width="30" align="center" valign="top" class="shop_icons">'
  block_text=block_text+'<img src="../images/acidtechgreen/16_info_acidtech.png" alt="" width="36" height="16"></td>'
  block_text=block_text+'<td  class="shop_info">{SHOP_INFO}</td>'
  block_text=block_text+'</tr>'
  block_text=block_text.replace(/{SHOP_INFO}/gi, myShop[idx][7])		//7 = Extra Information
  tpl=tpl.replace(/{BLOCK_SHOP_INFO}/gi, block_text)
}else{
  tpl=tpl.replace(/{BLOCK_SHOP_INFO}/gi, '')
}

//<tr>
//  <th class="vote_good" scope="row">
//    <img src="../images/acidtechgreen/vote_light_good.png" alt="" width="16" height="16" align="right">{REVIEW_TEXT}<br>
//    <strong>{REVIEW_NAME}</strong>
//    <hr size="1" noshade="noshade">
//  </th>
//</tr>

block_text=''
block_text=block_text+'<tr>'
block_text=block_text+'  <th class="{REVIEW_CLASS}" scope="row">'
block_text=block_text+'    <img src="{REVIEW_ICON}" alt="" width="16" height="16" align="right">{REVIEW_TEXT}<br>'
block_text=block_text+'    <strong>{REVIEW_NAME}</strong>'
block_text=block_text+'    <hr size="1" noshade="noshade">'
block_text=block_text+'  </th>'
block_text=block_text+'</tr>'
var review_block = ''

var foundReview = false
var ii=myShop[idx].length
while (ii>7)
{
  if (Shops[idx][ii]) {
    //myReview[0] = ''; //0 = BAD, 1 = NEUTRAL, 2 = GOOD
    //myReview[1] = '';	//1 = Review text
    //myReview[2] = '';	//2 = Reviewers name

  myReview = myShop[idx][ii].split("|");

    if (myReview[0]=="0"){
    	foundReview=true;
        review_block = review_block+block_text
        review_block=review_block.replace(/{REVIEW_CLASS}/gi, 'vote_bad')
        review_block=review_block.replace(/{REVIEW_ICON}/gi, '../images/acidtechgreen/vote_light_bad.png')
        review_block=review_block.replace(/{REVIEW_TEXT}/gi, myReview[1])
        review_block=review_block.replace(/{REVIEW_NAME}/gi, myReview[2])
    }
    
	else if (myReview[0]=="1"){
    	foundReview=true;
        review_block = review_block+block_text
        review_block=review_block.replace(/{REVIEW_CLASS}/gi, 'vote_neutral')
        review_block=review_block.replace(/{REVIEW_ICON}/gi, '../images/acidtechgreen/vote_light_neutral.png')
        review_block=review_block.replace(/{REVIEW_TEXT}/gi, myReview[1])
        review_block=review_block.replace(/{REVIEW_NAME}/gi, myReview[2])
	}
    
	else if (myReview[0]=="2"){
    	foundReview=true;
        review_block = review_block+block_text
        review_block=review_block.replace(/{REVIEW_CLASS}/gi, 'vote_good')
        review_block=review_block.replace(/{REVIEW_ICON}/gi, '../images/acidtechgreen/vote_light_good.png')
        review_block=review_block.replace(/{REVIEW_TEXT}/gi, myReview[1])
        review_block=review_block.replace(/{REVIEW_NAME}/gi, myReview[2])
	}
	else {
		foundreview=false;
	}
  }
    ii=ii-1
}

if (foundReview==false){
  review_block=review_block+'<tr><td class="vote_good" scope="row">'
  review_block=review_block+'No reviews submitted. Be the first to review this store<br /><hr size="1" noshade="noshade" />'
  review_block=review_block+'</td></tr>'
}

tpl=tpl.replace(/{SHOP_REVIEW}/gi, review_block)


document.write(tpl)
document.write('<br>')

}