var bc_count=0;
var bc_collection="";
var isValidBrowser =document.getElementById;

function highlightMenu(obj,on){
		 if(!isValidBrowser){return(false);}
        var color=(on==true)?"#FCF5EB":"#ffffff"
			if(obj){
				if(obj.className.indexOf("selecteditem")<0){
           			 obj.style.backgroundColor=color;
				}
			}
    }
//=============================================================================
// Dogum tarihi hesaplamak için
//=============================================================================

function createWeights(theObj){
  var callerForm=theObj.form;

  if(!gIsNumber(callerForm.PWeight.value,35,180)){
    alert("Lütfen  gebelik öncesi kilonuz için 35 ile  180 arası bir rakam giriniz");
    callerForm.PWeight.focus();
    callerForm.PWeight.select();
    return false;
  }
  if(!gIsNumber(callerForm.CWeight.value,35,180)){
    alert("Lütfen  şimdiki kilonuz için 35 ile  180 arası bir rakam giriniz");
    callerForm.CWeight.focus();
    callerForm.CWeight.select();
    return false;
  }
   
  var pWeight=parseInt( stripLeadingZeros( callerForm.PWeight.value ) );
  var cWeight=parseInt( stripLeadingZeros( callerForm.CWeight.value ) );
  var theWeek=0;

  for(i=0;i<callerForm.Week.options.length;i++){
    if(callerForm.Week.options[i].selected==true){
      theWeek=parseInt(callerForm.Week.options[i].value);
    }
  }

  if(theWeek<8){
	  var lowWeight=0+pWeight;
	  var upWeight=0+pWeight;
	} else if(theWeek>=8 && theWeek <= 15){
      var lowWeight=Math.round(0.453*((-0.002604*Math.pow(theWeek,3))+(0.1517857*Math.pow(theWeek,2))-(1.81994*Math.pow(theWeek,1))+6.4178571) +pWeight);
      var upWeight=Math.round(0.453*((0.0130208*Math.pow(theWeek,3))-(0.379464*Math.pow(theWeek,2))+(4.0550595*Math.pow(theWeek,1))-12.58214) +pWeight);
   } else if(theWeek>=16 && theWeek <= 31){
        var lowWeight=Math.round(0.453*((0.000342*Math.pow(theWeek,3))-(0.041126*Math.pow(theWeek,2))+(2.3628096*Math.pow(theWeek,1))-23.16739) +pWeight);
        var upWeight=Math.round(0.453*((-0.000789*Math.pow(theWeek,3))+(0.0324675*Math.pow(theWeek,2))+(1.1341089*Math.pow(theWeek,1))-14.778114) +pWeight);
   } else if(theWeek>=32){
        var lowWeight=Math.round(0.453*((0.0052083*Math.pow(theWeek,3))-(0.616071*(Math.pow(theWeek,2)))+(24.33631*Math.pow(theWeek,1))-297.05) +pWeight);
        var upWeight=Math.round(0.453*((-4.9*Math.pow(10,-16))*Math.pow(theWeek,3)-(0.040179*Math.pow(theWeek,2))+(3.3303571*Math.pow(theWeek,1))-36.45) +pWeight);
   }

   callerForm.Pound1.value=lowWeight-pWeight;
   callerForm.Pound2.value=upWeight-pWeight;
   callerForm.GWeight.value=cWeight-pWeight;
}


function stripLeadingZeros( number ) {

  // convert to string
  number = "" + number;

  // strip out any leading zeros that might be interpreted as octal
  if ( number.indexOf("0") != -1 ) { //if it includes a 0 test:
    while ( number.indexOf("0") == 0 ) {
      number = number.substring( 1 );
    }
  }

  return number;

}

//=============================================================================

