﻿function geturl(page) {
	var domainname = window.location.hostname;

	var url = 'http://' + domainname + '/feeds/posts/default';


	var fullUrl = 'http://' + printDomain + '/BlogPrint.aspx' + page + '&blog=blogger&blogurl=' + url;
	var requestScript = document.createElement("script");
	requestScript.type = "text/javascript";
	requestScript.src = fullUrl;
	var head = document.getElementsByTagName("head");
	head[0].appendChild(requestScript);

	if (gup('clipboard', fullUrl)) {
	    callxmlhttp(requestScript);
	} else {
		blogurl = 'http://' + domainname + '/feeds/posts/default'
		window.open('http://' + printDomain  + '/BlogPrint.aspx' + page +
			'&blog=blogger&blogurl=' + blogurl, "Blogprint", "scrollbars=1");
	}
}


//var flag = false;


function printclipboard() {
    var urlRegEx = "^http.*.com/.*/.*/*.html";
    var websiteUrl = location.href;
    if (websiteUrl.match(urlRegEx) == null) {
	alert('Click on a post title to enable printing');
	return;
    }
    var oldDialog = document.getElementById('overlay');
    if(oldDialog != null) {
        overlay('overlay');
        return;
    }
    
    var embedTag = document.getElementsByTagName('embed');
	if(embedTag != null) {
	    for(x = 0; x < embedTag.length; ++x) {
	        embedTag[x].setAttribute('wmode', 'transparent');
	        var paramTag = document.createElement('param');
	        paramTag.setAttribute('name', 'wmode');
	        paramTag.setAttribute('value', 'transparent');
	        embedTag[x].parentNode.appendChild(paramTag);
	        var objNode = embedTag[x].parentNode.parentNode;
	        var addNode = embedTag[x].parentNode;
	        var sibNode = embedTag[x].parentNode.nextSibling;
	        objNode.removeChild(embedTag[x].parentNode);
	        if(sibNode == null) {
	            objNode.appendChild(addNode);
	        } else {
	            objNode.insertBefore(addNode, sibNode);
	        }
	    }
	}
    
    var dialog = document.createElement('div');
	dialog.setAttribute('id', 'overlay');
	var divlink = document.createElement('a');
	divlink.innerHTML='<img style="cursor:pointer;position: absolute; left: 453px;top: 108px;border-style:none;" src="http://' + printDomain + '/images/close1.jpg"/>';
	divlink.setAttribute('href', 'javascript:closeradiowindow();');
	var image = document.createElement('p1');
		image.innerHTML='<img src="http://' + printDomain + '/images/img-hp-print.gif" width="398" height="147" />' ;
		image.setAttribute('style', 'border-style: none; position: absolute; left:30px; top: 362px; z-index:1;');
		
	
	dialog.setAttribute('style',
		"font-size:10px;font-family: verdana;visibility: hidden;position: fixed;left: 30%;top: 0%;width:100%" +
		"height:100%;text-align:center;z-index: 999;background-image:url(background-trans.png);");
	var div = document.createElement('div');
	div.setAttribute('style', 'width:433px;height:423px;margin: 100px auto;background-color: #fff;' +
		'border:5px solid rgb(176, 176, 176);padding:4px 15px;text-align:center;');
	var p = document.createElement('div');
	p.setAttribute('style', 'text-align:left; margin:0; padding:0;');
	p.innerHTML = '<div style="text-align: left; font-size:115%"><form name="printForm" style="margin:0; padding-bottom:4px;">' + 
			
		'<img src="http://' + printDomain + '/images/hp-hitprint-logo.jpg" alt="" width="160" height="73" />' +
		'<p style="margin:0; padding-bottom:4px;">Print It! lets you print blog posts without sidebars, menus, ads etc. so that you save paper and ink. In addition, Print It! enables you to make a collection of multiple posts and print them at one go.</p>' +
		
		'<div style="background:#EFEFEF; margin-bottom:1px; font-size:12px; padding:10px 12px;">' +
		'<span style="font-size:14px; font-weight:bold; color:#005DA3;">Print the post</span><br />' +
		'<input type="radio" name="group" value="pwoc" id="print" >With comments</input><br/>' +
		'<input type="radio" name="group" value="pwc" id="print_comments" >Without comments</input></div>' +
		
		'<div style="background:#EFEFEF; margin-bottom:1px; font-size:12px; padding:10px 12px;">' +
		'<span style="font-size:14px; font-weight:bold; color:#005DA3;">Create a collection of posts to print</span><br />' +
		'<input type="radio" name="group" value="cwoc" id="clip" >Add to collection with comments</input><br/>' +
		'<input type="radio" name="group" value="cwc" id="clip_comments" >Add to collection without comments</input></div>' +
		
		'</form></div>' +

		'<span id="spanSave" style="position:absolute; z-index:100;"><a id="idSave" href="javascript: exec(document.forms[\'printForm\'].elements[\'group\'])" onclick="reloadFrame()"><img style="border-style:none;" src="http://' + printDomain + '/images/okButton.gif"/></a>    <a id="idClip" href="javascript: showcheckboxwindow()"><img style="border-style:none;" src="http://' + printDomain + '/images/viewbutton.gif"/></a></span>' +
		'<p style="clear:both; padding-top:110px;position:absolute;" >'+
		'<a href="#" style="border-style: none; background:url(images/arrow.gif) left 5px no-repeat; padding-left:10px;">Explore the world of HP Printers</a></p>'; 

	
	var ieText = '<div id="overlay" style="font-size:10px;font-family: verdana;visibility: hidden;position: fixed;left: 20%;top: 0%;width:100%' +

		'height:100%;text-align:center;z-index: 999;background-image:url(background-trans.png);"><a href="javascript:closeradiowindow();"><img style="cursor:pointer;position: relative; float:none; left: 226px;top: 138px;border-style:none;" src="http://' + printDomain + '/images/close1.jpg"/></a><img src="http://' + printDomain + '/images/img-hp-print.gif" width="398" height="147" style="border-style: none; position: absolute; left:190px; top: 412px; z-index:1;" />' +
		'<div style="width:433px;height:423px;margin: 100px auto;background-color: #fff;' +
		'border:5px solid rgb(176, 176, 176);padding:15px;text-align:center;">' + p.outerHTML + '</div></div>';
	
	dialog.appendChild(divlink);
    dialog.appendChild(div);
    div.appendChild(p);
	div.appendChild(image);

    
    if(navigator.userAgent.indexOf("MSIE") > 0) {
	    var bodyIE = document.getElementsByTagName('body');
    	if(navigator.userAgent.indexOf("MSIE 8") > 0) {
	        bodyIE[0].appendChild(dialog);
	    } else {
	        bodyIE[0].innerHTML = bodyIE[0].innerHTML + ieText;
	    }
    } else {
        var it = document.evaluate('//body', document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
        var body = it.iterateNext();
        body.appendChild(dialog);
    }
    
    overlay('overlay');   
    
}// JavaScript Document