<?php 
$d = 0; // search depth;
while (!file_exists(str_repeat('../', $d) . 'wp-config.php')) if (++$d > 99) exit;
$wp_config = str_repeat('../', $d) . 'wp-config.php';
require_once($wp_config);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="<?php bloginfo('wpurl'); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>

<script type="text/javascript">
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function insertRating() {
	
	var rating = getCheckedValue(document.getElementsByName('flxrating'));
	
	var buttonStyle = getCheckedValue(document.getElementsByName('buttonstyle'));
	
	var ratingNumber = document.flexratings.rownumber.value;
	
	var i=0;
	
	var ratingrows2 = '';

		if (rating != 0){

			if (rating == 'starwbutton') {
			ratingstart = '<table width="100%" border="0" cellpadding="10" style="border-top:2px solid #eee;border-right:2px solid #eee;border-left:2px solid #eee;">';
			ratingrows = '<tr><td align="center" style="border-bottom:2px solid #eee;"><img src="<?php bloginfo('template_directory'); ?>/images/mock-logo.png" /></td><td valign="top" style="border-bottom:2px solid #eee;"><p>To change the number of stars shown, click on the star image and then click on the Insert/edit image icon in your toolbar and change the name of the image from 5-stars.png to the number of stars you want to show (4, 3, 2, 1 or 0).<br /><br />You will also need to change the link URL for the button either in HTML or Visual mode.</p></td><td width="100" align="center" style="border-bottom:2px solid #eee;"><img src="<?php bloginfo('template_directory'); ?>/images/5-stars.png" /><br /><br /><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/btn-' + buttonStyle + '.png"/></a></td>';
			while (i<ratingNumber)
			{
				ratingrows2 += ratingrows;
				i++;
			}
			
			ratingclose = '</table><p>Continue your page here...</p>';
			ratingcode = ratingstart + ratingrows2 + ratingclose;
			}
			
			if (rating == 'starwbuttondivider') {
			ratingstart = '<table width="100%" border="0" cellpadding="10">';
			ratingrows = '<tr><td align="center"><img src="<?php bloginfo('template_directory'); ?>/images/mock-logo.png" /></td><td valign="top"><p>To change the number of stars shown, click on the star image and then click on the Insert/edit image icon in your toolbar and change the name of the image from 5-stars.png to the number of stars you want to show (4, 3, 2, 1 or 0).<br /><br />You will also need to change the link URL for the button either in HTML or Visual mode.</p></td><td width="100" align="center"><img src="<?php bloginfo('template_directory'); ?>/images/5-stars.png" /><br /><br /><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/btn-' + buttonStyle + '.png" /></a></td><tr><td colspan="3"><img src="<?php bloginfo('template_directory'); ?>/images/shadows/sp-round-650.png" width="100%"/></td></tr>';
			while (i<ratingNumber)
			{
				ratingrows2 += ratingrows;
				i++;
			}
			
			ratingclose = '</table><p>Continue your page here...</p>';
			ratingcode = ratingstart + ratingrows2 + ratingclose;
			}
			
			if (rating == 'starwbuttonevenodd') {
			ratingstart = '<table width="100%" border="0" cellpadding="10">';
			ratingrows = '<tr style="background-color:#fafafa;"><td align="center"><img src="<?php bloginfo('template_directory'); ?>/images/mock-logo.png" /></td><td valign="top"><p>To change the number of stars shown, click on the star image and then click on the Insert/edit image icon in your toolbar and change the name of the image from 5-stars.png to the number of stars you want to show (4, 3, 2, 1 or 0).<br /><br />You will also need to change the link URL for the button either in HTML or Visual mode.</p></td><td width="100" align="center"><img src="<?php bloginfo('template_directory'); ?>/images/5-stars.png" /><br /><br /><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/btn-' + buttonStyle + '.png" /></a></td></tr>';
			
			ratingrowsodd = '<tr style="background-color:#eee;"><td align="center"><img src="<?php bloginfo('template_directory'); ?>/images/mock-logo.png" /></td><td valign="top"><p>To change the number of stars shown, click on the star image and then click on the Insert/edit image icon in your toolbar and change the name of the image from 5-stars.png to the number of stars you want to show (4, 3, 2, 1 or 0).<br /><br />You will also need to change the link URL for the button either in HTML or Visual mode.</p></td><td width="100" align="center"><img src="<?php bloginfo('template_directory'); ?>/images/5-stars.png" /><br /><br /><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/btn-' + buttonStyle + '.png" /></a></td></tr>';
			
			while (i<ratingNumber)
			{	
			if (i%2 == 0) {
				ratingrows2 += ratingrows;
			} else {
				ratingrows2 += ratingrowsodd;
			}
				i++;
			}
			
			ratingclose = '</table><p>Continue your page here...</p>';
			ratingcode = ratingstart + ratingrows2 + ratingclose;
			}
			
			
			
			
		}

		
		if ( rating == 0 ){
			tinyMCEPopup.close();
		}
	if(window.tinyMCE) {
		if (typeof tinyMCEPopup.editor.insertContent == 'function') { // tinymce 4.x
			tinyMCEPopup.editor.insertContent(ratingcode);
		} else { // tinymce 3.x
			window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, ratingcode);
		} 
		
		tinyMCEPopup.editor.execCommand('mceRepaint');
		tinyMCEPopup.close();
	}
	return;
}
</script>

