
var  intital_top = 0;
jQuery(document).ready(function () {
	jQuery('#kuponiada_box').html('<iframe src="http://www.kuponiada.ro/widget.html?type=dynamic&site=Kudika.ro" width="300" height="250" frameborder="0" scrolling="no" allowtransparency="true" style="border: medium none; overflow: hidden; width: 300px; height: 250px;" ></iframe>');
	jQuery('#fb_share_button').html('<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php?u='+escape(_GPD.PAGE.url)+'&t='+_GPD.PAGE.title+'">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>');
	jQuery('#fb_recom_button').html('<iframe src="http://www.facebook.com/plugins/like.php?href='+escape(_GPD.PAGE.url)+'&amp;layout=standard&amp;show_faces=true&amp;width=300&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:300px; height:80px"></iframe>');
	jQuery('#fb_like_box').html('<iframe src="http://www.facebook.com/plugins/activity.php?site='+escape(_GPD.SITE.url)+'&amp;width=300&amp;height=300&amp;header=true&amp;colorscheme=light&amp;recommendations=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:300px;" allowTransparency="true"></iframe>');
	jQuery('#fb_like_button').html('<iframe src="http://www.facebook.com/plugins/like.php?href='+escape(_GPD.PAGE.url)+'&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=trebuchet+ms&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:21px;" allowTransparency="true"></iframe>');
	
	if ( document.getElementById('recommend_allover') ) {
		p = $('#recommend_allover').position();
		intital_top = p.top + 20;
		intital_top = parseInt(intital_top);
		$(window).scroll(recommend_allover).resize(recommend_allover);				
	}
	
	if (document.getElementById('box_report_overlayer')) {
		jQuery('#box_report_overlayer').fadeIn();
		jQuery(window).scroll(function() { jQuery('#box_report_overlayer').css({top: jQuery(window).scrollTop() + 150, zIndex: 987321 }); });
	}

});

var ie=document.all
var ns6=document.getElementById && !document.all


function recommend_allover(){	
	if (intital_top<=$(window).scrollTop()){
		$('#recommend_allover').css({'position': 'fixed','margin-top':'0px','top':'0px','z-index': 987321,'width':'500px'});			
	}else{
		$('#recommend_allover').css({'position': '','margin-top':'20px'});
	}
}

function showPopUp(){
	document.getElementById('pWinConfg').style.visibility='visible';
}

function hidePopUp(){
	document.getElementById('pWinConfg').style.visibility='hidden';
}

function startPopUp(){
	timerID=setTimeout('showPopUp()',3000);
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
function setCookie( 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 loadornot(){
	if (get_cookie('popunder')=='true'){
		startPopUp();
		setCookie("popunder","false",1,"/","www.kudika.ro");
	}
}
loadornot();
theObjects = document.getElementsByTagName("object"); 
for (var i = 0; i < theObjects.length; i++) { 
	theObjects[i].outerHTML = theObjects[i].outerHTML; 
}
//MAKE ACTIVE AJAX BEGIN
	function callAHAH(url, pageElement, callMessage, errorMessage) {
     document.getElementById(pageElement).innerHTML = callMessage;
     try {
     req = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req = false;
         } 
       } 
     }
     req.onreadystatechange = function() {responseAHAH(pageElement, errorMessage);};
     req.open("GET",url,true);
     req.send(null);
  }

function responseAHAH(pageElement, errorMessage) {
   var output = '';
   if(req.readyState == 4) {
      if(req.status == 200) {
         output = req.responseText;
         document.getElementById(pageElement).innerHTML = output;
         } else {
         document.getElementById(pageElement).innerHTML = errorMessage+"\n"+output;
         }
      }
  }


function makeactive(url1,target) { 
callAHAH(url1, target, '<center><img src="./img/loading.gif" /></center>', 'Error');
} 
//MAKE ACTIVE AJAX END



function report_comment(cid,type) {
	if(jQuery !== undefined) {
		$.ajax({
		   type: 'POST',
		   url:  'http://www.kudika.ro/ajax.php',
		   data: 'act=report_comment&cid=' + cid + '&type=' + type,
		   success: function(result){			
				if(result.success) {
					alert('Comentariul a fost raportat!');
				}
		   },
		   dataType: 'json'
		 });
	}
}

function validate_search(frm) {
	if (frm.keyword) {
		if (frm.keyword.value == '' || frm.keyword.value == 'Introdu textul cautat') {
			frm.keyword.value = 'Introdu textul cautat';
			frm.keyword.focus();
			
			return false;
		}
	}
	
	return true;
}

function flashClickTracker(js_inf) {
	$.post(
		'http://www.kudika.ro/ajax.php',
		{act: 'flashClickTracker', inf: js_inf},
		null,
		'json'
	);
}

function open_picture_window(url) {
	var fWP = window.open(url, 'gf_picture', 'location=1,status=1,scrollbars=1,resize=0,width=980,height=780');
	fWP.focus();
	
	return false;
}

