/*jQuery(function() {
    var $ = jQuery;*/

var leftOffset;
var topOffset;
var respData;
var htmlCopy;
var anasayfa;
var qPar="q=a";
var harfPar;
var c;
var pageNumber=0;
var pageList= new Array()		;
var pageHashList= new Array()	;
var fragment;
var callTimes=0;
var b;	
var cache = {};
var		lastXhr;
var fark;
var selectedMenu;
var cc;
var slidOh;
var hoverBg="#FAF5F6";
var mainW="http://www.caliyorum.com";
var mainP="/yydefault1.php"
jQuery.fn.extend({
    param: function( a ) {
        var s = [];
 
        // If an array was passed in, assume that it is an array
        // of form elements
        if ( a.constructor == Array || a.jquery ){
            // Serialize the form elements
            jQuery.each( a, function(){
                s.push(unescape(encodeURIComponent(escape(this.name))) + "=" + unescape(encodeURIComponent(escape(this.value))));
            });
        }
        // Otherwise, assume that it's an object of key/value pairs
        else{
            // Serialize the key/values
            for ( var j in a )
                // If the value is an array then the key names need to be repeated
                if ( a[j] && a[j].constructor == Array )
                    jQuery.each( a[j], function(){
                        s.push(unescape(encodeURIComponent(escape(j)) + "=" + encodeURIComponent(escape(this))));
                    });
                else
                    s.push(unescape(encodeURIComponent(escape(j)) + "=" + encodeURIComponent(escape(a[j]))));
        }
        // Return the resulting serialization
        return s.join("&").replace(/ /g, "+");
    },

    serialize: function() {
        return this.param(this.serializeArray());
    }
   

});  
jQuery(document).ready(function()
{
	emptyAndHideVideo();
	$("#videoPlayer").draggable() ;
	
	if (window.location.hash)
		{contentload(window.location.hash);}
	  
	
	jQuery.fx.interval = 70;
	 
	var th=$("#mainBody").html().replace(/\/index-/gi,mainP+"#!yy-index-");
	
	$("#mainBody").innerHTML=th;
    
	anasayfa=$("#centerTD").html().replace("%21","!");


	leftOffset = ($("#tema_r1_c1").width() - 800) / 2 +"px";
	topOffset = ($(window).height() - 200) / 2 +"px";	
	$.ajaxSetup({cache: true , async:true, timeout:6000,contentType:"text/html, charset=iso-8859-9"});	
	

	$(window).bind("focus", function(event)
    {
        focusFlag = 1;

    }).bind("blur", function(event)
    {
        focusFlag = 0;
		
		$(".menuLinkYY").parent().removeClass("gradient" );
		$(".menuLinkYY").css("border-bottom","1px none red");
		$("selectedMenu").parent().addClass("gradient" );
    });

	
	/*$(window).bind('resize', function() {
			leftOffset = ($("#tema_r1_c1").width() - 800) / 2 +"px";
			topOffset = ($(window).height() - 200) / 2 +"px";
		});	*/
	c=$('body').css("background-color");
	setMenuLinkEvents();
	
	$("body").append('<div id="ajaxBusy"><p style="position: absolute; filter:alpha(opacity=70); width: 100%; height:100%;	top: 250px;" align="center" "vertical-align"="middle"><img style="width: 80px; height: 80px; position: relative; left: 160px;top:-50px;" src="img/ajax-loader.gif"><span class="style3"> Lütfen Bekleyin </span></p></div>');
	$("#tdGeri").append('<a href="#" class="geriCl" style="width: 24px; height: 24px;position:absolute;margin:0px; padding:0px:left:0px; top:0px;z-index:1;"><img id="geriButton" style="top: 100px; left: 125px; margin: 0px; border:0; padding: 0px;position:absolute;width: 24px; height: 24px;"  src="img/geri.png" alt="Geri Dön"></a>');
	$("#tdGeri").append('<a href="#" class="ileriCl" style="width: 24px; height: 24px;position:absolute;margin:0px; padding:0px:left:0px; top:0px;z-index:1;"><img id="ileriButton" style="top: 100px; left: 850px; margin: 0px; border:0; padding: 0px;position:absolute;width: 24px; height: 24px;"  src="img/ileri.png" alt="Geri Dön"></a>');
	setAllEvents();
	setAjaxEvents();
	htmlCopy=$("#centerTD").html();
	pageList[0]=htmlCopy;
	pageHashList[0]="";
	
	var tt=$("#mainBody").html();

    
	//GSearch.setOnLoadCallback(LoadVideoBar); 

	
	$("#mainBody").attr("style",	"BACKGROUND-IMAGE: url(/img/wood09m1.jpg);background-repeat:no-repeat ;background-attachment: fixed;")
	$("#tema_r1_c1").attr("src","img/tema1/porte1tr.png");
		
	$("#outerHaberTable").carouFredSel({
		items               : 4,
		direction           : "up",
		scroll : { 
			items           : 1,
			effect          : "easeOutBounce",
			duration        : 500,                        
			pauseOnHover    : true
		}                  
	}); 

	
	setAnaSayfaEvents();
	setOuterEvents();
	
	//$.getScript("./js/show_ads.js");
	/*slidOh=	$("#sliderohh").html();
	$("#sliderohh").slider({
		vertical: true,
		easing: 'linear',
		speed:30000	
	});*/


	

});
var tmp;
var tmpS;
var tmpW;
var tmpSpx;	
var tClass;

