// JavaScript Document

function addFavAuth(b,a){new Ajax.Request("/add_to_fav_auth.php",{method:"post",postBody:"auth_id="+b+"&quote_id="+a,onComplete:function(c){showAuthor(c)}})}
function showAlert(){
jQuery(document).ready( function(){
var msg = 'Copied to your clipboard';
jQuery("#modalbody").text(msg);
var animStyle = 'slide';
jQuery('#msg1').notificationmsg({animation:animStyle});
jQuery('#msg1').notificationmsg('show');
});
}
function openBookmarkLogin(a){window.location.href='/loginTwitter.php?bookmarkid='+a;}
var bookmarkVal = 1; 
function changeme(chgval){ 
if(chgval == 1){ 
bookmarkVal = 1; 
}else{ 
bookmarkVal = 0; 
}
} 
function postbookmark(b) {
	if(bookmarkVal == 1) {
		new Ajax.Request("/twitterBookmark.php",{method:"post",postBody:"quotation_id="+b})
	} 
}
function addFav(a){
	new Ajax.Request("/add_to_fav.php",{method:"post",postBody:"quotation_id="+a,onComplete:function(b){
	
	document.getElementById("bookmarklink"+ a ).style.color = '#777777';
	document.getElementById("bookmarklink"+ a ).style.cursor="default";
	var msg = 'Bookmarked successfully';
	jQuery("#bookmarkmodalbody").text(msg);
	var animStyle = 'slide';
	jQuery('#bookmarkmsg1').notificationmsg({animation:animStyle});
	jQuery('#bookmarkmsg1').notificationmsg('show');window.setTimeout("postbookmark(" + a + ")", 7000);
	showQuote(b)}})}



function showAuthor(a){if(a.responseText!=""){showdiv(a.responseText);changeIt("plus.png","imageauth"+a.responseText)}else{hidediv(a.responseText)}}

function showQuote(a){if(a.responseText!=""){
	
	showdiv(a.responseText);changeIt("plus.png","imagequote"+a.responseText)}else{hidediv(a.responseText)}}

function hidediv(a){if(document.getElementById){document.getElementById("hideshow"+a).style.visibility="hidden"}else{if(document.layers){document.hideshow.visibility="hidden"}else{document.all.hideshow.style.visibility="hidden"}}}
function showdiv(a){if(document.getElementById){document.getElementById("hideshow"+a).style.visibility="visible";setTimeout("hidediv("+a+")",1000)}else{if(document.layers){document.hideshow.visibility="visible";setTimeout("hidediv("+a+")",1000)}else{document.all.hideshow.style.visibility="visible";setTimeout("hidediv("+a+")",1000)}}}

function changeIt(a,c){var d=document.getElementById(c);var b="<img src='/images_web/"+a+"' border='0' />";d.innerHTML=b;return}

