
function show()
{
	$("div.test").slideDown("slow")
}
function hide()
{
	$("div.test").slideUp("slow")
	document.getElementById("result").innerHTML = "";
}
function hide2()
{$("div.test").slideUp("slow");	}
function showImg(imgName)
{	var img = document.getElementById('graph');
	if (imgName=="bse")
	{
		img.src = "http://ichart.finance.yahoo.com/t?s=%5EBSESN";
		img.title = "Indian stock market graph - BSE";					
	}
	else if (imgName=="nse")
	{
		img.src = "http://ichart.finance.yahoo.com/t?s=%5ENSEI";
		img.title = "Indian stock market graph - NSE";		
	}		
	else if (imgName=="gold")
	{
		img.src = "http://www.kitconet.com/charts/metals/gold/t24_au_en_ingr_2.gif";
		img.title = "Latest Gold prices in Indian Rupee per Gram - updated Every 24 hours";		
	}		
	else if (imgName=="silver")
	{
		img.src = "http://www.kitconet.com/charts/metals/silver/t24_ag_en_ingr_2.gif";
		img.title = "Latest Silver prices in Indian Rupee per Gram - updated Every 24 hours";		
	}		
}		
function dontAcceptEnter()
{
	if (window.event.keyCode == 13) 
	{
		event.returnValue=false; 
		event.cancel = true;
	}
}
function AjaxFunction()
{	$.ajax({type: "GET",
			url: "ajax/suggestsite.aspx",
			data: {url:$('#url').val()},
			success: function(msg)
			{	
				$("#result").empty();			
				$("#result").append(msg);
				
			},
			error: function(XReq, errs, errobj)
			{
				$("#result").empty();			
				$("#result").append("Sorry there is an error.");
			}
			});		
}
//var pagePath = 'http://localhost/saradaga';

var pagePath = '';

$(document).ready(function() 
{
	
	//getRssFeed('forex',$("span#forex"));
	callAjaxOutput('ajax/telugu.aspx?tag=cinejosh','teluguNews');
	//getAjaxOutput(pagePath + 'ajax/rating.aspx?movieCnt=5',$("span#movieRatings"));
	$('#container-joke').tabs({ remote: true });  
	getRssFeed('todayQuote',$("span#todayQuote"));
	//getAjaxOutput(pagePath + 'ajax/cricket.aspx',$("span#cricket"));
	
	getAjaxOutput(pagePath + 'ajax/horoscope.aspx',$("span#horoscope"));	
	getAjaxOutput(pagePath + 'ajax/flickr/flickrGals.aspx',$("span#spanFlickr"));
	
	//getAjaxOutput(pagePath + 'Misc/tagCloud.aspx',$("span#tagCloud"));
	
	//getAjaxOutput(pagePath + 'ajax/marqXml.aspx',$("span#marqXml"));
	getAjaxOutput(pagePath + 'ajax/marqTollyLImages.aspx?direction=left',$("span#TollymarqXml"));
	//callAjaxOutput('ajax/Misc/saradagatv.aspx','tv');

	callAjaxOutput('ajax/telugu.aspx?tag=IndianJoke','jokes');
callAjaxOutput('ajax/telugu.aspx?tag=workpermit','immiNews');
	callAjaxOutput('ajax/telugu.aspx?tag=rediff','indianNews');
		callAjaxOutput('ajax/telugu.aspx?tag=ndtvBusiness','businessNews');
	getRssFeed('randomsametha',$("span#randomsametha"));
	getAjaxOutput(pagePath + 'ajax/worldTimings.aspx',$("span#worldTimings"));
	//getUserVid('ipl',$("ul#ulMycarouseluserVid"),$("div#userVidMes"),'mycarouseluserVid');
	getUserVid('saradagachannel',$("ul#ulMycarousel6"),$("div#userVid6"),'mycarousel6');
	getUserVid('tv9telugu',$("ul#ulMycarousel7"),$("div#userVid7"),'mycarousel7');
	getUserVid('gulteet2',$("ul#ulMycarousel8"),$("div#userVid8"),'mycarousel8');
	getUserVid('latest9telugunews',$("ul#ulMycarousel9"),$("div#userVid9"),'mycarousel9');
	getUserVid('bollywoodbackstage',$("ul#ulMycarousel10"),$("div#userVid10"),'mycarousel10');
	
	//callAjaxOutput('ajax/flickr/fSetThumbs.aspx','fSets');
	//showGoogleAd('tollyNews');to do later
	
	
});

$(window).load(function () {
	
       //if ($.cookie('tvAnimated') == null)
       //{
		$("div#tvDiv").show("slow");
		$("div#tvDiv").animate({left:'+=100px'}, 3000);
		$("div#tvDiv").animate({left:'-=100px'}, 3000);
		
		//$.cookie('tvAnimated', 'true', { expires: 1 });	
      // }
    });

function callAjaxOutput(url, divId)
{
getAjaxOutput(pagePath + url,$("span#"+divId+""));
}

