// JavaScript Document

//var colorBoxWidth = parseInt(iwidth) + 40;
//var colorBoxHeight = parseInt(iheight) + 40;
$('#copyCode').click(function () {
        this.select();
    });
/*$("#widget_preview").click(function(){
	$('#widget_preview').colorbox({iframe:true,fastIframe:true,innerWidth:colorBoxWidth,innerHeight:colorBoxHeight});
});

$(document).bind('cbox_complete', function(){
	//$("iframe.cboxIframe").css("padding-top","25px");
	$.colorbox.resize()
});*/
$("#widget_preview").click(function(){
	$('#widget_preview').colorbox({iframe:true,fastIframe:false,innerWidth:iwidth,innerHeight:iheight,transition:"none",onComplete:function(){
		var iframe = $("iframe.cboxIframe");
		$.colorbox.resize({innerWidth: iframe.contents().width()+10,innerHeight: iframe.contents().height()+40 })
		}
	});
});
/*function listTrafficDetails()
{  
    var daterange = $('#daterange').val();
	var awid = $('#affiliateWidgetDetailID').val();
	var location = $('#location').val();
	if(daterange){
     $("#loadProcessImage").append('<img src="'+GLOBAL_ROOT_PATH+'/public/default/affiliate/standard/images/ajax-loader.gif" id="loading_gif2"  />');
	}
  $.ajax({
   type: "POST",
   url: GLOBAL_BASE_PATH+"/widget/ajaxwidgetdetails/",
   data: "awid="+awid+"&daterange="+daterange+"&location="+location,
   success: function(msg){  
    var msg = $.trim( msg );
	$("#loadProcessImage").empty();
    if(msg!=''){
         $('#trafficDetails').html(msg);
      }
    }
  });
  }
 */
function show_getCode()
 {
	 document.getElementById('getWidgetCode').style.display="block"
	 var widgetEncryptedID = $('#widgetIDEncrypted').val();
	 if($("#widgetType").val()=='Iframe')
     {
		  str = "<iframe src='"+siteUrl+"affiliate/widget/ajaxWidget/"+widgetEncryptedID+"/' frameborder='0' scrolling='no' width="+iwidth+" height="+iheight+"></iframe>"
		  $('#copyCode').val(str);
	 }
	  if($("#widgetType").val()=='JS')
     {
		    str = '<script type="text/javascript">\nvar __widget = "' + widgetEncryptedID + '",__width="'+iwidth+'",__height="' + iheight + '",__parent="",__od="";\n(function(){\n__od = document.createElement("script");\nvar __script = document.scripts[document.scripts.length - 1];\n __od.type = "text/javascript";\n __od.async = true;\n__od.src = ("https:" == document.location.protocol ? "' + httpsSiteUrl + '" : "' + siteUrl + '") + "public/widget/widget.js";\n__parent=__script.parentNode;\n__parent.insertBefore(__od, __script);\n})();\n</script>';		 		   
          $('#copyCode').val(str);
	 }
 }
 function hide_getCode()
 {
	 document.getElementById('getWidgetCode').style.display="none"
 }