function send_babylon(){
	var url = "http://online.babylon.com/combo/index.html?word="+document.getElementById('word').value+"&lang="+document.getElementById('lang')[document.getElementById('lang').selectedIndex].value;
	window.open (url, "translation", "scrollbars=no,status=no,width=256,height=334,top=215,left=33");
}

function check_email(str){
	var chkemail=  /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,3}$/; //v2
	var emailchk=str.match(chkemail);
	if (emailchk == null){
		return false;
	}
		return true;
}
function addsubscribes(){
	sname = document.getElementById('fName').value;
	semail = document.getElementById('fEmail').value;
	saccid = document.getElementById('fAccId').value;
	slid = document.getElementById('fLngId').value;
	var url="extpage.asp?pid=4&sname="+sname+"&semail="+semail+"&saccid="+saccid+"&slid="+slid
	if (sname.length!=0&&semail.length!=0&&check_email(semail)){
		window.open(url,'addsubscribes',' scrollbars=yes,resizeble=yes, width=300,height=200');
		document.getElementById('sButton').disabled = true;
	}
}

function showimage() {
	if($("#preview")!=null){
		$("#preview").attr("src","http://www.meteor.gov.tr/sunum/imgtahmingor-b1-g.aspx?merkez="+ $("#il").val()+"&gun=T&renkC=000&renkT=000&renkZ=fff");
	}
}

function gOpt(val){
	document.getElementById('g1').className = '';
	document.getElementById('g2').className = '';
	document.getElementById('g3').className = '';
	document.getElementById('g'+val).className = 'active';
	if (val=='1'){
		document.gsearchform.sitesearch.value = "";
		document.gsearchform.inlang.value = "tr";
	}
	if (val=='2'){
		document.gsearchform.sitesearch.value = "";
		document.gsearchform.inlang.value = "";
	}
	if (val=='3'){
		document.gsearchform.sitesearch.value = sWebUrl;
	}
}

function CreateBookmarkLink(title,surl) {
	url = "http://www."+surl;
	if (window.sidebar) {
		window.sidebar.addPanel(title,url,"");   
	} else if( window.external ) {
		window.external.AddFavorite(url,title);
	} else if(window.opera && window.print) {
		return true; 
	}
}

var sfHover = function(objID) {
	var sfEls = document.getElementById(objID).getElementsByTagName( "LI" );
	for (var i=0; i<sfEls.length; i++){
		sfEls[i].onmouseover = function(){
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onmouseout = function(){
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
		}
	} 
}

var validateForm = function(){
	iCnt = parseInt($("#cnt").val());
	var sPcs = ""
	var oP = 0
	for (i=1;i<=iCnt;i++){
		if ($("#r_"+i).val()=="1"){
			switch (parseInt($("#t_"+i).val())){
				case 1:
				case 10:
				case 29:
					if ($("#p_"+i).val()==""){
						sPcs += $("#c_"+i).val()+"\n";
						oP++;
						$("#d_"+i).css("border", "1px solid red");
					}else{
						$("#d_"+i).css("border", "0");
					}
					break;			
				case 6:
				case 7:
				case 8:
				case 9:
				case 16:
				case 17:
				case 18:
				case 19:
					if ($("input[name='p_"+i+"']:checked").val()==undefined){
						sPcs += $("#c_"+i).val()+"\n";
						oP++;
						$("#d_"+i).css("border", "1px solid red");
					}else{
						$("#d_"+i).css("border", "0");
					}
				break;
				case 14:
					if (($("#pa_"+i).val()=="")||($("#pb_"+i).val()=="")||(!/^\d+$/.test($("#pa_"+i).val()))||(!/^\d+$/.test($("#pb_"+i).val()))){
						sPcs += $("#c_"+i).val()+"\n";
						oP++;
						$("#d_"+i).css("border", "1px solid red");
					}else{
						$("#d_"+i).css("border", "0");
					}
				break;
				case 15:
					if(!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#p_"+i).val())){
						sPcs += $("#c_"+i).val()+"\n";
						oP++;
						$("#d_"+i).css("border", "1px solid red");
					}else{
						$("#d_"+i).css("border", "0");
					}
				break;
				case 2:
				case 3:
				case 5:
					if(/Invalid|NaN/.test(new Date(parseInt($("#pb_"+i).val())+"/"+(parseInt($("#pa_"+i).val())-1)+"/"+$("#pc_"+i).val()))){
						sPcs += $("#c_"+i).val()+"\n";
						oP++;
						$("#d_"+i).css("border", "1px solid red");
					}else{
						$("#d_"+i).css("border", "0");
					}
				break;
			}
		}
	}
	if (oP!=0){
		alert("Lütfen aşağıdaki alanları doldurunuz.\n\n"+sPcs);
		return false;
	}else{
		return true;
	}
}


var delayb4scroll=2000;
var marqueespeed=1;
var pauseit=1;

var copyspeed=marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
	if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)){
		cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px";
	}else{
		cross_marquee.style.top=parseInt(marqueeheight)+8+"px";
	}
}

jQuery.fn.delay = function(time,func){
	return this.each(function(){
		setTimeout(func,time);
	});
};

function initializemarquee(){
	cross_marquee=document.getElementById("vmarquee");
	cross_marquee.style.top=0;
	marqueeheight=document.getElementById("marqueecontainer").offsetHeight;
	actualheight=cross_marquee.offsetHeight;
	if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
		cross_marquee.style.height=marqueeheight+"px";
		cross_marquee.style.overflow="scroll";
		return
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll);
}


$(document).ready(function(){
	if($(".userform").length!=0){
		$("#uform").submit(function(){return validateForm();});
		$("#navcontainer h2").click(function(){return validateForm();});
	}
	showimage();
	sfHover("navlist");
	if($("#vmarquee p").length!=0){
		initializemarquee();
	}
	if($(".slideShowGallery").length!=0){
		squareGallery();
	}
});


function squareGallery (){
	$(".slideShowGallery dd img").click( function() { 
		var imageUrl =$(this).parent().attr('href');
		showImage(imageUrl);
		return false;
	} );
}

function showImage(url){
	$("#main_image").attr('src',url)
}



function dynamicSelect(id1, id2) {
	if (document.getElementById && document.getElementsByTagName) {
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		var clone = sel2.cloneNode(true);
		var clonedOptions = clone.getElementsByTagName("option");
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
	}
}

function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	while (sel2.options.length) {
		sel2.remove(0);
	}
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	for (var i = 0; i < clonedOptions.length; i++) {
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}
}