
/*
*	Form Submit
*	@param : Object (ref Form)
*	@param : boolean ( true /false)
*/
function formObj_submit(formObj){
 	if( !validateForm(formObj) ){
		alert('Ji kerema xwe re ciyên sor tije bike')
		return false;
	}else{
		formObj.submit();
	}
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" + escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name )
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 )
		return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 )
		end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function Delete_Cookie( name, path, domain )
{
	if ( Get_Cookie( name ) )
		document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function changeTarget(elm)
{
	tmp = elm.getElementsByTagName("a");
	for(i=0; i<tmp.length; i++)
		tmp[i].target = "_blank";
}
function changeSize(elm, _size, class_name)
{
 	document.getElementById(elm).className = class_name + '_' + _size;
 	Set_Cookie('text_size', _size, 30, '', '', '');
}


function hide(id){
	document.getElementById(id).style.display='none';	
}
function show(id){
	document.getElementById(id).style.display='block';	
}
function setClass(id,className){
	document.getElementById(id).className=className;
}


function showSubMenu(parent_id,obj,s,path){
			if(parent_id==0){
				return false;
			}else{
				var grid= document.getElementById('tableGrid');
				
				subDiv= grid.getElementsByTagName('div');
				for(i=0;i<subDiv.length;i++){
					p = subDiv[i].id.split(';');
					if(p[1]==parent_id){
						if(subDiv[i].style.display=='block'){
							subDiv[i].style.display='none';
							
							subDiv2= subDiv[i].getElementsByTagName('div');
							if(subDiv2){
								for(n=0;n<subDiv2.length;n++){
									if(subDiv2[i])
										subDiv2[i].style.display ='none'
								}//end for
							}
							if(s==1){
								obj.src=path+'images/elbow-end-plus.gif'
							}else if(s==0){
								obj.src=path+'images/elbow-end-plus-nl.gif'
							}
						}else{//end if
							subDiv[i].style.display='block';
							if(s==1){
								obj.src=path+'images/elbow-minus.gif'
							}else if(s==0){
								obj.src=path+'images/elbow-end-minus-nl.gif'
							}
							
						}
						
					}
				}
			}
			
		}
 
function showList(f){
	var liste = document.getElementById('liste');
	liste.style.position='absolute';
	liste.style.width=70;
	var  a=liste.getElementsByTagName('li');
	for(i=0;i<a.length;i++){
		//a[i].style.position='absolute';
		if(f)
			a[i].style.display='block';
		else if(a[i].className!='selected')
			a[i].style.display='none';
	}
}


function post(url,data,method ,container,callback){
	
	var ajax_post = new ajax();// YENI BIR AJAX NESNESI OLUTURULDU
	ajax_post.GetData = function(urun_kodu){
 		 ajax_post.InitializeRequest('POST', url);
		 ajax_post.Commit(data);
	} // Stok bilgilerini çek
	ajax_post.OnUninit= function() {
	   displayStaticMessage('<h1>Hata </h1><p>Bar nebû dîsa bike!!</p><p><a href=\'#\' onclick=\'closeMessage();return false\'>Bigre</a>',false)
	}
	ajax_post.OnLoading = function() {
	   displayStaticMessage('<h1><img src="../images/ajax-loader.gif">Bar dibe</h1><p>Lütfen Bekleyiniz</p><p><a href=\'#\' onclick=\'closeMessage();return false\'>Bigre</a>',false)
	
	}
	ajax_post.OnLoaded = function() {
	   displayStaticMessage('<h1><img src="../images/ajax-loader.gif">Bar dibe</h1><p>Lütfen Bekleyiniz</p><p><a href=\'#\' onclick=\'closeMessage();return false\'>Bigre</a>',false)
	
	}
	ajax_post.OnInteractive    = function() {
	   displayStaticMessage('<h1><img src="../images/ajax-loader.gif">Bar dibe</h1><p>Lütfen Bekleyiniz</p><p><a href=\'#\' onclick=\'closeMessage();return false\'>Bigre</a>',false)
 	}
}

var slideshow_ad_max = 7;

$(document).ready(function() {
	if ($('div.slideshow')) {
		startSlider();
	}
	
	if ($('#anonsen')) {
		startAdSlider();
	}
	
	slideshow_ad_max = $('div.anonsen-hide').length;
});

var current_slideshow_image = 0;
var slideshow_max = 8;
var slideshow_interval;

changeImage = function(id) {
	$('div.big-image').hide();
	$('#big-image-' + id).show();
	
	current_slideshow_image = id;
	
	moveMarker(id);
	
	stopSlider();
	//startSlider();
}

stopSlider = function() {
	clearInterval(slideshow_interval);
}

startSlider = function() {
	slideshow_interval = setInterval("changeToNextImage()", 5000);
}

changeToNextImage = function() {
	next_image = (current_slideshow_image * 1) + 1;
	
	if (next_image > (slideshow_max - 1))
		next_image = 0;
		
	$('div.big-image').hide();
	$('#big-image-' + next_image).show();
	
	moveMarker(next_image);
	
	current_slideshow_image = next_image;
}

moveMarker = function(position) {
	if (position > 0) {
		margin = (position * 65) + (position * 3);
	} else {
		margin = 0;
	}
	$('div.line div.marker').css({'margin-left' : margin + 'px' });
}



var current_slideshow_ad_image = 0;
var slideshow_ad_interval;

changeAdImage = function(id) {
	$('#anonsen-' + current_slideshow_ad_image).fadeOut('slow', function() {
		$('#anonsen-' + id).fadeIn('slow');
	});
	
	current_slideshow_ad_image = id;
		
	stopAdSlider();
	startAdSlider();
}

stopAdSlider = function() {
	clearInterval(slideshow_ad_interval);
}

startAdSlider = function() {
	slideshow_ad_interval = setInterval("changeToNextImageAd()", 5000);
}

changeToNextImageAd = function() {
	next_image = (current_slideshow_ad_image * 1) + 1;
	
	if (next_image > (slideshow_ad_max - 1))
		next_image = 0;
	
	//alert(current_slideshow_ad_image + ' ' + next_image);
	
	$('#anonsen-' + current_slideshow_ad_image).fadeOut('slow', function() {
		$('div.anonsen-hide').hide();
		$('#anonsen-' + next_image).fadeIn('slow');
	});

	current_slideshow_ad_image = next_image;
}

changeWc = function(id) {
	$('div.wc').hide();
	$('#wc-' + id).show();	
}