function setMenuLinkEvents(){
	
	$("#geriButton").live("click", function()
		{
			doBack();
			return false;
		});
		$("#ileriButton").live("click",function()
		{
			doFw();
			return false;
		});
		
	$(".veri[hhref*='yyabonelikekle1.php']").live("click", function(){
		$("#centerTD").load("yyabonelikekle1.php");
	});
	$('.menuLinkYY , .menuLinkYYmini').hover( 
	function()
	{
		$(this).parent().addClass("gradient");
		$(this).css("border-bottom","1px solid red");
	}, function() {
		if ($(selectedMenu).attr("href")==$(this).attr("href") && $(selectedMenu).text()==$(this).text()) 
				return false;
		$(this).parent().removeClass("gradient");
		
		$(this).css("border-bottom","1px solid transparent");
	});
	$(".menuLinkYY , .menuLinkYYmini").live("click", function()
	{
		var pg="yyeserlist.php";
		selectedMenu=$(this);
		document.title=$(this).text();
		$('meta[name=keywords]').attr('content', document.title);
				
		if ($(this).text().indexOf("Eser Arşivi")>=0) qPar="q=a";
		else if($(this).text().indexOf("Söz Arşivi")>=0) qPar="q=b";
		else if($(this).text().indexOf("Nota Arşivi")>=0) qPar="q=c";
		else if($(this).text().indexOf("Nota Çalıyorum *")>=0) qPar="q=g";
		else if($(this).text().indexOf("Hikaye Arşivi")>=0) qPar="q=d";
		else if($(this).text().indexOf("Video Arşivi")>=0) qPar="q=e";
		else if($(this).text().indexOf("Ses")>=0) qPar="q=f"; 
		else if($(this).text().indexOf("Biyografi")>=0){ 
			pg="yybiyografilist.php";
			qPar="Harf=A&q=b";
		}
		else if($(this).text().indexOf("Haberler")>=0){
			pg="yyhaber.php";
		}
		else if($(this).text().indexOf("Albümler")>=0){
			pg="yyalbum.php";
		}		
		
		else if($(this).text().indexOf("Ana Sayfa")>=0){
			mainPage();
			return false;
			
		}
		else  if($(this).text().indexOf("Bağlama Çalıyorum")>=0)
		{
			var hr=$(this).attr("href");
			if (hr) 
				getAnyPage(hr);
			return false;
		}
		else 
		{
			var hr=$(this).attr("href");
			if (hr){
				if(hr=="#!mainPage")
					mainPage();
				else 
					getAnyPage(hr);
			}
			return false;
		}
		var ie6 = ($.browser.msie && $.browser.version < 7); 
		if (ie6){
			$(".menuLinkYY, anasayfaBilgi, .menuLinkYYmini").hover(function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); });
		} 
		getPageWithPar(pg,qPar,1);
		
		var tmpS=".menuLinkYY[href!='" +$(selectedMenu).attr("href") +"'] ,.menuLinkYY[background-color!='transparent'] ";
		$(".menuLinkYY").parent().removeClass("gradient" );
		$(".menuLinkYY").css("border-bottom","1px none red");
		$("selectedMenu").parent().addClass("gradient" );
		
		return false;
	}
	);
}

function mainPage(){
	if ($("#haberColumn").css("display")=="none")
		$("#haberColumn").show();
	if (anasayfa.indexOf("anaSayfaTable")<0)
		location.href=mainW;
	$("#centerTD").empty();			
	$("#centerTD").append(anasayfa);
	location.hash="";
	cc=$("#centerTD");
	jQuery.fx.interval = 10;
	$('html, body').animate({scrollTop:0}, 800,'linear');
	runEffect(cc,"slide");				
	jQuery.fx.interval = 70;
	setAnaSayfaEvents();	
	emptyAndHideVideo();
	return false;
}

function contentload(fragment) {
	location.hash=fragment;
	fragment = fragment.slice(1).replace('!', '')
	//var adr=decodeURI('http://www.caliyorum.com/yydefault1.php'+fragment+'?ajax=1');
	//var adr=decodeURI('http://www.caliyorum.com/'+fragment);
	var adr=decodeURI(fragment);
	getPageWithUrl(adr,1); 
	//$('#centerTD').load(adr);
	
	return false;
} 
function setAjaxEvents(){
	$("#ajaxBusy").live("ajaxStart",function(){
		
		fark=document.documentElement.scrollTop;
		$("div#ajaxBusy").css("top", 		fark);
		$("div#ajaxBusy").css("display","inline");
	
		
		
		$("div#ajaxBusy").css("top", fark);
		$("div#ajaxBusy").show();
		$("div#ajaxBusy").css("display","inline"); 
		return false;
    }).ajaxStop(function(){  	 	
        $("div#ajaxBusy").hide();
		cc=$("#centerTD");//.parents("table:first");
		//$(cc).css("width","10px"); 
		//$(cc).animate({width:'10%'}, 'fast');
		
		jQuery.fx.interval = 10;
		//$(cc).animate({width:'100%'}, 800,'linear'); 
		runEffect(cc,"slide");				
		$('html, body').animate({scrollTop:0}, 800,'linear');
		jQuery.fx.interval = 70;
		
		//$(".menuLinkYY").parent().css("background-image","none" );
		$(".menuLinkYY").parent().removeClass("gradient");
		$(".menuLinkYY").css("border-bottom","1px none red");
		//$(selectedMenu).parent().css("background-image","url('/img/utdGrSm.png')");
		//$(selectedMenu).parent().css("background-repeat","repeat-x");
		$(selectedMenu).parent().addClass("gradient");
		setShareEvents();
		return false;
    });
};