function google_ad_request_done(google_ads) {
	//console.debug(google_ads);
	var s = '';
	var i;
	if (google_ads.length == 0) {
		return;
	}
	if (google_ads[0].type == "flash") {
		s += '<a href=\"' +
		google_info.feedback_url + '\" style="color:#000000"><b>Ads by Google</b></a><br>' + 
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' +
		google_ad.image_width + '" HEIGHT="' +
		google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' +
		google_ad.image_url + '">' +
		'<PARAM NAME="quality" VALUE="high">' +
		'<PARAM NAME="AllowScriptAccess" VALUE="never">' +
		'<EMBED src="' +
		google_ad.image_url + '" WIDTH="' +
		google_ad.image_width + '" HEIGHT="' +
		google_ad.image_height +
		'" TYPE="application/x-shockwave-flash"' +
		' AllowScriptAccess="never" ' +
		' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	} else if (google_ads[0].type == "image") {
		s += '<a href=\"' +
		google_info.feedback_url + '\" style="color:#000000"><b>Ads by Google</b></a><br> <a href="' +
		google_ads[0].url + '" target="_top" title="go to ' +
		google_ads[0].visible_url + '" onmouseout="window.status=\'\'"onmouseover="window.status=\'go to ' +
		google_ads[0].visible_url + '\';return true"><img border="0" src="' +
		google_ads[0].image_url + '"width="' +
		google_ads[0].image_width + '"height="' +
		google_ads[0].image_height + '"></a>';
	} else if (google_ads[0].type == "html") {
		s += google_ads[0].snippet;
	} else {
		if (google_ads.length == 1) {
			var br_html = (ads_shape != 0) ? ' ' : '<br>';
			var rem_br = (rem_br == 0) ? '<br>' : '&nbsp;&nbsp;';
			s += '<a href=\"' + google_info.feedback_url + '\" style="float: left; clear: both; color:#000000;font-size:12px;text-decoration: underline;"><b>Anunşuri Google</b></a><br><ul style="float: left; clear: both;">'
			for(i = 0; i < google_ads.length; ++i) {
				s += '<li style="'+li_style+'"><a style="'+url_title_style+'" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + google_ads[i].visible_url + '\';return true"> <span style="text-decoration:underline"> ' + google_ads[i].line1 + '</span></a>'+rem_br+'<span style="'+text_style+'">' +
				google_ads[i].line2 + br_html +
				google_ads[i].line3 + '<br></span> <span><a style="'+url_link_style+'" href="' +
				google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
				google_ads[i].visible_url + '\';return true">' +
				google_ads[i].visible_url + '</span></a></li>';
			}
			s += '</ul>';
		} else if (google_ads.length > 1) {
			var br_html = (ads_shape != 0) ? ' ' : '<br>';
			var rem_br = (rem_br == 0) ? '<br>' : '&nbsp;&nbsp;';
			s += '<a href=\"' + google_info.feedback_url + '\" style="float: left; clear: both; color:#000000;font-size:12px;text-decoration: underline;"><b>Anunşuri Google</b></a><br><ul style="float: left; clear: both;">'
			for(i = 0; i < google_ads.length; ++i) {
				s += '<li style="'+li_style+'"><a style="'+url_title_style+'" href="' + google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + google_ads[i].visible_url + '\';return true"> <span style="text-decoration:underline"> ' + google_ads[i].line1 + '</span></a>'+rem_br+'<span style="'+text_style+'">' +
				google_ads[i].line2 + br_html +
				google_ads[i].line3 + '<br></span> <span><a style="'+url_link_style+'" href="' +
				google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
				google_ads[i].visible_url + '\';return true">' +
				google_ads[i].visible_url + '</span></a></li>';
			}
			s += '</ul>';
		}
	}
	document.write(s);
	return;
}

function sertare_poza(id){
	if (id = "sertar_300x150"){
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") center no-repeat', 'float': 'left'});
		$('<img src="http://85.9.22.142/httpool.ro/z_httpool_resources/noifetele_btn/bg.png" alt="" style="position: absolute; z-index: -1; top: 0px;" />').appendTo('#sertar_300x150')
		$('#banner').css('background','none');
	}
	if (id = "sertar_300x165"){
		$('#sertar_wrapper').css({'position': 'relative', 'z-index': '1'});
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") center no-repeat', 'float': 'left'});
		$('#'+id).children('img').css({'position' : 'relative', 'z-index' : '-1'})
	}
	if (id = "sertar_300x250"){
		$('#sertar_wrapper').css({'position': 'relative', 'z-index': '1'});
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") center no-repeat', 'float': 'left'});
		$('#'+id).find('a:first').css({'float': 'left'});
		$('#'+id).find('img').css({'position' : 'relative', 'z-index' : '-1'})
	}	
	if (id = "sertar_500x449"){
		//$('#sertar_wrapper').css({'position': 'relative', 'z-index': '1'});
		$('#sertar_wrapper a:first').css({'float': 'left'});
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") top no-repeat', 'float': 'left', 'height': '449px'});
		$('#'+id).find('.box_picture').css({'position' : 'relative', 'z-index' : '-1'})
	}
	if (id = "sertar_500x316"){
		//$('#sertar_wrapper').css({'position': 'relative', 'z-index': '1'});
		$('#'+id).find('a:first').css({'float': 'left'});
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") top no-repeat', 'float': 'left'});
		$('#'+id).find('.box_picture').css({'position' : 'relative', 'z-index' : '-1'})
	}
}

function sertare_text(id){

	if (id == 'sertar_300x176'){
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") center bottom no-repeat', 'float': 'left', 'clear': 'both', 'margin': '20px 0 0 0', 'height': '166px'});
		$('#'+id).children('a').css('position','relative')
	}
	if (id = "sertar_160x343"){
		$('#'+id).children('.sb160_title').css('background','none');
		$('#'+id).css({'position': 'relative', 'background': 'url("../images/common/'+id+'.png") center bottom no-repeat', 'float': 'left', 'clear': 'both', 'width': '160px', 'height': '343px'});
		$('#'+id).children('a').css('position','relative')
	}	
}

$(document).ready(function(){
	/* sertare_poza('sertar_300x150');
	sertare_poza('sertar_300x165');
	sertare_poza('sertar_500x449');
	sertare_poza('sertar_500x316');
	sertare_text('sertar_300x176');
	sertare_text('sertar_160x343'); */
});


