/** feature begin:share product, status:altered, editor:jason, date:06.26.07 
* descr: changed format to include logo and link to privay policy  **/

/*
** PROBLEM WITH CODE BELOW: query string can only be so long in IE
** SOLUTION: create a form low on the product page (outside of existing product page form) and submit that form on share
*/

function shareproduct(PageURL,args,SURL) 
{ 
	/** to change the code of the offer edit the text in between the quotes **/
	var plink = ""; //full url w/ querystring arguments
	var emailbody = "";
    var description_chunk = "";
	var url = ""; //base url w/o querystring arguments
    var url_args = "dept_id=" + dept_id + "&pf_id="+ pf_id +"&";
    if (s_id != "0"){ url_args = "s_id=" + s_id + "&" + url_args; } //prepend s_id if it's not zero.
	if (args.indexOf("=")<0 ||args.indexOf("&")<0 ){ args=""; } else { url_args += args; } //append any args passed in
    
	if(sharepage="none" || sharepage==""){
		url = i_jscript_uu_rootURL + "product.asp";
	}
	else {
		url = i_jscript_uu_rootURL + sharepage ;
	}
	
	plink=url + "?" + url_args;
	emailbody = "";
    
    //emailbody ="<style>td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; color:#000000;}.msrpPriceDisplay { text-decoration:line-through;} .ListPricewSale {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#24B3ED; font-weight:bold; text-decoration:line-through;} .ListPricewSale2 {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#404040; } .ListPricewSaleNoUnderline {text-decoration:none;} .ListPricewoSale, .ListPricewoSaleR {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#24B3ED; margin-bottom:10px; text-align:left; display:block;} .SalePrice {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#DE5800; } .MSRPPrice {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1px; color:#FFFFFF; }</style>";
	//emailbody +="<TABLE cellspacing=5 cellpadding=5 width=\"90%\" style=\"border-left:1px solid #818181; border-top:1px solid #818181;\">";
	//emailbody +="<TR><TD ><img src=\""+i_jscript_uu_rootURL+"assets/images/mail_imgs/lumens_email2.gif\" border=0 alt=\"\" ></TD>";
	//emailbody +="</TR><TR><td >";
	emailbody +="Dear #RecipientName#,<br>";
	emailbody +="#Text_field_3#" + "<br>";
    
    //Seperator
    //if you want a solid line seperating comments, use this:
    //emailbody += "<hr color=\"#8A8A8A\">";
    emailbody += "--<br>";
    
    
	/** table with product image **/
	//emailbody +="<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
	//emailbody +="<tr valign=top><td >";
	/**if image add the image link created above **/ 
    var image_name = "";
    if (product_image.length >= 2)
    {//in this case, the first image is a thumbnail, so let's try for the second image
        image_name = product_image[1].image;
    }
    else //there's one (or possibly zero) items in the array...
    {
        image_name = product_image[0].image;
	}
    if (image_name != "")
    {
        emailbody +=" <A HREF=\"" + plink + "\" ><IMG SRC=\""+ i_jscript_uu_rootURL + "assets/product_images/"+ image_name + "\" border=0 alt=\"" + product_name + "\"></A><br>";
    }
	emailbody +="<A HREF=\"" + plink + "\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; text-decoration:none; color:#BDAA10;\">" + product_name + "</A><br>";
	
    //description section
    description_chunk ="<font style=\"font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; color:#8A8A8A;\">";
	var description_chunk_maxsize =300;
	if(product_description.length > description_chunk_maxsize)
    {   //trim it
        description_chunk += product_description.substring(0, description_chunk_maxsize) + "...";
	}
	else
	{   //include entire thing
		  description_chunk += product_description;
	}
	description_chunk +="</font>";
	
    
	emailbody += description_chunk + "<br><br>Click this link to see the <A HREF=\"" + plink + "\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; color:#00B5D7;\">" + product_name + "</A><br><br><br>";
	
    //catch-all image & text
    //emailbody += "</td></tr><tr><td align=left><img src=\""+i_jscript_uu_rootURL+"assets/images/mail_imgs/lumens_email_catch.gif\" border=0 alt=\"\" ></td></tr></table>";
	
	
	//set the inputs
	document.getElementById("share_new_referer").value = plink; //product link
	document.getElementById("share_new_target").value = window.location.href; //basically sends the shopper back to where they were
	document.getElementById("share_new_email_body").value = emailbody;
	
	/*
	Not changing the location any longer...submitting form instead to get around IE querystring character limit 
	window.location=PageURL +"referer="+escape(plink)+"&email_body="+escape(emailbody)+"&target="+ escape(window.location.href)+"&";	
	*/
	
	//submit form
	document.share_new.submit();
	
	return(false);
}//end shareproduct