function setHoverEvents(){
	$('.anasayfaBilgi , .albumTable, .haberTable , .outerHaberTableC ' ).hover( 
		function()
		{	
			$(this).css("border","1px ridge red" );
			$(this).addClass("gradient");
			$(this).css("background-repeat","repeat-x");
			$(this).css("background-size","contain");
			$(this).css({cursor: 'pointer'});
			}, function() {
			if (selectedMenu!=$(this)){
			$(this).css("border","1px solid transparent" );
			$(this).removeClass("gradient");
	
			}
		});
		$(".borderDotted").hover( 
		function()
			{	
			tmpB="xx";
			}, function() {
				$(this).css("border",	" 1px dotted  red");
			});
		
		$(".borderBottom").hover( 
		function()
			{	
			tmpB="xx";
			}, function() {
				$(this).css("border-bottom",	" 1px dotted  red");
			});
		
		$(".haberLink,   .eserBilgiTur").hover( 
			function()
			{	
				$(this).parents("td:first").addClass(gradient);
				$(this).css({cursor: 'pointer'});
			}, function() {
			if (selectedMenu!=$(this)){
				$(this).parents("td:first").removeClass("gradient");
				$(this).css("background-color","transparent" );			
			}
		});
		
		
		
		$('tr>td>a.eserListItem , .biyoListItem').hover(
		function()
		{
			$(this).parents("tr:first").find("td").addClass("gradient");
			$(this).css({cursor: 'pointer'});
			}, function() {
			if (selectedMenu!=$(this)){
				$(this).parents("tr:first").find("td").removeClass("gradient");
			}
		});
		$('li a.eserListItem').hover(
		function()
		{
			$(this).parent().addClass("gradient");
			$(this).css({cursor: 'pointer'});
			}, function() {
			if (selectedMenu!=$(this)){
				$(this).parent().removeClass("gradient");
			}
		});
	return false;
	
};
function setAnaSayfaEvents(){
	$(".fotothOH>img").height("75px");
	$(".fotothOH>img").width("65px");
	$(".fotothOH>img").css("margin-left","0px");
	$(".fotothOH>img").css("margin-right","0px");
	
	$(".fotothOH>img").css("offset","0px");
	$(".fotothOH>img").css("float","left");
	$(".fotothOH>img").css("hspace","0px");
	$(".outerHaberListItem").parent().offset(0);
	
	
	setHoverEvents();
	seteEserListItemEvents();
	setAnyWithoutClass();
	setAlbumEvents();
	$(".anasayfakonu").unbind("click");
	$(".anasayfakonu ,  .outerHaberListItem").click(function()
			{
				var options = {};
				var tthis=this;
				var aText=this.hash;//$(this).attr("hhref");
				if (aText){
					aText=aText.replace("#!",""); 
					//$("#centerTD").load(aText);
					if (aText=="mainPage") 
						mainPage();
					else
						getPageWithUrl(aText,1);
				}
				else
					if ($(this).attr("href"))
						window.open($(this).attr("href"));
				return false;
			}	);	

	$("#slidera").carouFredSel({
		items: 3, 
		direction   : "left",  
		auto : {  
			pauseOnHover: true 
			}  ,
		scroll : {
			items           : 1,
			effect          : "easeOutBounce",
			duration        : 500,                        
			pauseOnHover    : true
			}
		}).find(".slide").hover(  
		function() { $(this).find("div").slideDown(); },  
		function() { $(this).find("div").slideUp(); }  
	);
	$("#sliderk").carouFredSel({
			items       : 3, 
			direction   : "left",  
			auto : {  
				pauseOnHover: true 
				}  ,
			scroll : {
			items           : 1,
			effect          : "easeOutBounce",
			duration        : 800,                        
			pauseOnHover    : true
				}
			}).find(".slide").hover(  
			function() { $(this).find("div").slideDown(); },  
			function() { $(this).find("div").slideUp(); }  
		);


}
function getPageWithPar(pg,par, animate){		
			emptyAndHideVideo();
	
			var aText= //"http://www.caliyorum.com/"+
				pg+"?"+par//q=" + harf,// + "&harf="+harf ;
			getPageWithUrl(aText, animate);
			
			return false;			
};
function getAnyPage(adres){
	var rText="";
	adres=adres.replace("#!","");
	iIndex=adres.indexOf("index-");
	var htmlIndex=adres.indexOf(".html");
				
	if(iIndex>-1){
		rText="yyanasayfadetay.php?id=" + adres.substr(iIndex+6,htmlIndex-iIndex-6);
		getPageWithUrl(rText,1);
	}
	else
		getPageWithUrl(adres,1);
	return false;
};


		   

function getPageWithUrl(adres,animate){
			if(!adres) return false;
			emptyAndHideVideo();
	
			var aText= (adres);
			
			aText=encodeBulInURI(aText);
			
				//$("#centerTD").load(aText);
				
				
			//location.hash=aText.replace("www.caliyorum.com/yydefault1.php#","");  
			
			 fark= document.documentElement.scrollTop;
			 window.pageYOffset;
			$("div#ajaxBusy").css("top", 		fark);
			$("div#ajaxBusy").css("display","inline");
			
					
			$.ajax({
				  url: aText,
				  cache: false,
				  scriptCharset: "iso-8859-9",
				  async:true,
				  dataType:"html",
				  success: function(html){
					htmlCopy=$("#centerTD").html();
					if(pageList.length>pageNumber+1)
						pageList.splice(pageNumber+1, pageList.length-pageNumber-1);
					$("#centerTD").empty();
					html=html.replace(/\/index-/gi,mainP+"#!yy-index-") ;
					//$("#centerTD").html(html);
					$("#centerTD").append(html);
					
					if($("#centerTD .konubaslik").text()!="")
						document.title=$("#centerTD .konubaslik").text();
						
					location.hash="!"+aText.replace("http://www.caliyorum.com/","");
						//location.href=location.href.substr(0,location.href.indexOf("?_escaped_fragment_="));
					if (location.href.indexOf("?_escaped_fragment_=")>1)
						//location.href=location.href.replace("?_escaped_fragment_=","#!");
						location.href=mainW + mainP +"#!"+aText.replace("http://www.caliyorum.com/",""); ;
					pageList.push(html);
					pageHashList.push(aText) ;
					pageNumber++;
					setAllEvents();
					$("div#ajaxBusy").hide();
					$("div#ajaxBusy").css("display","none");
					callTimes=0;
				  },
				  error:function (jqXHR, textStatus, errorThrown){
					callTimes++;
					if (callTimes>3)
						{	
							callTimes=0;
							alert("Lütfen tekrar deneyin");// + errorThrown );
							
						return;}
					else
						getPageWithUrl(adres,animate);
					//doBack();
				  }
				});
				$('#centerTD').find('a[href*="/index-"]').each(function(){
					$(this).attr("href", $(this).attr("href").replace("/index-",mainP+"#!yy-index-"));
				});
			//replaceIndPagesWithyyInd();
			//location.hash=aText;
			if (aText.indexOf("eser-nplayer")>=0)
				$("#haberColumn").hide("slow");
			else
				$("#haberColumn").show();
			
			return false;			
			
}

function replaceIndPagesWithyyInd(){
	$('#centerTD').find('a[href*="/index-"]').each(function(){
						$(this).attr("href", $(this).attr("href").replace("/index-",mainP+"#!yy-index-"));
					});
	$('#centerTD').find('a[href^="index-"]').each(function(){
						$(this).attr("href", $(this).attr("href").replace("index-",mainP+"#!yy-index-"));
					});
	return false;

};				

function LoadVideoBar(ss) {
	var videoBar;
	var options = {
		largeResultSet : true,
		horizontal : true,
		string_allDone : "Kapat!",
		thumbnailSize : GSvideoBar.THUMBNAILS_SMALL,

		autoExecuteList : {
		  cycleTime : GSvideoBar.CYCLE_TIME_SHORT,
		  cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
		  
		  executeList : [ss]
		}
	  }
	videoBar = new GSvideoBar(document.getElementById("videoBar-bar"),
							  $("#videoPlayer").get(0), //GSvideoBar.PLAYER_ROOT_FLOATING,
							  options);
	$("#videoBar-bar").show();					
	$("#videoPlayer").show();   
	return false;
							  
}