<title>FlexSqueeze Mock Ratings</title>
<style type="text/css">
td img:hover, input:hover {cursor:pointer;}
td {border:1px solid #fff;}
.cancelbtn, .submitbtn {padding:5px;}
.cancelbtn:hover, .submitbtn:hover {background-color:#555;color:#fff;}

</style>
</head>

<body onLoad="tinyMCEPopup.executeOnLoad('init();');">
<form action="#" method="post" name="flexratings">
  <table id="boxchoices" width="664" cellpadding="8" style="margin:0 auto;">
  
  <tr><td colspan="3" style="border:none;"><p>These pre-formatted tables can be used for product listings, comparisons and mock ratings charts.  The ratings do not allow for user ratings, but rather give you a method for inserting a star rating system for products that you choose and rate.</p></td></tr>
    <tr>
       
        <td style="text-align:center;"><label>
        <img src="ratings-stars-border.gif" /><br /><br/>
        This style has a border around all rows<br />
        <input type="radio" name="flxrating" value="starwbutton" checked="checked"/>
        </label></td>

    </tr>
    
    <tr>
       
        <td style="text-align:center;"><label>
        <img src="ratings-stars-divider.gif" /><br /><br/>
        This style uses a shadow divider and no borders<br />
        <input type="radio" name="flxrating" value="starwbuttondivider"/>
        </label></td>

    </tr>
    
    <tr>
       
        <td style="text-align:center;"><label>
        <img src="ratings-stars-evenodd.gif" /><br /><br/>
        This style alternates colors on even and odd rows<br />
        <input type="radio" name="flxrating" value="starwbuttonevenodd"/>
        </label></td>

    </tr>
    
     
     
     <tr>
      <td colspan="3">Button style:
      <label>
              <input type="radio" name="buttonstyle" value="more-info" checked="checked"/>
              More Info (orange)</label> 
       <label>
              <input type="radio" name="buttonstyle" value="buy-now" />
              Buy Now (green)</label>
              <label>
              <input type="radio" name="buttonstyle" value="visit-site" />
              Visit Site (blue)</label>
</td>
    </tr>
    
    <tr>
      <td colspan="3"><label>Number of table rows (one row per product):
          <input name="rownumber" type="text" id="rownumber" size="5" value="5" style="cursor:text;"/>
       </label></td>
    </tr>


    
    <tr>
  <td colspan="3">
  <input name="cancel" class="cancelbtn" type="button" value="Cancel"  onClick="tinyMCEPopup.close();" />
    
  <input name="submit" class="submitbtn" type="button" value="Insert Table" onClick="insertRating();" />

    
  </td>
    </tr>
  </table>
</form>


</body>
</html>