//start esw code
function esw_what_am_i()
{
var getvalue = $("input[name='ProductCode']").val()
return getvalue;
}
function esw_where_am_i()
{
var getvalue = $(location).attr('href');
return getvalue;
}
function esw_show_iframe()
{
  $("#esw_upload_area").hide();
  $("#esw_inpage_upload").fadeIn("slow");
setInterval(function() {
$.post('/v/upload_system/prxy.asp?UID=' + $("#esw_listener").text(), function(data) {
if(data == "COMPLETE"){ 
 $("#esw_inpage_upload").html("<h2>Upload done.</h2><p>Once you've picked any other options you require below, just click the 'add to cart' button.</p>");
 }
});
}, 5000); 
  return true;
}
function esw_reset_uploadr(){
//rewind!
 
 $("#easy_eswuploadr_quote").fadeOut("slow");	
 
$("#esw_upload_area_quote").fadeIn("slow");
  $("#q_form_submit").fadeIn("slow");	
  
  
  $('html,body').animate({ scrollTop: $("#Verification_Code").offset().top }, { duration: 'slow', easing: 'swing'});
  
	
}
function esw_show_iframe2()
{
  $("#q_form_submit").fadeOut("slow");
  $("#esw_upload_area_quote").hide();
  $("#easy_eswuploadr_quote").fadeIn("slow");
  $('html,body').animate({ scrollTop: $("#easy_eswuploadr_quote").offset().top }, { duration: 'slow', easing: 'swing'});
  
  
setInterval(function() {
$.post('/v/upload_system/prxy.asp?UID=' + $("#esw_listener").text(), function(data) {
if(data == "COMPLETE"){ 

	$.post('/v/upload_system/prxyfile.asp?UID=' + $("#esw_listener").text(), function(fileID) {
	if(fileID){
		$("#ESWImageURL").val("http://e-swoosh.co.uk/sewsub/90807060/" + fileID);
	}
	}); 

 $("#easy_eswuploadr_quote").html("<p style='font-style: italic; font-weight: bold;'>Thanks for attaching your image.<br/><br/>Please click the 'Request Quotation' button to complete your quotation request.</p>");
 $("#q_form_submit").html("<input type='submit' name='submit' value='Request Quotation'>");
 $("#q_form_submit").slideDown("slow");
 }
});
}, 5000); 
  return true;
}
function do_esw_check(solid_UID)
{
$.get('/v/upload_system/prxy.asp?UID=' + $("#esw_listener").text(), function(data) {
});
}
$(document).ready(function(){
var date = new Date();
var d  = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var i_am_product_id = $("input[name='ProductCode']").val()
var you_are_here = $(location).attr('href');
var var_UID= Math.floor(Math.random()*9999) + "-" + hours + minutes + seconds + day + year + month + seconds + hours + Math.floor(Math.random()*9999);
var solid_UID = var_UID;
$("#esw_listener").html(solid_UID);
$("#easy_eswuploadr").html("<div class='esw_upload1' id='esw_upload_area'><a href='http://e-swoosh.co.uk/sewsub/inpage.php?pid=nojscript' target='_blank'>Click to launch uploader in a new window</a></div><div class='esw_hidden_iframe' id='esw_inpage_upload' style='display: none;'></div>");
$("#esw_inpage_upload").html("<iframe src='http://e-swoosh.co.uk/sewsub/inpage.php?UID=" + solid_UID + "&product=" + i_am_product_id + "&refer=" + you_are_here + "' width='350' height='400' style='border-width: 0px;' frameBorder='0' id='eswIframe1'><p>Sorry, your browser does not support our web-uploader. Please ring us on 01295 270693</p></iframe>");
//inject
$("#esw_upload_area").html("<a href='#' onclick='return esw_show_iframe();'><img src='/v/upload_system/esw_upload_img.png' alt='Upload your image for print' title='Upload your image for print'></a><br/>Click to upload your own image for personalisation");
$("#esw_upload_area_quote").html("<a href='#' onclick='return esw_show_iframe2();'><img src='/v/upload_system/esw_upload_img.png' alt='Upload your image for print' title='Upload your image for print'></a><br/>");
$("#easy_eswuploadr_quote").html("<iframe src='http://e-swoosh.co.uk/sewsub/inpage2.php?UID=" + solid_UID + "&product=" + i_am_product_id + "&refer=" + you_are_here + "' width='660' height='230' style='border-width: 0px;' frameBorder='0' id='eswIframe2'><p>Sorry, your browser does not support our web-uploader. Please ring us on 01295 270693</p></iframe><br/><a href='#' onclick='return esw_reset_uploadr();' style='font-weight: bold; color: Red;'>Cancel image upload ?</a>");
$("#q_form_submit").html("<input type='submit' name='submit' value='Request Quotation'>");

$("#Verification_Code").css("border-width","1px");
$("#Verification_Code").css("border-color","#000");

//end esw code
 });