function seteEserPageNumEvents(){
	$(".eserPageNum").click(  function()
			{
				var aText=this.hash;
				var rText="";
				rText=aText.replace("#!","");
				
				//var aText=$(this).attr("href");
				getPageWithUrl(rText,1);
				
				return false;
			}
		); 
		
	$("a.veribaslik").unbind('click');
	$("a.veribaslik").click(  function()
			{
				var aText=$(this).find("a").attr("href");
				//aText=encodeBulInURI(aText);
				getPageWithUrl(aText,1);
				return false;
			}
		);

}

function runEffect(objt,selectedEffect){
            //get effect type from 
             //most effect types need no options passed by default
            var options = {};
            //check if it's scale, transfer, or size - they need options explicitly set
            if(selectedEffect == 'scale'){ options = {percent: 0}; }
            else if(selectedEffect == 'transfer'){ options = { to: "#button", className: 'ui-effects-transfer' }; }
            else if(selectedEffect == 'size'){ options = { to: {width: 200,height: 60} }; }
            //var x=$(objt).closest('div.portlet_content');
            $(objt).effect(selectedEffect,options,800); 
			return false;

    };
function doBack(){ 
	if(pageNumber<=0) return;
	$("div#ajaxBusy").css("display","inline"); 
	pageNumber--;
	htmlCopy=pageList[pageNumber];
	$("#centerTD").empty();
	$("#centerTD").append(htmlCopy);
	emptyAndHideVideo();
	
	setAllEvents();
	location.hash="!"+ pageHashList[pageNumber]  ;
	$("div#ajaxBusy").hide(); 
	$('html, body').animate({scrollTop:0}, 800,'linear');
	if (pageNumber==0) 
		setAnaSayfaEvents();
	return false;
}
function emptyAndHideVideo(){
    $("#videoBar-bar").hide();
	$("#videoPlayer").empty();
	$("#videoPlayer").hide();
}
function doFw(){
	if(pageNumber>=pageList.length-1) return;
	$("div#ajaxBusy").css("display","inline"); 
	pageNumber++;
	htmlCopy=pageList[pageNumber];		
	$("#centerTD").empty();
	$("#centerTD").append(htmlCopy);
	emptyAndHideVideo();
	
	emptyAndHideVideo();
	
	setAllEvents();
	location.hash="!"+ pageHashList[pageNumber];
	$("div#ajaxBusy").hide(); 
	$('html, body').animate({scrollTop:0}, 800,'linear');
	return false;

}
function setAllEvents(){
	
	replaceIndPagesWithyyInd();
	setAlbumEvents();
	setHoverEvents();
	setAnyWithoutClass();	
	return false;
}

function encodeBulInURI(aText){
				var eqAt=aText.indexOf("bul=");
				var andAt=aText.indexOf("&", eqAt);
				if (andAt==-1) 
					andAt=aText.length;
				var tbEncoded=aText.substr(eqAt+4, andAt-eqAt-4);
				var encodeda=encodeURI(tbEncoded);  
				aText=aText.replace(tbEncoded,encodeda);
				return aText;
}

function setAnyWithoutClass(){
	$("a:not([class])").unbind("click");
	$("a:not([class])").click(function()
			{
				if($(this).attr("hideFocus")) return;
				var options = {};
				var tthis=this;
				var aText=this.hash;//$(this).attr("hhref");
				if (aText){
					aText=aText.replace("#!",""); 
					//$("#centerTD").load(aText);
					if (aText=="mainPage") 
						mainPage();
					else
						getPageWithUrl(aText,1);
				}
				else
					if ($(this).attr("href"))
						window.open($(this).attr("href"));
				document.title=$(this).text();
				$('meta[name=keywords]').attr('content', document.title);
				
				return false;
			}	);	
	return false;
}

function setOuterEvents(){	
	$(".outerALink").unbind("click");
	$(".outerALink").click(function()
			{
				var aText=this.hash;//$(this).attr("hhref");
				if (aText){
					aText=aText.replace("#!",""); 
					//$("#centerTD").load(aText);
					if (aText=="mainPage") 
						mainPage();
					else
						getPageWithUrl(aText,1);
				}
				else
					if ($(this).attr("href"))
						window.open($(this).attr("href"));
				
				
				return false;
			}	);	
	$(".outerHaberTableC").click(function(){
		var aText=$(this).find("a[href!='']").attr("href");
				if (aText){
					aText=aText.replace("#!",""); 
					//$("#centerTD").load(aText);
					if (aText=="mainPage") 
						mainPage();
					else
						getPageWithUrl(aText,1);
				}
				else
					if ($(this).attr("href"))
						window.open($(this).attr("href"));
				
		
		document.title=$(this).find("a[text!='']").text();
		$('meta[name=keywords]').attr('content', document.title);
				
	}	);	
	return false;
			
}

function seteEserListItemEvents(){
			$(".eserListItem , .eserBilgiTur").unbind('click');
				
			$(".eserListItem").click(function()
			{				
				var options = {};
				var tthis=this;
				var aText=this.hash;
				if (!aText)
					aText=$(this).find("a").attr("href");
				var rText="";
					rText=aText.replace("#!","");
				getPageWithUrl(rText,1);
				var vIndex=rText.indexOf("-eser-");
				//if(vIndex>0)
					 LoadVideoBar( rText.substr(0,vIndex-5).replace(/-/g,' ')  );
				document.title=$(this).text();
				$('meta[name=keywords]').attr('content', document.title);
				
				return false;
			});
			$(".eserBilgiTur").click(function()
			{				
				var options = {};
				var tthis=this;
				var aText=this.hash;
				if (!aText)
					aText=$(this).find("a").attr("href");
				var rText="";
				rText=aText.replace("#!","");
				getPageWithUrl(rText,1);
				var vIndex=rText.indexOf("-yy-e-eser-video");
				if(vIndex>0)
					 LoadVideoBar( rText.substr(0,vIndex).replace(/-/g,' ')  );
				if (aText.indexOf("-eser-soz-") >0){
					document.title=$("#eserAdi").text()  + " Eser Sözleri" ;}
				else if (aText.indexOf("-eser-nota-")>0){
					document.title=$("#eserAdi").text() + " Eser Notası" ;}
				else if (aText.indexOf("-eser-video-")>0){
							document.title=$("#eserAdi").text() + " Eser Videosu" ;}
				else if (aText.indexOf("-eser-hikaye-")>0){
							document.title=$("#eserAdi").text() + " Eser Hikayesi" ;}
				else if (aText.indexOf("-eser-ses-")>0){
							document.title=$("#eserAdi").text() + " Eser Ses Kaydı" ;}
				else if ($(this).attr("bilgiType")){
						document.title=$(this).attr("bilgiType") + " " + $(this).text() + " olan eserler";
						}
				
				$('meta[name=keywords]').attr('content', document.title);
				return false;
			});
			seteserListItemVideoImageEvents();
			
			
}

