function replaceText(sOrgVal,sSearchVal,sReplaceVal)
{
	var sVal;
	try
	{
		sVal = new String(sOrgVal);
		if (sVal.length < 1) { return sVal; }
		var sRegExp = eval("/\\" + sSearchVal + "/g");
		sVal = sVal.replace(sRegExp,sReplaceVal);
	}
	catch (exception) { }
	return sVal;
}
function $(id)
{
	return document.getElementById(id);
}
function goUrl(url)
{
	window.location.href = url;
}
function popup(url,windowName,width,height,resizable)
{
	if(resizable == '')	
		resizable=0;	
	newwindow=window.open(url,windowName,"width="+width+",height="+height+",resizable="+resizable+",location=no,scrollbars=no");	
	if (window.focus)
		newwindow.focus();	 
}
function replaceText(sOrgVal,sSearchVal,sReplaceVal)
{
	var sVal;
	try
	{
		sVal = new String(sOrgVal);
		if (sVal.length < 1) { return sVal; }
		var sRegExp = eval("/\\" + sSearchVal + "/g");
		sVal = sVal.replace(sRegExp,sReplaceVal);
	}
	catch (exception) { }
	return sVal;
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function nl2br( str ) {
    return str.replace(/([^>])\n/g, '$1<br />\n');
}
L.getElement = function(elemName)
{
	if(document.getElementById(elemName))
		return document.getElementById(elemName);
	else
		return null;
}
L.setPhoto = function(idName,thumbnail)
{
	var obj = document.getElementById(idName).getElementsByTagName('img');
	var len=obj.length;
	var but =0;
	var thumbnailFolder;
	if(thumbnail)
		thumbnailFolder=thumbnail+'/';
	else
		thumbnailFolder='th_1/';
	for(var i=0;i<len;i++)
	{
		if ( obj[i].getAttribute('ptitle') != '')
		{
			obj[i].src=L.define.imgUrl+thumbnailFolder+obj[i].getAttribute('ptitle');
		}
	}
}

L.setDelete=function(formName,id)
{
	if(confirm(confirmMessage))
	{
		var obj = document[formName];
		obj.delete_id.value=id;
		obj.submit();
	}
	else
		return false;
}
function VOID()
{
}
function textLimit(val,max,message)
{
	if(val.value.length > max)
	{
		alert(message);
		val.value = val.value.substring(0,max)
	}
}
function visible(divId)
{
	document.getElementById(divId).style.display='';
}

function showing(the,divId)
{
	var obj = document.getElementById(divId);
	var SpanObj=document.getElementById('span_'+divId);
	var ImgObj=document.getElementById('_'+divId);
	if(obj.style.display=='inline')
	{
		obj.style.display='none';
		the.src=the.src.replace('_on.gif','_off.gif');
		L.cookie.setDelete(divId);
		L.cookie.setCookie(divId,'off',30);

		if (SpanObj!=null && SpanObj!='undefined')
		{
			SpanObj.innerHTML="AÇ";
			ImgObj.title="AÇ";
		}
	}
	else{
		obj.style.display='inline';
		the.src=the.src.replace('_off.gif','_on.gif');
		L.cookie.setDelete(divId);
		L.cookie.setCookie(divId,'on',30);
		
		if (SpanObj!=null && SpanObj!='undefined')
		{
			SpanObj.innerHTML="&nbsp;";		
			ImgObj.title="";
		}
	}
}
function show(divId)
{
	var obj = document.getElementById(divId);
	var ImgObj = document.getElementById('_'+divId);
	var SpanObj=document.getElementById('span_'+divId);
	if(L.cookie.getCookie(divId)=='off'){
		obj.style.display='none';
		ImgObj.src=ImgObj.src.replace('_on.gif','_off.gif');
		
		
		if (SpanObj!=null && SpanObj!='undefined')
		{
			SpanObj.innerHTML="AÇ";
			ImgObj.title="AÇ";
		}
	}
	else{
		obj.style.display='inline';
		ImgObj.src=ImgObj.src.replace('_off.gif','_on.gif');
		
		if (SpanObj!=null && SpanObj!='undefined')
		{
			SpanObj.innerHTML="&nbsp;";
			ImgObj.title="";
		}
	}
}

function streamYoutubeFlash(videoId,backgroundColor,width,height,autoplay,baseurl)
{
	if(autoplay)
		autoplay=1;
	else
		autoplay=0;
	
	var url = 'http://www.youtube.com/v/'+videoId+'&rel=1&autoplay='+autoplay;
	var inner = '<object width="'+width+'" height="'+height+'" style="background-color:'+backgroundColor+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'+
				'<param name="movie" value="'+url+'"></param>'+
				'<param name="wmode" value="transparent"></param>'+
				'<param name="allowScriptAccess" value="always" />'+
  				'<param name="quality" value="high" />'+
  				'<param name="bgcolor" value="'+backgroundColor+'" />' +
				'<embed src="'+url+'" type="application/x-shockwave-flash" wmode="transparent" width="'+width+'" height="'+height+'"></embed>'+
				'</object>';
	return inner;
}


function streamVideoFlash(videoId,backgroundColor,width,height,autoplay,sitename,baseurl)
{
	var inner = '';
	if (sitename=="youtube")
	{
		if(autoplay) 
			autoplay=1;
		else
			autoplay=0;
		
		var url = baseurl+videoId+'&rel=1&autoplay='+autoplay;

		inner = '<object width="'+width+'" height="'+height+'" style="background-color:'+backgroundColor+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'+
				'<param name="movie" value="'+url+'"></param>'+
				'<param name="wmode" value="transparent"></param>'+
				'<param name="allowScriptAccess" value="always" />'+
  			'<param name="quality" value="high" />'+
  			'<param name="bgcolor" value="'+backgroundColor+'" />' +
				'<embed src="'+url+'" type="application/x-shockwave-flash" wmode="transparent" width="'+width+'" height="'+height+'"></embed>'+
				'</object>';
	}
	
	if (sitename=="timsah" || sitename=="izlesene" || sitename=="dailymotion" || sitename=="google" || sitename=="yahoo")
	{
		if(sitename=="dailymotion") 
		{
		  var ids = videoId.split('_');
			var id  = ids[0];
			var url = baseurl+id+'&related=0';
		}
		else if(sitename=="yahoo") 
		{
      var ids = videoId.split('/');
			var vid = ids[0];
			var id  = ids[1];
			var url = baseurl+'&id='+id+'&vid='+vid;
		}
		else if(sitename=="izlesene" || sitename=="timsah") 
		{
		  var ids = videoId.split('/');
			var id  = ids[1];
			var url = baseurl+id;
		}
		else var url = baseurl+videoId;
		
		inner = '<object width="'+width+'" height="'+height+'" style="background-color:'+backgroundColor+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'+
				'<param name="movie" value="'+url+'"></param>'+
				'<param name="wmode" value="transparent"></param>'+
				'<param name="allowScriptAccess" value="always" />'+
  			'<param name="quality" value="high" />'+
  			'<param name="bgcolor" value="'+backgroundColor+'" />' +
				'<embed src="'+url+'" type="application/x-shockwave-flash" wmode="transparent" width="'+width+'" height="'+height+'"></embed>'+
				'</object>';
	}
	
	if (sitename=="piknik")
	{
		
		var url = baseurl+videoId+'&a=1&c=0';
		inner = '<object width="'+width+'" height="'+height+'" style="background-color:'+backgroundColor+'" allowFullScreen="true" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'+
				'<param name="flashvars" value="linktarget=_blank&embedded=1&xmlsrc='+url+'"></param>'+
				'<param name="movie" value="http://www.pikniktube.com/player/videoplayer2.swf" width="'+width+'" height="'+height+'"></param>'+
				'<param name="xmlsrc" value="'+url+'"></param>'+
				'<param name="wmode" value="transparent"></param>'+
  			'<param name="quality" value="high" />'+
  			'<param name="bgcolor" value="'+backgroundColor+'" />' +
				'<embed src="http://www.pikniktube.com/player/videoplayer2.swf" type="application/x-shockwave-flash" allowFullScreen="true" width="'+width+'" height="'+height+'" flashvars ="linktarget=_blank&embedded=1&xmlsrc='+url+'"></embed>'+
				'</object>';
	}
	
	return inner;
}


/*
iframe oluşturur
*/
var IFrameObj;
function createIframe(id,name)
{
	if (!document.createElement)
	{
		return true
	}
	var IFrameDoc;

	if (!IFrameObj && document.createElement) 
	{
		try 
		{
	 		iframeHTML='<div style="display:none;height:0px;width:0px;position:absolute;"><iframe id="'+id+'" name="'+name+'" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;z-index:-1';
			iframeHTML+='height:0px;position:absolute;display:none';
			iframeHTML+='"><\/iframe></div>';
			document.body.insertAdjacentHTML("beforeEnd",iframeHTML);
			IFrameObj=document.getElementById(id)
  			return;
  			/*
  			var tempIFrame=document.createElement('iframe');
  			tempIFrame.id=id;
   			tempIFrame.name=name;
     
	 		tempIFrame.style.border='0px';
			tempIFrame.style.width='400px';
			tempIFrame.style.height='400px';
			IFrameObj = document.body.appendChild(tempIFrame);
			
			if (document.frames)
			{
				IFrameObj = document.frames[id];
			}*/
		} 
		catch(exception) 
		{
			iframeHTML='\<iframe id="'+id+'" name="'+name+'" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;display:inline;';
			iframeHTML+='"><\/iframe>';
			document.body.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById(id);
			IFrameObj.document.location.replace = function(location) 
			{
				this.iframe.src = "";
			}
		}
	}
}
function flushMember(message)
{
	if(confirm(message))
	{
		if(confirm(message))
		{
			document.deleteMember.controle.value=1;
			document.deleteMember.submit();
		}
	}
}
function sendReport(report_user_id,action_id,type_id,content)
{
	var parameters = 'controle=1&report_user_id='+report_user_id+'&action_id='+action_id+'&report_type_id='+type_id+'&content='+content;
	L.AJAX.connection('/ajax/sendMessage.php',parameters,getReport,'POST');	
}
function getReport()
{
	if(http.readyState == 4)
	{
		if (http.responseText)
		{
			
		}
	}
}
function ajaxDelete(the)
{
	if(confirm('İşlemi yapmak istediğinizden emin misiniz?'))
	{
		var param='controle=1&'+the.getAttribute('url');
		L.AJAX.connection('/ajax/setDelete.php',param,function(){if(http.readyState == 4){if (http.responseText=="1"){window.location.reload();}}},'POST');
	}
}
function usernameLeng()
{
	var user = trim(document.mainForm.username.value);
	if(user.length<6)
	{
		alert("Rumuzunuz en az 6 karakter olmalı");
		document.mainForm.username.value=user;
		document.mainForm.username.focus();
		return false;
	}
	return true;
}
L.locationLink=function(id,text)
{
	var arr = text.split(',');
	if(id==1)
		document.write('<a href="/location&location_id='+arr[0]+'">'+arr[1]+'</a> - <a href="/location&location_id='+arr[2]+'">'+arr[3]+'</a>');
	else
		document.write('<a href="/location&birth_location_id='+arr[0]+'">'+arr[1]+'</a> - <a href="/location&birth_location_id='+arr[2]+'">'+arr[3]+'</a>');
}