//general purpose function to see if an input value has been entered at all
function isEmpty(inputStr) {
	if (inputStr == "" || inputStr == null) {
		return true;
	}
	return false;
}
//general purpose function to see if a suspected numeric input
//is a positive integer
function isNumber(inputStr) {
	for (var i = 0; i<inputStr.length; i++) {
		var oneChar = inputStr.charAt(i);
		if (oneChar<"0" || oneChar>"9") {
			return false;
		}
	}
	return true;
}
//function to determine if value is in acceptable range for this application
function inRangeDay(inputStr) {
	num = parseInt(inputStr);
	if (num<1 || num>31) {
		return false;
	}
	return true;
}
//function to determine if value is in acceptable range for this application
function inRangeYear(inputStr) {
	num = parseInt(inputStr);
	if (num<1900 || num>3000) {
		return false;
	}
	return true;
}
//Master value validator routine for day
function isValidDay(inputStr) {
	if (isEmpty(inputStr)) {
		alert("Lütfen son adet tarihinizin ilk gününü giriniz.");
		return false;
	} else {
		if (!isNumber(inputStr)) {
			alert("Belirttiginiz gün sayisal bir deger olmalidir");
			return false;
		} else {
			if (!inRangeDay(inputStr)) {
				alert("Lütfen geçerli bir gün belirtiniz.");
				return false;
			}
		}
	}
	return true;
}
//Master value validator routine for year
function isValidYear(inputStr) {
	if (isEmpty(inputStr)) {
		alert("Lütfen son adet tarihinizin yilini giriniz.");
		return false;
	} else {
		if (!isNumber(inputStr)) {
			alert("Belirttiginiz yil sayisal bir deger olmalidir.");
			return false;
		} else {
			if (!inRangeYear(inputStr)) {
				alert("Lütfen geçerli bir yil belirtiniz.");
				return false;
			}
		}
	}
	return true;
}
function makeArray(n) {
	this.length = n;
	for (var i = 1; i<=n; i++) {
		this[i] = null;
	}
	return this;
}
var maxday = new makeArray(12);
maxday[1] = 31;
maxday[2] = 28;
maxday[3] = 31;
maxday[4] = 30;
maxday[5] = 31;
maxday[6] = 30;
maxday[7] = 31;
maxday[8] = 31;
maxday[9] = 30;
maxday[10] = 31;
maxday[11] = 30;
maxday[12] = 31;
var monthname = new makeArray(12);
monthname[1] = "Ocak";
monthname[2] = "Subat";
monthname[3] = "Mart";
monthname[4] = "Nisan";
monthname[5] = "Mayis";
monthname[6] = "Haziran";
monthname[7] = "Temmuz";
monthname[8] = "Agustos";
monthname[9] = "Eylül";
monthname[10] = "Ekim";
monthname[11] = "Kasim";
monthname[12] = "Aralik";
var adddays = new makeArray(7);
adddays[1] = 14;
adddays[2] = 28;
adddays[3] = 70;
adddays[4] = 91;
adddays[5] = 196;
adddays[6] = 189;
adddays[7] = 280;
adddays[8] = 294;
adddays[9] = 266;
//Calculate the date string
function calcNewDate(month, day, year, adddays) {
	newday = eval(day)+adddays;
	newmonth = month+1;
	newyear = eval(year);
	var max;
	for (var i = 0; i<12; i++) {
		if (newmonth == 2 && (newyear%4) == 0) {
			max = 29;
		} else {
			max = maxday[newmonth];
		}
		if (newday>max) {
			newday = newday-max;
			newmonth = newmonth+1;
			if (newmonth>12) {
				newyear = newyear+1;
				newmonth = 1;
			}
		} else {
			break;
		}
	}
	var datestring = monthname[newmonth]+" "+newday+", "+newyear;
	return datestring;
}
//Get the date entered and calculate the rest of the dates
function calc(form) {
	day = form.day.value;
	year = form.year.value;
	monthnum = form.month.selectedIndex;
	if (isValidDay(day)) {
		if (isValidYear(year)) {
			form.conception.value = calcNewDate(monthnum, day, year, adddays[1]);
			form.beginrisk.value = calcNewDate(monthnum, day, year, adddays[2]);
			form.endrisk.value = calcNewDate(monthnum, day, year, adddays[3]);
			form.kirkiki.value = calcNewDate(monthnum, day, year, adddays[8]);
			form.otuzsekiz.value = calcNewDate(monthnum, day, year, adddays[9]);
		}
	}
}



//=============================================================================
// Sub Menü
//=============================================================================