function setShareEvents(){
	var l="http://www.facebook.com/share.php?u=" + window.location  ;//+"%23"+ window.location.hash ;
	//var l="http://www.facebook.com/sharer/sharer.php?u=" + window.location +"&src=sp" ;//+"%23"+ window.location.hash ;
	var ll="http://www.facebook.com/plugins/like.php?href="+ window.location;
	$("#fbShare").attr("href",l.replace("#","%23"));
	$("#fbShare").attr("onclick","return fbs_click()" );
	$("#fbifrm").attr("src",ll.replace("#","%23"));
	/*$("#fbShare").click(function(){ 
		window.open(l);
		});*///("href","http://www.facebook.com/share.php?u=" + window.location);
	l="http://twitter.com/share?original_referer=" + window.location;
	$("#twShare").attr("href",l.replace("#","%23"));
}

function seteserListItemVideoImageEvents(){			
			$(".eserListItemVideoImage").click(function()
			{	
				var tText= $(this).parents("a:first").attr("href");
				var htmlIndex=tText.indexOf(".html");
				var hashInd=tText.indexOf("#!");
				var vIndex=tText.indexOf("-eser-video-");
				if(vIndex>1){
					var rText="/yyeservideo.php?id=" + tText.substr(vIndex+12,htmlIndex-vIndex-12);	
					getPageWithUrl(rText,1);
					
					LoadVideoBar(  tText.substr(hashInd+2,vIndex- hashInd -7).replace(/-/g,' ') );
					return false;
				}
				return false;
			}	);			
};

var availableEsers ;		
function getEsers(addr){
	addr=encodeBulInURI(addr);
	
	$.get(addr, function(data){
	  data=encodeURI(data)	
	  availableEsers= data.split(";;");
	});
	return availableEsers;
}

var options = {};
var bul;

var avl=[5555,1055,1555];

function setAlfabeEvents(){
		
	  
	  cache = {};
	  $( "#bulEser" ).autocomplete({
			minLength: 3,
			delay:300,
			matchCase:false,
			  //mustMatch:false,
			  //autoFill:false,
			  source: function( request, response ) {
				var term = request.term;
				if ( term in cache ) {
					response( cache[ term ] );
					return;
				}
				
				lastXhr=$.ajax({
					  url: "yyeserbul.php?"+qPar+"&b="+$("#b").val(),
					  dataType: 'json',
					  data: request,
					  global:false,
					  success: function( data, status, xhr ) {
							cache[ term ] = data;
							if ( xhr === lastXhr ) {
								response( data );
							};
							
							
						}
					});

				/*lastXhr = getJJSON( "yyeserbul.php?b="+$("#b").val(), request, function( data, status, xhr ) {
					cache[ term ] = data;
					if ( xhr === lastXhr ) {
						response( data );
					};
					
					
				});
				cannotAnimate=false; */
				return ;
			},
			select: function(event, ui) { 
				 bul="bul="+ ui.item.value.toUpperCase();
				 b= "b="+$("#b").find("option:selected").attr("value");	
				 	getPageWithPar("yyeserlist.php",qPar+ "&" +bul+"&"+b);
					return ;
				
			}

		});  

	  
	  
		$(".alfabe , #araButton").unbind('click');
		$(".alfabe").click(  function()
			{
				
				 aText=$(this).text();
				aText=encodeURI(aText);  
				
				getPageWithPar("yyeserlist.php",qPar+ "&harf=" + aText,1);
				return false;
			}
		);
		$("#araButton").click(  function()
			{
				 bul="bul="+ $("#bulEser").val().toUpperCase();
				 b= "b="+$("#b").find("option:selected").attr("value");					
				/*bul=&q=&b=o&submit.x=10&submit.y=5*/
				getPageWithPar("yyeserlist.php",qPar+ "&" +bul+"&"+b);
				return false;
			}
		);



		/*$("#bulEser").keydown(  function(e)
			{
				 bul="bul="+ $(this).parent().find("#bulEser").attr("value").toUpperCase();
				 b= "b="+$("#b").find("option:selected").attr("value");	
				if (e.keyCode == '13') {
					getPageWithPar("yyeserlist.php",qPar+ "&" +bul+"&"+b);
					return false;
				}
				
				
			}
		);*/
		
	return false;

}	


function setAlbumEvents(){
	$(".albumTable").unbind('click');
	$(".albumTable").click(  function()
			{
				var options = {};
				var tthis=this;
				var aText=$(this).find("a").attr("href");
				var htmlIndex=aText.indexOf(".html");
				var habIndex=aText.indexOf("-yy-album-detay-");
				
				if(habIndex>1){
					rText="yyalbumdetay.php?id=" + aText.substr(habIndex+16,htmlIndex-habIndex-16);
					getPageWithUrl(rText,1);
				}
				document.title=$(this).find("a").text();
				$('meta[name=keywords]').attr('content', document.title);
				
				return false;
			}
		);
			return false;

}

function setBiyoEvents(){
		cache = {};
		$('#biyoAraButton').click(function()
			{
				 options = {};
				 bul="bul="+ $("#bulBiyografi").attr("value").toUpperCase();
				getPageWithPar("yybiyografilist.php", bul + "&" + qPar );
				//getPageWithUrl("yybiyografilist.php?q=b&"+bul);
				return false;
			}
		);
		$(".biyoListItem").live("click",function()
			{				
				var options = {};
				var tthis=this;
				var aText=this.hash;
				if (!aText)
					aText=$(this).find("a").attr("href");
				var rText="";
				rText=aText.replace("#!","");
				seteserListItemVideoImageEvents();

				
				getPageWithUrl(rText,1);
				document.title= "Biyografi:" + $(this).text();
				$('meta[name=keywords]').attr('content', document.title);
				
				return false;
			});
		$( "#bulBiyografi" ).autocomplete({
			minLength: 3,
			delay:300,
			matchCase:false,
			   source: function( request, response ) {
				var term = request.term;
				if ( term in cache ) {
					response( cache[ term ] );
					return;
				}
				
				
				lastXhr=$.ajax({
					  url: "yybiyografibul.php?b="+$("#b").val(),
					  dataType: 'json',
					  data: request,
					  global:false,
					  success: function( data, status, xhr ) {
							cache[ term ] = data;
							if ( xhr === lastXhr ) {
								response( data );
							};
							
							
						}
					});
				
				
				/*lastXhr = $.getJSON( "yybiyografibul.php?b="+$("#b").val(), request, function( data, status, xhr ) {
					cache[ term ] = data;
					if ( xhr === lastXhr ) {
						response( data );
					}
				});*/
				return ;
			},
			select: function(event, ui) { 
				bul="id="+ ui.item.valueid;
				getPageWithPar("yybiyografidetay.php", bul);
				return ;
			
			}

		});  
		return false;
	}