function callAjaxOutputDiv(url, divId)
{	
	getAjaxOutput(pagePath + url,$("div#"+divId+""));
	//alert('Refreshed.');
}
function getRssFeed(tag,obj)
{		
	$.ajax({type: "GET",
			url: "ajax/telugu.aspx",
			data: {tag:tag},
			success: function(msg)
			{	
				$(obj).empty();			
				$(obj).append(msg);
				
			},
			error: function(XReq, errs, errobj)
			{
				$(obj).empty();			
				$(obj).append("Sorry temporarly unavailable");
			}
			});	
}
//this function returns latest gallery images
function getAjaxOutput(url,obj)
{	
$(obj).empty().append('Loading...Please wait..');	
$.ajax({type: "GET",
			url: url,			
			success: function(msg)
			{	
				$(obj).empty();			
				$(obj).append(msg);
				
			},
			error: function(XReq, errs, errobj)
			{
				$(obj).empty();			
				$(obj).append("Sorry temporarly unavailable");
			}
			});	
}
function showDiv()
{	document.getElementById("ajaxDiv").style.visibility = 'visible';
	document.getElementById("ajaxDiv").style.display = 'inline';
}
function hideAjaxDiv()
{	document.getElementById("result").innerHTML = "";
	document.getElementById("ajaxDiv").style.visibility = 'hidden';
	document.getElementById("ajaxDiv").style.display = 'none';
}

function applyTheme(color)
{	$("td").filter("#themeCol").removeClass().addClass(color + "Col");
	$("img").filter("#left_top_").attr("src","images/left_top_"+color+".gif");	
	$("img").filter("#right_top_").attr("src","images/right_top_"+color+".gif");	
	$("img").filter("#left_bottom_").attr("src","images/left_bottom_"+color+".gif");
	$("img").filter("#right_bottom_").attr("src","images/right_bottom_"+color+".gif");
	$("td").filter("#line_left_").attr("background","images/line_left_"+color+".gif");	
	$("td").filter("#line_right_").attr("background","images/line_right_"+color+".gif");
	$("td").filter("#line_bottom_").attr("background","images/line_bottom_"+color+".gif");
	$("td").filter("#bar").removeClass().addClass("topbar"+color);
	$("img#_logo").attr("src","images/"+color+"_logo.jpg");
	//$.cookie('theme', '', { expires: -1 });
	//$.cookie('theme', color, { expires: 60 });	
}
function checkTheme()
{	//check if cookies exists so that we will display that color theme
	if ($.cookie('theme')!=null)	
		applyTheme($.cookie('theme'));	
}

function checkAndForceTheme(color)
{	//check for theme cookie and it null then force the color i Like
	if ($.cookie('theme')==null)	
	{
		$.cookie('theme', color, { expires: 60 });
		applyTheme($.cookie('theme'));	
	}
}

function setTodayColor()
{
	var d=new Date();	
	if(d.getDay() == 0)//sunday
		applyTheme('voilet');	
	else if(d.getDay() == 1)//monday
		applyTheme('voilet');
	else if(d.getDay() == 2)//"Tuesday"
		applyTheme('voilet');
	else if(d.getDay() == 3)//"Wednesday"
		applyTheme('voilet');
	else if(d.getDay() == 4)//"Thursday"
		applyTheme('voilet');
	else if(d.getDay() == 5)//"Friday"
		applyTheme('voilet');
	else if(d.getDay() == 6)//"Saturday"
		applyTheme('voilet');
	
}


function removeTheme()
{	if ($.cookie('theme')!=null)	
		$.cookie('theme', '', { expires: -1 });	
	window.location='http://www.saradaga1.com';
}

function showGoogleAd(obj)
{
///not completed yet- to do later
	var ad = "";
	ad += "<script type=\"text/javascript\">\n<!--\n";
	ad += "google_ad_client = \"pub-5403470932574918\";\n";
	ad += "/* Saradaga Home 300x250 TOP */\n";
	ad += "google_ad_slot = \"1836763041\";\n";
	ad += "google_ad_width = 300;\n";
	ad += "google_ad_height = 250;\n";
	ad += "//-->\n";
	ad += "</script>\n";
	ad += "<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"></script>";
	alert(ad);
	$(obj).empty().append(ad);	
}

function getMostViewedGals(duration)
{
	$("div#mostViewedGalMes").empty().append("Please wait...loading..");
	getAjaxOutput('ajax/Misc/topViewedGals.aspx?duration='+duration+'',$("ul#ulMycarouselMostVisited"));
	$("div#mostViewedGalMes").empty().append("");
}
function getUserVid(username,obj, objmes,carid)
{
	$(objmes).empty().append("Please wait...loading..");
	getAjaxOutput('ajax/Misc/userVids.aspx?uname='+username+'&carid='+carid+'',$(obj));
	$(objmes).empty().append("");
}
function getMostViewedGalsTop(duration)
{
	
	
	getAjaxOutput('ajax/Misc/topViewedGals.aspx?duration='+duration+'',$("ul#ulMycarouselMostVisitedTop"));
		
	
}

function rotate(thumb)
{
	var imageurl = thumb.src;
	thumb.src = imageurl.replace("/2.jpg", "/1.jpg");

	setTimeout(function() {
			thumb.src = imageurl.replace("/2.jpg", "/3.jpg");
	}, 1000);

}

function rotateimages(thumb, path, img1, img1Width,img1Height, img2, img2Width, img2Height)
{
	var image = thumb.src;	
	var orgwid = thumb.width;
	var orghig = thumb.height;
	
	thumb.src = path +'/'+img1;
	thumb.width=img1Width;
	thumb.height = img1Height;
	
	setTimeout(function() {
			thumb.src = path +'/'+img2;
			thumb.width=img2Width;
			thumb.height = img2Height;
	}, 1000);

}