(function($) {
                
			    $(function() { //on DOM ready
				  
				//s2f window open..
				$("a#btn1").click(function () {
				xpos = findPosX(document.getElementById("topbar")) + 490 +"px";
				if(document.getElementById('login').style.display=="block"){
				    $("#login")
							.animate({width:"0px", height:"0px", marginLeft:"305px",padding:"0"},400)
							.toggle("slow");
							//.toggle("slow");
				    $('#sendresult').hide();   
                    $('#friendmail').val("");
                    $('#email').val("");
                    $('#subject').val("");
                    $('#message').val("");
				} else {
				   $("#login")
                       // .css("left",xpos)
                       // .toggle({"left":xpos},"slow"); 
 					    .css({"left":xpos,"width":"0","height":"0","display":"none","margin-left":"305px","padding":"15px"})
						.animate({width:"330px", height:"260px", marginLeft:"0px"},500); 
				}
                  
                });
                //S2f form post ---------------
                $("a#btnsend").click(function (){ 
                var emailfilter=new RegExp("^([a-z0-9_\.\-])+\@([a-z0-9\-])+\.([a-z]{2,4})(\.([a-z]{2,4}))?$","i");
	             if($('#friendmail').val() == "" || emailfilter.test($('#friendmail').val())==false)   
		            {		             
		                 $('#friendmail').css("border","solid 1px #f00");			            
		            } 
	            else if($('#subject').val() == "" || $('#subject').val().length < 2)   
		            {   
		                $('#subject').css("border","solid 1px #f00");		 
		            }
	            else if($('#email').val() == "" || emailfilter.test($('#email').val())==false)   
		            {   		                
			            $('#email').css("border","solid 1px #f00");		
		            } 
	            else if($('#message').val() == "" || $('#message').val().length < 2)   
		            {  		                
			            $('#message').css("border","solid 1px #f00");		 
		            } 
	            else {
	            	$('#sendresult').show();           	
 	            $('#s2fresult').html('Pending...'); 
	            $.ajax({type: 'POST', url: '/s2f.aspx', cache: false,  data: 's1='+$('#friendmail').val()+'&s2='+$('#subject').val()+'&s3='+$('#email').val()+'&s4='+$('#message').val(),
		             success: function(sonuc) {
			             $('#s2fresult').html(sonuc);
			             }
		             });
	            }
                
                });
                
                //s2f window close..
				$(".kapat").click(function () {
                    $("#login")
							.animate({width:"0px", height:"0px", marginLeft:"305px",padding:"0"},400)
							.toggle("slow");
                    $('#sendresult').hide();   
                    $('#friendmail').val("");
                    $('#email').val("");
                    $('#subject').val("");
                    $('#message').val("");
                  });


                  $("#shareInit").mouseover(function() {
                     xpos = findPosX(document.getElementById("topbar")) +620 + "px";
                       $("#socialLinks").css({display: "block", left: xpos });                   
                    });
                    $("#shareInit").mouseout(function() {
                      $("#socialLinks").css('display', 'none');
                    });
                    $("#socialLinks").mouseover(function() {
                      $("#socialLinks").css("display", "block");
                    });
                    $("#socialLinks").mouseout(function() {
                      $("#socialLinks").css('display', 'none');
                    });

                
			});
		})(jQuery);




		
function chngbg(prm){	
	for(var i = 0; i < 6; i++){
		document.getElementById("linkid"+i).className = "link"+i;
	}
	document.getElementById("linkid"+prm).className = "link"+prm+"ac";
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function tabs(prm){
	var c = new Array();
	var t = new Array();
	c[0]="itemcontent1";c[1]="itemcontent2";c[2]="itemcontent3";
	t[0]="tab1";t[1]="tab2";t[2]="tab3";
	for (var i=0; i<3; i++ ){
		document.getElementById(c[i]).style.display = "none";
		document.getElementById(t[i]).className="";
	}
		document.getElementById(c[prm-1]).style.display = "block";
		document.getElementById(t[prm-1]).className="selected";		
}


function findPosX(obj) {
  var curleft = 0;
  if(obj.offsetParent) {
    while(1) {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
  } else if(obj.x) {
    curleft += obj.x;
  }
  //obj.style.position = "static";
  return curleft;
}

function search(){
    var cx = document.getElementById("cx").value;
    var cof = document.getElementById("cof").value;
    var ie = document.getElementById("ie").value;
    var q = document.getElementById("q").value;
    document.location.href="/search.aspx?q="+q+"&cx="+cx+"&cof="+cof+"&ie="+ie;
}

function pwhomelink(){
  document.getElementById('homelink').className = "pwhome";  
}


function searchkey(e) { 
	var key;    
        if(window.event)
             key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
     
        if(key == 13)
           search();
       	else
             return false;
}