function setHaberEvents(){
		cache = {};
		$("#araHaberButton, #bulHaber, .haberTable, .haberLink,  .haberListItem").unbind('click');
		$("#araHaberButton").click(  function()
			{
				var options = {};
				var bul="bul="+ $(this).parent().parent().find("#bulHaber").attr("value");
				getPageWithPar("yyhaber.php",bul);
				
				return false;
			}
		);
		
	   $( "#bulHaber" ).autocomplete({
			minLength: 3,
			delay:300,
			matchCase:false,
			   source: function( request, response ) {
				var term = request.term;
				if ( term in cache ) {
					response( cache[ term ] );
					return;
				}
				
				lastXhr=$.ajax({
					  url: "yyhaberbul.php?b="+$("#b").val(),
					  dataType: 'json',
					  data: request,
					  global:false,
					  success: function( data, status, xhr ) {
							cache[ term ] = data;
							if ( xhr === lastXhr ) {
								response( data );
							};
							
							
						}
					});

				/*lastXhr = $.getJSON( "yyhaberbul.php?b="+$("#b").val(), request, function( data, status, xhr ) {
					cache[ term ] = data;
					if ( xhr === lastXhr ) {
						response( data );
					}
				});*/
				return ;
			},
			select: function(event, ui) { 
				bul="id="+ ui.item.valueid;
				getPageWithPar("yyhaberdetay.php", bul);
				return;
			
			}

		});  
		/*$("#bulHaber").keydown(  function(e)
			{
			if (e.keyCode == '13') {
				var options = {};
				var bul="bul="+ $(this).parent().parent().find("#bulHaber").attr("value");
				getPageWithPar("yyhaber.php",bul);
				return false;
			}}
		);  */
			
		$(".haberTable").click(  function()
			{
				var options = {};
				var tthis=this;
				var aText=$(this).find("a").attr("href");
				var htmlIndex=aText.indexOf(".html");
				var habIndex=aText.indexOf("-yy-haber-detay-");
				
				if(habIndex>1){
					rText="yyhaberdetay.php?id=" + aText.substr(habIndex+16,htmlIndex-habIndex-16);
					getPageWithUrl(rText,1);
				}
				document.title=  $(this).find("td.anasayfakonubaslik").text();
				$('meta[name=keywords]').attr('content', document.title);
				
				return false;
			}
		);
		$(".haberLink").live("click",  function()
			{
				var options = {};
				var tthis=this;
				var aText=$(this).attr("href");
				getAnyPage(aText);
				return false;
			}	);
		/*$(".haberListItem").click(function()
			{				
				var options = {};
				var tthis=this;
				var aText=$(this).attr("href");
				var htmlIndex=aText.indexOf(".html");
				var habIndex=aText.indexOf("-yy-haber-detay-");
				if(habIndex>1){
					rText="yyhaberdetay.php?id=" + aText.substr(habIndex+16,htmlIndex-habIndex-16);
					getPageWithUrl(rText,1);
				}
				return false;
			});*/
				return false;

		
}
function popUp(URL) {
day = new Date();
id = day.getTime();
mv=window.open(URL, '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=880,height=700,top=0,left=0');
//eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=880,height=900,top=0,left=0');");
}
var errors=0;

function setSoruCevapEvents(){
		$("#formsc").validate(
		  {
			rules: {
			  
				mesaj: { required: true, minlength:6 }
			},
			messages: {
			  
				mesaj: { required: 'Gerekli', minlength: 'Mesaj en az 6 karakterli olmalı' }
			} ,
			submitHandler: function(){
				//var encdd=$("#iletisim").serialize();
				var kime_mail="bilgi@caliyorum.com";
				var ad_soyad = $("input#ad_soyad").val();  
				var email = $("input#email").val();  
				var konu = $("input#konu").val();  
				var mesaj=$("textarea#mesaj").val();  
				var dataString = 'kime_mail='+kime_mail+'&ad_soyad='+ encodeURIComponent(ad_soyad) + '&email=' + email + '&konu=' + encodeURIComponent(konu) +'&mesaj='+encodeURIComponent(mesaj);
				
				if (errors)
					return false;
				$.ajax({
							  url: 'mail_yolla_uye.php',
							  type:'POST',
							  data:dataString,	
							  contentType: "application/x-www-form-urlencoded;charset=iso-8859-9",
							  success: function(html){
								$("#centerTD").html(html);
							  }
							});
				//$.get("yymail_yolla.php",$("#iletisim").serialize(),
				//function(data){
					//$("#centerTD").html(data);
					//});
				return false;
		 
			
			}
		});
		return false;
}