function copy_to_clipboard(a){if(window.clipboardData){window.clipboardData.setData("text",a)}else{var b=document.getElementById("divclipboardswf");if(b==null){b=document.createElement("div");b.setAttribute("name","divclipboardswf");b.setAttribute("id","divclipboardswf");document.body.appendChild(b)}b.innerHTML='<embed src="clipboard.swf" FlashVars="clipboard='+encodeURIComponent(a)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>'}alert("The text is copied to your clipboard...");return false}function update_quotes(){$("progress").show();$("error").hide();new Ajax.Updater("quotes","post_quote.php",{method:"post",parameters:$("postquote").serialize(),insertion:Insertion.Top,onSuccess:function(){$("quote").value="";$("first_name").value="";$("last_name").value="";$("progress").hide()}})}function openShareWindow(a){jQuery(document).ready(function(){url="/sendtofriend.php?height=710&width=1000&filename="+a+"&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}function eMailCard(a,b){jQuery(document).ready(function(){url="/eMailCard.php?height=710&width=1000&quote_id="+b+"&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}function openEcardWindow(a,b,e,d,c){jQuery(document).ready(function(){url="/ecard_creator.php?height=605&width=900&searchType="+a+"&quote_id="+b+"&secure="+e+"&searchQuery="+d+"&authorSearched="+c+"&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}function openEmailWindow(d,b,c,a){Modalbox.show("/email_quote.php",{title:"",width:550,params:{author:d,quote_id:b,return_url:c,filename:a}});return false}function openTagEmailWindow(d,b,c,a){Modalbox.show("/email_tag_video.php",{title:"",width:550,params:{video_title:d,video_link:b,return_url:c,filename:a}});return false}function openLoginWindow(){url="/login.php?height=200";tb_show("",url,"");return false}function openMenuWindow(e,c,d,b,a,f,g){Modalbox.show("/Menu2/ScrollWithoutEcard.php",{title:"",width:940,params:{author:e,author_id:c,icon:d,script:b,quote:a,tag:f}});return false}function openTwitterWindow(a){Modalbox.show("/twitter_login.php",{title:"",width:420,height:200,params:{quote_id:a}});return false}/*function openTwitterWindow(a){jQuery(document).ready(function(){url="/twitter_login.php?height=850&width=900&quote_id="+a+"&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}*//*function openFbWindow(a){jQuery(document).ready(function(){url="/facebook_login.php?height=200&width=420&quote_id="+a+"&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}*/function openUserTwitterWindow(a){Modalbox.show("/userquote_twit.php",{title:"",width:420,params:{id:a}});return false}/*function userReTweet(a){Modalbox.show("/userquote_twit.php",{title:"",width:420,params:{quote_id:a}});return false}*//*function openVideo(){Modalbox.show("/home_player.php",{title:"",width:590,height:407});return false}*/function openVideo(){jQuery(document).ready(function(){url="/home_player.php?height=650&width=600&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}function errorReport(){jQuery(document).ready(function(){url="/errorReport.php?height=650&width=600&amp;keepThis=true&amp;TB_iframe=true&modal=true";tb_show("",url,"")})}function openWallpaperWindow(d,b,a,c,subject){Modalbox.show("/QBImageWithIcon/create_wallpaper.php",{title:"",width:1000,params:{author:d,icon:c,author_id:b,quote:a,tag:subject}});return false}function loaded(){var a=document.getElementsByName("thickbox");for(i=0;i<a.length;i++){a[i].style.visibility="visible"}};
function openFbWindow(a){

	new Ajax.Request("/facebook_canvas.php",{method:"post",postBody:"quote_id="+a,onComplete:function(b){
	
	document.getElementById("bookmarklink"+ a ).style.color = '#777777';
	document.getElementById("bookmarklink"+ a ).style.cursor="default";
	var msg = 'Posted to Facebook successfully';
	jQuery("#modalbody").text(msg);
	var animStyle = 'slide';
	jQuery('#msg1').notificationmsg({animation:animStyle});
	jQuery('#msg1').notificationmsg('show');
	showQuote(b)}})
}
function openFbTagMsgWindow(a){

	new Ajax.Request("/facebook_canvas.php",{method:"post",postBody:"tag_msg="+a,onComplete:function(b){

	var msg = 'Posted to Facebook successfully';
	jQuery("#modalbody").text(msg);
	var animStyle = 'slide';
	jQuery('#msg1').notificationmsg({animation:animStyle});
	jQuery('#msg1').notificationmsg('show');
	showQuote(b)}})
}

function reTweetMsg(tweetmsg) {

	var msg = 'Tweeted successfully';
	jQuery("#twittermodalbody").text(msg);
	var animStyle = 'slide';
	var img = '/images_web/retweet_2.gif';
	jQuery('#twittermsg1').notificationmsg({animation:animStyle});
	jQuery('#twittermsg1').notificationmsg('show');
	//imgChangeRetweet(img,quoteid); 
	document.getElementById('retweetimgs1').src = img;
	jQuery.ajax({
		type: "POST",
		url: "/reTweetMsg.php",data: "retweet_msg="+ tweetmsg,
		success: function(msg) {
		
			},
		error: function(xhr,msg,e){
			alert(msg);
		}
	});
	
}	
function userReTweet(quoteid) {
	
	var msg = 'Tweeted successfully';
	jQuery("#twittermodalbody").text(msg);
	var animStyle = 'slide';
	var img = '/images_web/retweet_2.gif';
	jQuery('#twittermsg1').notificationmsg({animation:animStyle});
	jQuery('#twittermsg1').notificationmsg('show');
	//imgChangeRetweet(img,quoteid); 
	document.getElementById('retweetimg'+quoteid).src = img;
	jQuery.ajax({
		type: "POST",
		url: "/reTweetQuote.php",data: "quote_id="+ quoteid,
		success: function(msg) {
			},
		error: function(xhr,msg,e){
			alert(msg);
		}
	});
	
}
function imgChangeRetweet( img,quote_id ) {

	if(document.getElementById('retweetimg'+quote_id).src!='http://www.iwise.com/images_web/retweet_2.gif'){
		document.getElementById('retweetimg'+quote_id).src = img;
	}
}
function userQuoteReTweet(quoteid) {
	
	var msg = 'Tweeted successfully';
	jQuery("#twittermodalbody").text(msg);
	var animStyle = 'slide';
	var img = '/images_web/retweet_2.gif';
	jQuery('#twittermsg1').notificationmsg({animation:animStyle});
	jQuery('#twittermsg1').notificationmsg('show');
	//imgChangeUserRetweet(img,quoteid);
	document.getElementById('userretweetimg'+quoteid).src = img;
	jQuery.ajax({
		type: "POST",
		url: "reTweetUserQuote.php",data: "quote_id="+ quoteid,
		success: function(msg) {
			 },
		error: function(xhr,msg,e){
			alert(msg);
		}
	});
	
}
function imgChangeUserRetweet( img,quote_id ) {
	if(document.getElementById('retweetimg'+quote_id).src!='http://www.iwise.com/images_web/retweet_2.gif'){
		document.getElementById('userretweetimg'+quote_id).src = img;
	}
}
jQuery(document).ready( function(){

	jQuery('.sidebarBox').corners();
	jQuery('.catsidebarBox').corners();	
	jQuery('.resultsearchauthor').corners();
	
	image1 = new Image();
	image1.src = "/images_web/favOff.png";

	image2 = new Image();
	image2.src = "/images_web/retweetOFF.png";

	image3 = new Image();
	image2.src = "/images_web/ReMailOn.png";

	image4 = new Image();
	image4.src = "/images_web/add_fav.png";

	image5 = new Image();
	image5.src = "/images_web/retweetRollover.png";

	image6 = new Image();
	image6.src = "/images_web/email.png";

});
function pauseIt(){
	clearTimeout(timer);
	countershown=20;
	document.getElementById('expander').innerHTML='<img src="/images_web/playbtn.png" alt="Play" border="0"/>';
	document.getElementById('expander').href="javascript:startIt()";
}
function startIt(){
	timer=setTimeout("RandomQuote()",5000);
	countershown=0;
	document.getElementById('expander').innerHTML='<img src="/images_web/pausebtn.png" alt="Pause" border="0"/>';
	document.getElementById('expander').href="javascript:pauseIt()";
}
function format_txt(res)
{
	res = res.replace(/(gissisim)/ig, '<strong class="twitterfeeds">$1</strong>');
	return res.makeLink();
}
function closevideo(){

jQuery('.video').hide();
//document.getElementById('videoclose').src = 'http://www.iwise.com/images_web/Plus_0.gif';

document.getElementById('videoclosebtn').innerHTML='<img src="/images_web/Plus_0.gif" alt="Close" border="0" onmouseover="imgChangeVideoClose("/images_web/Plus_1.gif")" onmouseout="imgChangeVideoClose("/images_web/Plus_0.gif")" />';
document.getElementById('videoclosebtn').href="javascript:showvideo()";

}
function showvideo(){

jQuery('.video').show();
//document.getElementById('videoclose').src = 'http://www.iwise.com/images_web/Plus_0.gif';

document.getElementById('videoclosebtn').innerHTML='<img src="/images_web/Close_0.gif" alt="Close" border="0" onmouseover="imgChangeVideoClose("/images_web/Close_1.gif")" onmouseout="imgChangeVideoClose("/images_web/Close_0.gif")" />';
document.getElementById('videoclosebtn').href="javascript:closevideo()";

}
function imgChangeVideoClose( img ) {

	
		document.getElementById('videoclose').src = img;
	
}
function linkup(link)
{
	link = link.replace('&lt;a href=&quot;','<a href="');
	link = link.replace('&quot;&gt;','">');
	link = link.replace('&lt;/a&gt;','</a>');
	return link;
}

String.prototype.makeLink = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/~.=]+/, function(m) {
		return m.link(m);
	});
};

function get_time(time_value) { 
	var valArr = time_value.split(" ");
	time_value = valArr[2] + " " + valArr[1] + ", " + valArr[3] + " " + valArr[4];
	var parsedDt = Date.parse(time_value);
	var relTo = (arguments.length > 1) ? arguments[1] : new Date();
	var secs = parseInt((relTo.getTime() - parsedDt) / 1000);
	secs = secs + (relTo.getTimezoneOffset() * 60);

	var r = '';
	if (secs < 60) {
		r = 'a minute ago';
	} else if(secs < 120) {
		r = 'couple of minutes ago';
	} else if(secs < (45*60)) {
		r = (parseInt(secs / 60)).toString() + ' minutes ago';
	} else if(secs < (90*60)) {
		r = 'an hour ago';
	} else if(secs < (24*60*60)) {
		r = '' + (parseInt(secs / 3600)).toString() + ' hours ago';
	} else if(secs < (48*60*60)) {
		r = '1 day ago';
	} else {

		r = (parseInt(secs / 86400)).toString() + ' days ago';
	}

	return r;
}
function twitter_callback ()
{
	return true;
}
jQuery(function() {
	jQuery('.desc').truncate({max_length: 230});
});
function ShowImg(quote_id,imgsrc,imgsrc2,imgsrc3) {
	if ( imgsrc ) {
		document.getElementById('targetImg_'+quote_id).src = imgsrc;
	} else {
		document.getElementById('targetImg_'+quote_id).src = '/images_web/Blank.gif';
	}
	if ( imgsrc2 ) {
		document.getElementById('targetImg2_'+quote_id).src = imgsrc2;
	} else {
		document.getElementById('targetImg2_'+quote_id).src = '/images_web/Blank.gif';
	}
	if ( imgsrc3 ) {
		document.getElementById('targetImg3_'+quote_id).src = imgsrc3;
	} else {
		document.getElementById('targetImg3_'+quote_id).src = '/images_web/Blank.gif';
	}
}
/*function followAuthor(author_id) {
	new Ajax.Request("addFollower.php",
	{
		method: 'post',
		postBody: 'aid='+ author_id,
		onComplete: function(res) { changediv(author_id);  }
	});
}
*/
function followAuthor(author_id) {
	new Ajax.Request("/addFollower.php",{method:"post",postBody:"aid="+author_id,onComplete:function(res){
	var msg = 'Followed successfully';
	jQuery("#followmodalbody").text(msg);
	var animStyle = 'slide';
	jQuery('#followmsg1').notificationmsg({animation:animStyle});
	jQuery('#followmsg1').notificationmsg('show');changediv(author_id);window.setTimeout("postfollow(" + author_id + ")", 7000);
	}});
}
function changediv(author_id) {
	jQuery('#chg_'+author_id).html('<div><img src="/images_web/Following.png" alt="Following" title="Following"/></div>');
	jQuery('.expandtext').corners("");
}
function imgChange1( img,author_id ) {
	document.getElementById('follow'+author_id).src = img;
}
function showAlert(){
//alert('abhi');
/* 	jQuery("#copied").show();
  	setTimeout(function(){
  	jQuery("#copied").fadeOut("slow", function () {
  	jQuery("#copied").hide();
     });
}, 2000);*/
jQuery(document).ready( function(){
	var msg = 'Copied to your clipboard';
	jQuery("#modalbody").text(msg);
	var animStyle = 'slide';
	jQuery('#msg1').notificationmsg({animation:animStyle});
	jQuery('#msg1').notificationmsg('show');
});
}