var select=new Array();
var scount;




function openWindow(pageName,pageWidth,pageHeight) {

window.open(pageName,"remote","width=" + pageWidth + " ,height=" + pageHeight + ",menubar=no");

}


function cte_window(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
window.open(mypage,myname,settings);

}


function CTE_plugin(ProdID){

var cte_placement = getVar('cte_placement');
var cte_product = getVar('cte_product');
var cte_member = getVar('cte_member');
var cte_page = getVar('cte_page');
var cte_options = getVar('cte_options');
var cte_image = getVar('cte_image');
var cte_engfee = getVar('cte_engfee');
var cte_type = getVar('cte_type');

if(cte_product){

cte_options = cte_options.replace(/______/g, " [ ");
cte_options = cte_options.replace(/_____/g, " ] <br>");
cte_options = cte_options.replace(/____/g, " <br>(NewLine) ");
cte_options = cte_options.replace(/___/g, ": ");
cte_options = cte_options.replace(/__/g, "<br>");
cte_options = cte_options.replace(/_/g, " ");

cte_options = cte_options.replace(/%3A/g, ":");
cte_options = cte_options.replace(/%2B/g, "<br>");
cte_options = cte_options.replace(/%27/g, "'");
cte_options = cte_options.replace(/%21/g, "!");
cte_options = cte_options.replace(/%5B/g, "[");
cte_options = cte_options.replace(/%5D/g, "]");
cte_options = cte_options.replace(/%0D%0A/g, "<br>(new Line) ");
cte_options = cte_options.replace(/%2F/g, "/");
cte_options = cte_options.replace(/%2C/g, ",");

cte_options_tag = cte_options.replace(/<br>/g, " + ");

var TableHead;
var TableData;
var FormData;

var cte_image_link = ("http://www.clicktoengrave.com/cte/members/" + cte_member + "/images/saved/" + cte_image + "_THUMB.jpg");

TableHead = ("<table width=\"100\%\" cellspacing=\"1\" cellpadding=\"2\" style=\"border: 1px solid #CCCCCC\;\"><tr>");
TableData = ("<tr><td align=\"left\" width=\"40\%\">");

TableData = (TableData + "<div id=\"CTE_" + cte_product + "_ENLARGE\" style=\"display: none\; position: absolute\; padding: 4px\; border: 1px solid \#333333\;\">");
TableData = (TableData + "<img src=\"http://www.clicktoengrave.com/cte/members/" + cte_member + "/images/saved/" + cte_image + ".jpg\" border=\"0\" style=\"padding: 3px\" onMouseOut=\"MM_showHideLayers\(\'CTE_" + cte_product + "_ENLARGE\',\'\',\'hide\'\)\"></div>");
TableData = (TableData + "<img src=\"http://www.clicktoengrave.com/cte/members/" + cte_member + "/images/saved/" + cte_image + "_THUMB.jpg\" border=\"0\" style=\"padding: 3px\" onMouseOver=\"MM_showHideLayers\(\'CTE_" + cte_product + "_ENLARGE\',\'\',\'show\'\)\">");

TableData = (TableData + "</td><td width=\"60\%\" align=\"left\" valign=\"top\">");
TableData = (TableData + "<b>" + cte_type + ":</b><br>" + cte_options + "<br><b>" + cte_type + " Fee: </b>$" + cte_engfee + "<br></td>");
TableData = (TableData + "</tr></table><div style=\"text-align: right\; width: 100\%\; color: #999933\; font-size: 10px\;\"><i>Powered by ClickToEngrave.com</i></div><br>");

FormData = ("<input type=\"hidden\" name=\"cte_options\" value=\"" + cte_options_tag + "\">\n");
FormData = (FormData + "<input type=\"hidden\" name=\"cte_image\" value=\"" + cte_image_link + "\">\n");
FormData = (FormData + "<input type=\"hidden\" name=\"cte_engfee\" value=\"" + cte_engfee + "\">\n");
FormData = (FormData + "<input type=\"hidden\" name=\"cte_type\" value=\"" + cte_type + "\">\n");

var getplugindiv = (cte_product + "_cteview");
var plugindiv = document.getElementById(getplugindiv);
if(plugindiv){ plugindiv.innerHTML = (TableHead + TableData + FormData); }
else{ 
alert("Im sorry - The engraving options for this item have not been set up properly, please try again"); }



}




}


function getVar(name)
         {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
         }