function setIletisimEvents(){

	/*$.validator.setDefaults({
		submitHandler: function() { alert("submitted!"); }
	}); 

	$("#iletisim").submit(*/
	
	$.validator.setDefaults({
		submitHandler: function(){
			//var encdd=$("#iletisim").serialize();
			var kime_mail="bilgi@caliyorum.com";
			var ad_soyad = $("input#ad_soyad").val();  
			var email = $("input#email").val();  
			var konu = $("input#konu").val();  
			var mesaj=$("textarea#mesaj").val();  
			var dataString = 'kime_mail='+kime_mail+'&ad_soyad='+ encodeURIComponent(ad_soyad) + '&email=' + email + '&konu=' + encodeURIComponent(konu) +'&mesaj='+encodeURIComponent(mesaj);
			
			if (errors)
				return false;
			$.ajax({
						  url: 'yymail_yolla.php',
						  type:'POST',
						  data:dataString,	
						  contentType: "application/x-www-form-urlencoded;charset=iso-8859-9",
						  success: function(html){
							$("#centerTD").html(html);
						  }
						});
		//$.get("yymail_yolla.php",$("#iletisim").serialize(),
		//function(data){
			//$("#centerTD").html(data);
			//});
		return false;
 
		
		}
		});
	$("#iletisim").validate(
		  {
		   rules: {
			  ad_soyad: { required: true, minlength:6},
			  email: { required: true, email: true },
			  konu: { required: true, minlength:6 },
			  mesaj: { required: true, minlength:6 }
			},
		  messages: {
			  ad_soyad: { required: 'Gerekli', minlength: 'Adınız ve soyadınız en az 6 karakterli olmalı' },
			  email: { required: 'Gerekli', email: 'Lütfen geçerli bir e-mail adresi giriniz' },
			  konu: { required: 'Gerekli',  minlength: 'Konu en az 6 karakterli olmalı' },
			  mesaj: { required: 'Gerekli', minlength: 'Mesaj en az 6 karakterli olmalı' }
			} 
		/*,
			submitHandler: function(form) {
				$(form).ajaxSubmit();
			   }  */



		});
	return false;
}

function setAbonelik2Events(){
	$.validator.setDefaults({
		submitHandler: function(){
			var uyruk="TC";
			var tckimlik = $("input#tckimlik").val();  
			var ad_soyad = $("input#ad_soyad").val();  
			var email = $("input#email").val();  
			var telefon=$("input#telefon").val();  
			var adres=$("textarea#adres").val();  
			var ulke=$("input#ulke").val();  
			var il=$("input#il").val();  
			var ilce=$("input#ilce").val();
			var postakodu=$("input#postakodu").val();  
			var paket_adi=$("select#paket_adi").val();  
			var sure=$("input#sure").val();  
			var odemesekli=$("select#odemesekli").val();  
			var KT_Insert1="Ekle";
			var uyeid=$("input#uyeid").val();  
			var havale_banka=$("input#havale_banka").val();  
			var dataString = // $("#formae2").serialize();
			'uyruk=' + 	uyruk +
			'&tckimlik=' +tckimlik +
			'&ad_soyad=' +encodeURIComponent(ad_soyad)+
			'&email=' +email+
			'&telefon='+ telefon+
			'&adres=' +adres+
			'&ulke=' +ulke+
			'&il=' +encodeURIComponent(il)+
			'&ilce='+ encodeURIComponent(ilce)+
			'&postakodu=' +postakodu+
			'&paket_adi=' +paket_adi+
			'&sure=' +sure+	
			'&odemesekli='+odemesekli+
			'&havale_banka='+havale_banka;
			
			if (errors)
				return false;
			
			$.ajax({
						  url: 'yyabonelikekle2n.php',
						  type:'POST',
						  data:dataString,	
						  contentType: "application/x-www-form-urlencoded;charset=iso-8859-9",
						  success: function(html){
							$("#centerTD").html(html);
						  }
						});
		return false;
 
		
		}
		});
	
	
	
	
	
	
	$("#formae2").validate(
		  {
		   rules: {
			  ad_soyad: { required: true, minlength:6},
			  email: { required: true, email: true },
			  tckimlik: { required: true, minlength:11},
			  adres: { required: true, minlength:12},
			  ulke:{ required: true, minlength:3 },
			  il:{ required: true, minlength:3 },
			  ilce:{ required: true, minlength:3 },
			  postakodu:{ required: true, minlength:5 }
			  
			  
			},
		  messages: {
			  ad_soyad: { required: 'Gerekli', minlength: 'Lütfen adınızı ve soyadınızı doğru bir şekilde giriniz' },
			  email: { required: 'Gerekli', email: 'Lütfen geçerli bir e-mail adresi giriniz' },
			  tckimlik:{ required: 'Gerekli',  minlength: ' en az 11 karakterli olmalı' },
			  adres: { required: 'Gerekli', minlength:' en az 12 karakterli olmalı' },
			  ulke:{ required: 'Gerekli', minlength:'en az 3 karakterli olmalı' },
			  il:{ required: 'Gerekli', minlength:'en az 3 karakterli olmalı' },
			  ilce:{ required: 'Gerekli', minlength:'en az 3 karakterli olmalı' },
			  postakodu:{ required: 'Gerekli', minlength:'en az 5 karakterli olmalı' }
			  
			  
			} 
		/*,
			submitHandler: function(form) {
				$(form).ajaxSubmit();
			   }  */



		});
	
}

function setKayitEvents(){
	$('#form1').validate(
		  {rules: {
			  ad_soyad: { required: true, minlength:6},
			  email: { required: true, email: true },
			  parola: { required: true, minlength:6, maxlength: 16 },
			  re_parola: { required: true, minlength:6, maxlength: 16, equalTo:"#parola" },
			  dogum_tarihi: { required: true },
			  cinsiyet: { required: true },
			  ulke: { required: true, minlength:3},
			  telefon: { required: true, minlength:10},
			  meslek: { required: 	true, minlength:3 }
			},
		  messages: {
			  ad_soyad: { required: 'Gerekli', minlength: 'Lütfen adınızı ve soyadınızı doğru bir şekilde giriniz' },
			  email: { required: 'Gerekli', email: 'Lütfen geçerli bir e-mail adresi giriniz' },
			  parola: { required: 'Gerekli', minlength: 'Parolanız en az 6 karakterli olmalı', maxlength: 'Parolanız en çok 16 karakterli olmalı' },
			  re_parola: { required: 'Gerekli', minlength: 'Parolanız en az 6 karakterli olmalı', maxlength: 'Parolanız en çok 16 karakterli olmalı', equalTo: 'Girdiğiniz parolalar aynı değil!'  },
			  dogum_tarihi: { required: 'Gerekli'},
			  cinsiyet: { required: 'Gerekli'},
			  ulke: { required: 'Gerekli', minlength: 'Lütfen ülke ismini doğru bir şekilde giriniz' },
			  telefon: { required: 'Gerekli', minlength: 'Geçerli bir telefon numarası giriniz' },
			  meslek: { required: true, minlength: 'Geçerli bir meslek adı giriniz'  }
			},
		  submitHandler: function(){
			var ad_soyad = $("input#ad_soyad").val();  
			var email = $("input#email").val();  
			var parola = $("input#parola").val();  
			var re_parola = $("input#re_parola").val();  
			var dogum_tarihi=$("input#dogum_tarihi").val();
			var telefon=$("input#telefon").val();  
			var ulke=$("input#ulke").val();  
			var il=$("input#il").val();  
			var ilce=$("input#ilce").val();
			var cinsiyet=$("select#cinsiyet").val();  
			var meslek=$("input#meslek").val();
			
			var dataString = 
				'&ad_soyad=' +encodeURIComponent(ad_soyad)+
				'&email=' +email+
				'&parola=' +parola+
				'&re_parola=' +re_parola+
				'&dogum_tarihi='+ dogum_tarihi+
				'&telefon='+ telefon+
				'&ulke=' +encodeURIComponent(ulke)+
				'&il=' +encodeURIComponent(il)+
				'&ilce='+ encodeURIComponent(ilce)+
				'&meslek='+ encodeURIComponent(meslek)+
				'&cinsiyet=' +cinsiyet
				;
			
			if (errors)
				return false;
			
			$.ajax({
						  url: 'yykayit.php',
						  type:'POST',
						  data:dataString,	
						  contentType: "application/x-www-form-urlencoded;charset=iso-8859-9",
						  success: function(html){
							$("#centerTD").load("yykayitok.php");},
						  error:function(html){
							$("#centerTD").html(html);
						  }
						});		
		}

		});
		

	 
	
}

function setKayDuzEvents()
 {
		  $('#form1').validate({
		  rules: {
			  ad_soyad: { required: true, minlength:6},
			  email: { required: true, email: true },
			  parola: { required: true, minlength:6, maxlength: 16 },
			  re_parola: { required: true, minlength:6, maxlength: 16, equalTo:"#parola" },
			  dogum_tarihi: { required: true },
			  cinsiyet: { required: true },
			  telefon: { required: true, minlength:10},
			  meslek: { required: true, minlength:3 }
		  },
		  messages: {
			  ad_soyad: { required: 'Gerekli', minlength: 'Lütfen adınızı ve soyadınızı doğru bir şekilde giriniz' },
			  email: { required: 'Gerekli', email: 'Lütfen geçerli bir e-mail adresi giriniz' },
			  parola: { required: 'Gerekli', minlength: 'Parolanız en az 6 karakterli olmalı', maxlength: 'Parolanız en çok 16 karakterli olmalı' },
			  re_parola: { required: 'Gerekli', minlength: 'Parolanız en az 6 karakterli olmalı', maxlength: 'Parolanız en çok 16 karakterli olmalı', equalTo: 'Girdiğiniz parolalar aynı değil!'  },
			  dogum_tarihi: { required: 'Gerekli'},
			  cinsiyet: { required: 'Gerekli'},
			  telefon: { required: 'Gerekli', minlength: 'Geçerli bir telefon numarası giriniz' },
			  meslek: { required: true, minlength: 'Geçerli bir meslek adı giriniz'  }
		  },
		  submitHandler: function(){
			var ad_soyad = $("input#ad_soyad").val();  
			var telefon=$("input#telefon").val();  
			var ulke=$("input#ulke").val();  
			var il=$("input#il").val();  
			var ilce=$("input#ilce").val();
			var cinsiyet=$("select#cinsiyet").val();  
			var meslek=$("input#meslek").val();
			var dogum_tarihi=$("input#dogum_tarihi").val();
			
			var dataString = 
				'&ad_soyad=' +encodeURIComponent(ad_soyad)+
				'&dogum_tarihi='+ dogum_tarihi+
				'&telefon='+ telefon+
				'&ulke=' +ulke+
				'&il=' +encodeURIComponent(il)+
				'&ilce='+ encodeURIComponent(ilce)+
				'&meslek='+ encodeURIComponent(meslek)+
				'&cinsiyet=' +cinsiyet
				;
			
			if (errors)
				return false;
			
			$.ajax({
						  url: 'yykayitduzenle.php',
						  type:'POST',
						  data:dataString,	
						  contentType: "application/x-www-form-urlencoded;charset=iso-8859-9",
						  success: function(html){
							$("#centerTD").html(html);},
						  error:function(html){
							$("#centerTD").html(html);
						  }
						});		
		  }
		  });
		  $('input:text').setMask();
		  return false;
      };

function getPage(address)
    {
            var newLocation = address;
            xmlHttp=GetXmlHttpObject()
                if (xmlHttp==null)
                {
                     alert ("Browser does not support HTTP Request");
                     return;
                }
                xmlHttp.onreadystatechange=resolveNode ;
                xmlHttp.open("GET",newLocation,false);
                xmlHttp.send(null);
                respData=xmlHttp.responseText;
			return respData;
    };
function resolveNode() 
    { 
        while (!xmlHttp.readyState==4 && !xmlHttp.readyState=="complete");
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {                 
        respData = xmlHttp.responseText; 
        //alert("response is" + respData);
        var strar = respData.split(":");
        } 
    };

function GetXmlHttpObject()
{
    try
     {
     // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
     }
    catch (e)
     {
     //Internet Explorer
     try
      {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
    return xmlHttp;
}
	
	
(function($) {
	$.fn.progressDialog = function() {

	};

	$.fn.progressDialog.showDialog = function(text) {
		text = text || "Loading,Please wait..."
		createElement(text);
		setPosition();
		waterfall.appendTo("body");
		$(window).bind('resize', function() {
			setPosition();
		});
	}

	$.fn.progressDialog.hideDialog = function(text) {
		waterfall.remove();
	}
 
	function createElement(text) { 
		if (!waterfall) {
			waterfall = $(document.createElement("div"));
			waterfall.attr("id", "waterfall");
			waterfall.css( {
				"height" : "100%",
				"width" : "100%",
				"filter" : "alpha(opacity = 50)",
				"-moz-opacity" : "0.5",
				"opacity" : "0.5",
				"background-color" : "#CCCCCC",
				//"position" : "absolute",
				"left" : "0px",
				"top" : "0px"
			});
		}
		if (!loadDiv) {
			loadDiv = document.createElement("div");
		}
		$(loadDiv).appendTo(waterfall);
		
		var content = "<span>"+text+"</span>";
		$(loadDiv).html(content);
	}

	function setPosition() {
		var leftOffset = ($(document).width() - 120) / 2;
		var topOffset = ($(document).height() - 160) / 2;
		$(loadDiv).css( {
			//"position" : "absolute",
			"height" : "60px",
			"width" : "120px",
			"left" : leftOffset + "px",
			"top" : topOffset + "px"
		});
	}

	var waterfall;
	var loadDiv;
})(jQuery);