var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('.submenu2{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function SwitchMenu2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv2").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu2") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}


//=============================================================================
// İletişim Form
//=============================================================================

function EMailKontrol(adres) {
	var noktayeri = -1;
	var atyeri = -1;
	
	if (adres == "" || adres.length < 6) { return false;}
	atyeri = adres.indexOf("@",0);

	for ( var i = 0; i < adres.length; ) {
		if (adres.indexOf(".",i) > 0 ) {
			noktayeri = adres.indexOf(".",i);
			i = noktayeri;
		}
		i++;
	}
	if (atyeri < 0 || noktayeri < 0 || noktayeri < atyeri ) { return false;}
	return true;
}

function FormKontrol(frm)
{
	if(FrmIletisim.isim.value=="")
	{
		alert("Lütfen Adınızı ve Soyadınızı giriniz.");
		FrmIletisim.isim.focus();
		return false;
		
	}
	
	if (!EMailKontrol(FrmIletisim.email.value))
	{
		alert("Lütfen e-Posta adresinizi giriniz.");
		FrmIletisim.email.focus();
		return (false); 
		
	}
	
	if(FrmIletisim.mesaj.value=="")
	{
		alert("Lütfen Mesajınızı yazınız.");
		FrmIletisim.mesaj.focus();
		return false;
	}
	return true;
	
}

function FormKontrol_ark(frmb)
{
	
	if (!EMailKontrol(FrmIletisimb.emailb.value))
	{
		alert("Lütfen e-Posta adresi giriniz.");
		FrmIletisimb.emailb.focus();
		return (false); 
	}
	else
	{
		frmb.submit();
		return true;
	}

	
}

//=============================================================================
// Popup
//=============================================================================

function pencereAc(Sayfa, Genislik ,Yukseklik) {
window.open(''+Sayfa+'','','width='+Genislik+',height='+Yukseklik+'')
}

//=============================================================================
// Flash
//=============================================================================

function isFlash(inVersion){
 FlashMode = 0;
 if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
  if (navigator.plugins && navigator.plugins["Shockwave Flash"] && (versionIndex = navigator.plugins["Shockwave Flash"].description.indexOf(".")) != - 1) {
   var versionString = navigator.plugins["Shockwave Flash"].description.substring(versionIndex-1, versionIndex);
   versionIndex = parseInt( versionString );
   if ( versionIndex >= inVersion ) {
     FlashMode = 1;
   }
  }
 }
 else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
    && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0 )) {
  theStr='FlashMode = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+inVersion+'"))) \n';
  document.write('<script language=VBScript\> \n');
  document.write('on error resume next \n');
  document.write(theStr);
  document.write('</script\> \n');
   
 }
 return FlashMode;
}

function insertFlash(i_minVersion, i_path, i_name, i_width, i_height, i_bgcolor, i_fb,i_link,i_fblink, transparent) {
	//alert (navigator.userAgent);
  if (isFlash(i_minVersion)){
  	if(i_link){
   		i_link=escape(i_link);
		var linkarray=i_link.split("/");
		i_link=linkarray.join("%2F");
   		i_path=i_path+i_link;
   }
  document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
  document.write(' codebase="../../../../active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0/default.htm"');
  document.write(' ID="' + i_name + '" width="' + i_width + '" height="' + i_height + '">');
  document.write(' <param name=movie value="' + i_path +'"> ');
  document.write(' <param name=quality value=high> ');
  document.write(' <param name=menu value=false> ');
    document.write(' <param name=scale value=noscale>  ');
  document.write(' <param name=bgcolor value=#' + i_bgcolor + '> ');
  if(transparent)
  document.write(' <param name=wmode value=transparent> ');
  document.write(' <embed src="' + i_path +'"');
  if(transparent)
  document.write(' wmode=transparent ');
  document.write(' name=' + i_name + ' swLiveConnect="true" width="' + i_width + '" height="' + i_height + '"');
  document.write(' quality="high" menu="false" scale="noscale" bgcolor="#' + i_bgcolor + '"');
  document.write(' type="application/x-shockwave-flash" pluginspage="../../../../www.macromedia.com/shockwave/download/download.cgi@P1_Prod_Version=ShockwaveFlash.htm">');
  document.write('</embed>');
  document.write('</object>');
 }else {
 	if(i_fblink){
     document.write('<a href="'+i_fblink+'"><img src="' + i_fb+'" width="'+i_width+'" height="'+i_height+'" border="0"></a>');
	}else{
		document.write('<img src="' + i_fb+'" width="'+i_width+'" height="'+i_height+'" border="0">');
	}
 }
}