/**********************************************
* Digital Inspiration - http://www.labnol.org *
**********************************************/

function share(action, key) {
 var link = document.location.href;
 var u = link;
 if(link.indexOf("#") == -1) {
	u = encodeURIComponent(link); 
 } else {
	u = encodeURIComponent(link.substring(0, link.indexOf("#"))); 
 }
 var desc = '&utm_content=' + u + '&utm_term=' + encodeURIComponent(document.title);
 key = typeof(key) != 'undefined' ? key : 'na';
 var url = 'http://www.labnol.org/assets/aryaman/r.php?utm_source=site&utm_medium=' + action + '&utm_campaign=' + key + desc;
 var size = '';

 switch (action) {
  case "link":
		size = 'toolbar=0,status=0,height=350,width=500,scrollbars=yes,resizable=no';
		break;	
  case "pdf":
		size = 'toolbar=0,status=0,height=320,width=650,scrollbars=yes,resizable=no';
		break;	
  case "blog":
		size = 'toolbar=0,status=0,height=550,width=500,scrollbars=yes,resizable=no';
		break;	
  case "email":
		size = 'toolbar=0,status=0,height=550,width=500,scrollbars=yes,resizable=no';
		break;	
  case "addthis":
		size = 'toolbar=0,status=0,height=650,width=650,scrollbars=yes,resizable=no';
		break;	
  default:
		size = 'toolbar=0,status=0,height=600,width=600';
		break;
	}

  switch (action) {
	case "lang":
	case "social":
	case "rss":
	case "rssi":
		var win = window.open(url, "_blank");
		break;
	case "print":
		window.print();
		break;	
	default:
		var win = window.open(url, action, size);
		break;
  }
}

function byline(date) {u=encodeURIComponent(location.href);t=encodeURIComponent(document.title); document.write('<p class="byline"><span class="author">' + date + '</span></p> <div class="share"><a href="mailto:?subject=' + t + '&body=' + u + ' [Sent from Digital Inspiration]"><img width="89" height="13" src="http://media.digitalinspiration.com/v1/mail.png" border="0"/></a></div>');}

function sharemap(id) {u=encodeURIComponent(location.href);t=encodeURIComponent(document.title);if(id) s="http://labnol.org/?p="+id; else s=u;
p1='<p><img src="http://media.digitalinspiration.com/v1/labnol_spread.png" width="540" height="20" border="0" usemap="#labnol" /><map name="labnol" id="labnol"><area shape="rect" coords="40,0,58,20" href="http://twitter.com/home?source=digitalinspiration&status=' + t + ' ' + s + ' on @labnol"  target="_blank" alt="Share on Twitter" /><area shape="rect" coords="64,0,81,20" href="http://www.facebook.com/sharer.php?u=' + u + '"   target="_blank" alt="Share on Facebook" /><area shape="rect" coords="85,0,102,20" href="mailto:?subject=' + t + '&body=' + s + ' [Sent from Digital Inspiration]" alt="Email a friend" /><area shape="rect" coords="407,0,455,20" href="http://www.labnol.org/" alt="Go to home page" /><area shape="rect" coords="470,0,535,20" href="http://www.labnol.org/tag/feature/" alt="Browse the archives" /></map></p>';document.write(p1);}

function get_ref(){referrer=decodeURIComponent(document.referrer);var query=null;if(referrer.match(/^http:\/\/(www)?\.?google.*/i)){if(referrer.match(/q=/))query=referrer.replace(/^.*[?&_]q=([^&]+)&?.*$/i,'$1')}else if(referrer.match(/^http:\/\/(www)?\.?bing*/i)){if(referrer.match(/q=/))query=referrer.replace(/^.*q=([^&]+)&?.*$/i,'$1')}else if(referrer.match(/^http:\/\/.*search\.yahoo.*/i)){if(referrer.match(/p=/))query=referrer.replace(/^.*p=([^&]+)&?.*$/i,'$1')}if(query){query=query.replace(/\'|"/,'');query=query.replace(/\+/g,' ')}return query;};

function local_query(){s=decodeURIComponent(location.href);var query="";if(s.match(/q=/))query=s.replace(/^.*[?&]q=([^&]+)&?.*$/i,'$1');if(query){query=query.replace(/\+/g,' ');}return query;}

var tr=new Array()
tr[0]="<table width='100%' cellspacing='1' cellpadding='30'> <tr><td width=\"32%\"><a href=\"#\" onclick=\"share('lang','fr'); return false;\">français</a></td>    <td width=\"32%\"><a href=\"#\" onclick=\"share('lang','de'); return false;\">deutsch</a></td>    <td><a href=\"#\" onclick=\"share('lang','nl'); return false;\">nederlands</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','it'); return false;\">italiano</a></td>    <td><a href=\"#\" onclick=\"share('lang','es'); return false;\">español</a></td>    <td><a href=\"#\" onclick=\"share('lang','pt'); return false;\">português</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','hi'); return false;\">हिन्दी</a></td>    <td><a href=\"#\" onclick=\"share('lang','zh-CN'); return false;\">中文</a></td>    <td><a href=\"#\" onclick=\"share('lang','ar'); return false;\">عَرَبيْ</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','ru'); return false;\">pусский</a></td>    <td><a href=\"#\" onclick=\"share('lang','ja'); return false;\">日本語</a></td>    <td><a href=\"#\" onclick=\"share('lang','ko'); return false;\">한국어</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','ro'); return false;\">română</a></td>    <td><a href=\"#\" onclick=\"share('lang','pl'); return false;\">polski</a></td>    <td><a href=\"#\" onclick=\"share('lang','el'); return false;\">Ελληνική</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','cs'); return false;\">čeština</a></td>    <td><a href=\"#\" onclick=\"share('lang','da'); return false;\">dansk</a></td>    <td><a href=\"#\" onclick=\"share('lang','bg'); return false;\">Български</a></td>  </tr>  <tr>    <td><a href=\"#\" onclick=\"share('lang','no'); return false;\">norsk</a></td>    <td><a href=\"#\" onclick=\"share('lang','sv'); return false;\">svenska</a></td>    <td><a href=\"#\" onclick=\"share('lang','fi'); return false;\">suomi</a></td>  </tr></table>";


function favthis() {
 title = "Digital Inspiration"; url="http://www.labnol.org";
 if (window.sidebar) { window.sidebar.addPanel(title, url,"");
 } else if( window.external ) { window.external.AddFavorite( url, title); 
 } else if(window.opera && window.print) { return true; }
}


var menuwidth='500px';
var disappeardelay=500;
var hidemenu_onclick="no";

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dmdiv" style="visibility:hidden;width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dd(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dmdiv") : dmdiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
dh()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
dh()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function dh(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu