// 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 check_length(my_form)
{
maxLen = 500; // max number of characters allowed
if (my_form.my_text.value.length >= maxLen) {
// Alert message if maximum limit is reached. 
// If required Alert can be removed. 
var msg = "You have reached your maximum limit of characters allowed";
alert(msg);
// Reached the Maximum length so trim the textarea
my_form.my_text.value = my_form.my_text.value.substring(0, maxLen);
}
else{ // Maximum length not reached so update the value of my_text counter
my_form.text_num.value = maxLen - my_form.my_text.value.length;}
}

jQuery(document).ready(function(){
	jQuery('.rounded').corners("top-left bottom-left");
	jQuery('.roundedside').corners("top-right bottom-right"); /* test for double rounding */
});

function update_quotes()
{
	$('progress').show();

	//document.getElementById('button_ack').style.backgroundColor = "#FFFFFF";
	new Ajax.Updater( 'quote_list', '/add_quotes.php',
	{

		method: 'post' ,
		parameters: $('my_form').serialize(),
		insertion: Insertion.Top,
		onSuccess: function (){
			$('my_text').value = '';
			$('progress').hide();
			//document.getElementById('button_acknowledgement').style.backgroundColor = "#FFFFFF";


		}
	} );
}
function closediv(popup_target) {
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  element.style.display = 'none';
}
function unfollow(id) {
	iddiv='#auth_'+id;
	new Ajax.Request("/unfollow.php",
	{
		method: 'post',
		postBody: 'author_id='+ id,
		onComplete: function(b) { 
		jQuery(iddiv).hide();
		var msg = b.responseText +' un-followed';
		jQuery("#modalbody").text(msg);
		var animStyle = 'slide';
		jQuery('#msg1').notificationmsg({animation:animStyle});
		jQuery('#msg1').notificationmsg('show');  
		}
	});
}
function update_original()
{
	new Ajax.Request("/checkQuote.php", {
 	method: 'post',
	postBody: 'quote='+ $('my_text').value,
  	onSuccess: function(transport) {
	//alert(transport.responseText);
			if (transport.responseText=='0'){
   		 		jQuery('#quotelatest').html( '<strong>Yes</strong> ');
			}else{
				jQuery('#quotelatest').html( '<strong>Your text appears <a href="http://www.google.com/#hl=en&q='+ $('my_text').value+'&aq=f&oq=&aqi=&fp=kE0CVI1PqvM" target="_blank">'+transport.responseText+'</a> times on the internet</strong> ');
			}
  	}
});

}

function delete_quotes(id) {

	new Ajax.Request("/delete_quote.php",
	{
		method: 'post',
		postBody: 'qid='+ id,
		onComplete: function(res) { fadediv(id);  }
	});
}
function fadediv(id){
	$('fade_demo_'+id).fade();
	return false;
}
function managefollow(){

jQuery('.unfollow').show();

}
jQuery(document).ready( function(){
	jQuery('.unfollow').hide();
	jQuery('.sidebarBox').corners();
	jQuery('.catsidebarBox').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";
	jQuery('#cmbAutoTweet').change(function(){
		jQuery.post("/tweet_settings.php", 'cmbAutoTweet='+jQuery('#cmbAutoTweet option:selected').val(), function(data){
			//alert(data);
		});
	});

});
jQuery(
function()
{
	//setInterval("getSearchGeneric()",10000);

	
	timer=setTimeout("RandomQuote()",15000);

	//setInterval("getSearchFeed()",20000);
	RandomQuote();
	
	//getSearchGeneric();
	//getSearchFeed();

}
);

function pauseIt(){
	clearTimeout(timer);
	countershown=20;
	document.getElementById('expander').innerHTML='<img src="/images_web/playbtn.png" alt="Pause" 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()";
}

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 followmypage(fname) {
	new Ajax.Request("/addFollowerMyPage.php",
	{
		method: 'post',
		postBody: 'followname='+fname,
		onComplete: function(res) {  changediv();  }
	});
}
function updatefollow(imgName) {
	new Ajax.Request("/update_follow.php",
	{
		method: 'post',
		onComplete: function(res) {  
		if (imgName == 'http://www.iwise.com/images_web/off.png') {
			document.tweet_followbutton.src="/images_web/on.png";
		  } else {
			document.tweet_followbutton.src="/images_web/off.png";
		  } }
		});
		
	
}
function updatedm(imgName) {
	new Ajax.Request("/update_dm.php",
	{
		method: 'post'
		,
		onComplete: function(res) {  
		if (imgName == 'http://www.iwise.com/images_web/off.png') {
			document.dmbutton.src="/images_web/on.png";
		  } else {
			document.dmbutton.src="/images_web/off.png";
		  } }
		});
		
	
}
function updatebookmark(imgName) {
	new Ajax.Request("/update_bookmark.php",
	{
		method: 'post',
		onComplete: function(res) {  
		if (imgName == 'http://www.iwise.com/images_web/off.png') {
			document.tweet_bookmarkbutton.src="/images_web/on.png";
		  } else {
			document.tweet_bookmarkbutton.src="/images_web/off.png";
		  } }
		});
		
	
}
function changediv() {
	jQuery('#chg').html('<div><img src="/images_web/Following.png" alt="Following" title="Following"/></div>');
}
function imgChange1( img ) { document.follow.src = img; }
function Rollover( img,id ) { document.getElementById(id).src = img; }

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;
	}
}