
function checkall(str)
{
	if (document.getElementById("checkbutton").value=="Tümünü Seç")
	{
		for (i=1; i < str; i++)
		{
			document.getElementById("checkbox"+i).checked=true;
		}
		document.getElementById("checkbutton").value="Tümünü Kaldır";
	} else
	{
		for (i=1; i < str; i++)
		{
			document.getElementById("checkbox"+i).checked=false;
		}
		document.getElementById("checkbutton").value="Tümünü Seç";
	}
}

function checkallkey(str)
{
	if (document.getElementById("checkbuttonkey").value=="Tümünü Seç")
	{
		for (i=1; i < str; i++)
		{
			document.getElementById("keycheckbox"+i).checked=true;
		}
		document.getElementById("checkbuttonkey").value="Tümünü Kaldır";
	} else
	{
		for (i=1; i < str; i++)
		{
			document.getElementById("keycheckbox"+i).checked=false;
		}
		document.getElementById("checkbuttonkey").value="Tümünü Seç";
	}
}

function checkalt(str)
{
	var say = document.getElementById("parent"+str).value;
	for (i=1; i<=say; i++)
	{
		document.getElementById(str+"_"+i).checked=true;
	}
}

function formgonder(str)
{
	document.getElementById(str).submit();
}

function textKontrol( str )
{
	if ( str == "tarih" )
	{
		var sgun = document.getElementById("sgun").value;
		var say = document.getElementById("say").value;
		var syil = document.getElementById("syil").value;
		var fgun = document.getElementById("fgun").value;
		var fay = document.getElementById("fay").value;
		var fyil = document.getElementById("fyil").value;
		
		if ( sgun == "" || say == "" || syil == "" || fgun == "" || fay == "" || fyil == "" )
		{
			alert ( "Tarih Alanlarını Boş Bırakamazsınız" );
		}
	}
}

function selectop(str)
{
	if (document.getElementById("op").value=="listrating")
	{
		document.getElementById("ratingForm").submit();
	} else if (document.getElementById("op").value=="searchstatuskey")
	{
		document.getElementById("ratingForm").submit();
	} else if (document.getElementById("op").value=="prevkeyword_key")
	{
		var text = "<table border=0 cellpadding=1 cellspacing=1>"
		+"<tr><td align='right'>"
		+"<span style='color: #ff0000'>*</span>Anahtar Kelimeler</td>"
		+"<td align='left'><textarea cols='100' rows='10' name='name'></textarea></td></tr>"
		+"<tr><td align='right'>Dil</td>"
		+"<td align='left'><select name='language'>"
		+"<option value='1'>Turkce</option>"
		+"<option value='2'>English</option>"
		+"<option value='3'>FransÄ±zca</option>"
		+"<option value='4'>Almanca</option>"
		+"</select></td></tr>"
		+"<tr><td align='right'>Rating</td>"
		+"<td align='left'><input name='rating' type='text' value='' /></td></tr>"
		+"<tr><td>&nbsp;</td>"
		+"<td align='left'><input value='Kaydet' type='submit' /></td></tr></table>";
		
		document.getElementById("showKeyForm").innerHTML = text;
	} else if (document.getElementById("op").value=="prevkeyword_label")
	{
		var text = "<table border=0 cellpadding=1 cellspacing=1>"
		+"<tr><td align='right'>"
		+"<span style='color: #ff0000'>*</span>Label Kelimeler</td>"
		+"<td align='left'><textarea cols='100' rows='10' name='name'></textarea></td></tr>"
		+"<tr><td align='right'>Dil</td>"
		+"<td align='left'><select name='language'>"
		+"<option value='1'>Turkce</option>"
		+"<option value='2'>English</option>"
		+"<option value='3'>FransÄ±zca</option>"
		+"<option value='4'>Almanca</option>"
		+"</select></td></tr>"
		+"<tr><td align='right'>Rating</td>"
		+"<td align='left'><input name='rating' type='text' value='' /></td></tr>"
		+"<tr><td>&nbsp;</td>"
		+"<td align='left'><input value='Kaydet' type='submit' /></td></tr></table>";
		
		document.getElementById("showKeyForm").innerHTML = text;
	} else if (document.getElementById("op").value=="delKeys")
	{
		document.getElementById("keyForm").submit();
	} else if (document.getElementById("op").value=="statusKeys")
	{
		document.getElementById("keyForm").submit();
	} else if (document.getElementById("op").value=="add_spnKeys")
	{
		var text = "<table border=0 cellpadding=2 cellspacing=2>"
		+"<tr><td>Baslangic Tarihi: "
		+"<input type='text' name='sgun' id='sgun' size=2> / "
		+"<input type='text' name='say' id='say' size=2> / "
		+"<input type='text' name='syil' id='syil' size=4></td>"
		+"<td>Bitis Tarihi: "
		+"<input type='text' name='fgun' id='fgun' size=2> / "
		+"<input type='text' name='fay' id='fay' size=2> / "
		+"<input type='text' name='fyil' id='fyil' size=4></td>"
		+"<td><input value='Kaydet' type='submit' /></td></tr></table>";
		
		document.getElementById("showKeyForm").innerHTML = text;
	} else if ( document.getElementById("op").value=="del_spnKeys" )
	{
		document.getElementById("keyForm").submit();
	} else
	{
		document.getElementById("showKeyForm").innerHTML = "";
	}
}

function include_temp( str, id, recid )
{
	if ( str == 1 || str == 2 )
	{
		var text = "<form name='miniTempForm' action='index.php' method=post enctype='multipart/form-data'>"
		+"<table style='border:1px solid #666666; text-align:left;' cellpadding=2 cellspacing=2><tr>"
		+"<td>Resim dosyası seçin</td>"
		+"<td><input type=file name='img' /> </td></tr>"
		+"<tr><td>Çözünürlük belirleyin</td>"
		+"<td><select name='img_res'><option value='1'>180 X 270</option><option value='2'>270 X 180</option><option value='3'>180 X 180</option><option value='4'>270 X 270</option></select></td></tr>"
		+"<tr><td>Resim için başlık</td>"
		+"<td><input type='text' name='title' size='50' /></td></tr>"
		+"<tr><td>Resim için açıklama</td>"
		+"<td><textarea name='img_content' cols='65' rows='7'></textarea></td></tr>"
		+"<tr><td colspan=2><input type='submit' value='Kaydet' /></td></tr>"
		+"<tr><td colspan=2><font color='#C30000'>*</font>Resim boyutu en fazla 60 Kb olabilir."
		+"<input type='hidden' name='module' value='SP_Companies' />"
		+"<input type='hidden' name='op' value='addguesttemp'>"
		+"<input type='hidden' name='id' value='"+id+"'>"
		+"<input type='hidden' name='recid' value='"+recid+"'>"
		+"<input type='hidden' name='num' value='"+str+"'></td></tr>"
		+"</table></form>";
		
		document.getElementById("inc_sablon").innerHTML = text;
	} else if ( str == 3 )
	{
		var text = "<form name='miniTempForm' action='index.php' method=post enctype='multipart/form-data'>"
		+"<table style='border:1px solid #666666; text-align:left;' cellpadding=2 cellspacing=2><tr>"
		+"<td>1. Resim dosyasını seçin</td>"
		+"<td><input type=file name='img1' /> </td></tr>"
		+"<tr><td>1. Resim için çözünürlük seçin</td>"
		+"<td><select name='img_res1'><option value='1'>180 X 270</option><option value='2'>270 X 180</option><option value='3'>180 X 180</option><option value='4'>270 X 270</option></select></td></tr>"
		+"<tr><td>1. Resim için başlık</td>"
		+"<td><input type='text' name='title1' size='50' /></td></tr>"
		+"<tr><td>2. Resim dosyasını seçin</td>"
		+"<td><input type=file name='img2' /> </td></tr>"
		+"<tr><td>2. Resim için çözünürlük seçin</td>"
		+"<td><select name='img_res2'><option value='1'>180 X 270</option><option value='2'>270 X 180</option><option value='3'>180 X 180</option><option value='4'>270 X 270</option></select></td></tr>"
		+"<tr><td>2. Resim için başlık</td>"
		+"<td><input type='text' name='title2' size='50' /></td></tr>"
		+"<tr><td colspan=2><input type='submit' value='Kaydet' /></td></tr>"
		+"<tr><td colspan=2><font color='#C30000'>*</font>Bir resmin boyutu en fazla 60 Kb olabilir."
		+"<input type='hidden' name='module' value='SP_Companies' />"
		+"<input type='hidden' name='op' value='addguesttemp'>"
		+"<input type='hidden' name='id' value='"+id+"'>"
		+"<input type='hidden' name='recid' value='"+recid+"'>"
		+"<input type='hidden' name='num' value='"+str+"'></td></tr>"
		+"</table></form>";
		
		document.getElementById("inc_sablon").innerHTML = text;
	} else if ( str == 4 )
	{
		var text = "<form name='miniTempForm' action='index.php' method=post enctype='multipart/form-data'>"
		+"<table style='border:1px solid #666666; text-align:left;' cellpadding=2 cellspacing=2>"
		+"<tr><td>1. Açıklama için başlık</td>"
		+"<td><input type='text' name='title1' size='50' /></td></tr>"
		+"<tr><td>1. Açıklama</td>"
		+"<td><textarea name='content1' cols='65' rows='7'></textarea></td></tr>"
		+"<tr><td>2. Açıklama için başlık</td>"
		+"<td><input type='text' name='title2' size='50' /></td></tr>"
		+"<tr><td>2. Açıklama</td>"
		+"<td><textarea name='content2' cols='65' rows='7'></textarea></td></tr>"
		+"<tr><td colspan=2><input type='submit' value='Kaydet' />"
		+"<input type='hidden' name='module' value='SP_Companies' />"
		+"<input type='hidden' name='op' value='addguesttemp'>"
		+"<input type='hidden' name='id' value='"+id+"'>"
		+"<input type='hidden' name='recid' value='"+recid+"'>"
		+"<input type='hidden' name='num' value='"+str+"'></td></tr>"
		+"</table></form>";
		
		document.getElementById("inc_sablon").innerHTML = text;
	} else if ( str == 5 )
	{
		var text = "<form name='miniTempForm' action='index.php' method=post enctype='multipart/form-data'>"
		+"<table style='border:1px solid #666666; text-align:left;' cellpadding=2 cellspacing=2>"
		+"<tr><td>Açıklama için başlık</td>"
		+"<td><input type='text' name='title' size='50' /></td></tr>"
		+"<tr><td>Açıklama</td>"
		+"<td><textarea name='content' cols='85' rows='10'></textarea></td></tr>"
		+"<tr><td colspan=2><input type='submit' value='Kaydet' />"
		+"<input type='hidden' name='module' value='SP_Companies' />"
		+"<input type='hidden' name='op' value='addguesttemp'>"
		+"<input type='hidden' name='id' value='"+id+"'>"
		+"<input type='hidden' name='recid' value='"+recid+"'>"
		+"<input type='hidden' name='num' value='"+str+"'></td></tr>"
		+"</table></form>";
		
		document.getElementById("inc_sablon").innerHTML = text;
	} else
	{
		document.getElementById("inc_sablon").innerHTML = "";
	}
}

function open_sub_menu( str )
{
	document.getElementById("submenu"+str).style.visibility="visible";
}
function close_sub_menu( str )
{
	document.getElementById("submenu"+str).style.visibility="hidden";
}

function check_delete( form )
{
	var r = confirm( "Silme İşlemini Onaylıyor musunuz?" );
	
	if ( r==true )
	{
		document.getElementById( form ).submit();
	}
}

function check_delete_link( str )
{
	var r = confirm( "Silme İşlemini Onaylıyor musunuz?" );
	
	if ( r==true )
	{
		window.location.href( str );
	}
}

function popup( url )
{
	myWindow=window.open( url,'','width=600,height=800,scrollbars=1');
	myWindow.focus();
}

function close_window( )
{
	var t=setTimeout("window.close()",1500);
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  	http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml; charset=iso-8859-9');
         }
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function update(formid,divid)
{
	if ( document.getElementById("q").value=="" )
	{
		document.getElementById(divid).innerHTML="";
		document.getElementById(divid).style.visibility="hidden";
		document.getElementById(divid).style.border="0px";
		return;
	}
	
	var form    = document.getElementById(formid);
	var http_request = false;
	
	http_request = false;
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml; charset=iso-8859-9');
		}
	} else if (window.ActiveXObject)
	{
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
		}
	}
	
	if (!http_request)
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', "key_search.php", true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Connection", "close");
	http_request.send(createQuery(form));
   

   function alertContents()
   {
      if (http_request.readyState == 4)
	  {
		  document.getElementById(divid).style.visibility="visible";
		  document.getElementById(divid).innerHTML=http_request.responseText;
		  document.getElementById(divid).style.border="1px solid #A5ACB2";
		  document.getElementById(divid).style.backgroundColor="#FFF";
      }
   }
}

function showResultCompanies(formid,divid)
{
	if ( document.getElementById("name").value=="" )
	{
		document.getElementById(divid).innerHTML="";
		document.getElementById(divid).style.visibility="hidden";
		document.getElementById(divid).style.border="0px";
		return;
	}
	
	var form    = document.getElementById(formid);
	var http_request = false;
	
	http_request = false;
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml; charset=iso-8859-9');
		}
	} else if (window.ActiveXObject)
	{
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
		}
	}
	
	if (!http_request)
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', "company_search.php", true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Connection", "close");
	http_request.send(createQuery(form));
   

   function alertContents()
   {
      if (http_request.readyState == 4)
	  {
		  document.getElementById(divid).style.visibility="visible";
		  document.getElementById(divid).innerHTML=http_request.responseText;
		  document.getElementById(divid).style.border="1px solid #A5ACB2";
		  document.getElementById(divid).style.backgroundColor="#FFF";
      }
   }
}

function createQuery(form)
{
    var elements = form.elements;
    var pairs = new Array();

    for (var i = 0; i < elements.length; i++) {

        if ((name = elements[i].name) && (value = elements[i].value))
            pairs.push(name + "=" + encodeURIComponent(value));
    }
    //pairs.push("param1=1");
    return pairs.join("&");
}

function checkbox_control(form,say)
{
	var kontrol = 0;
	for ( i=0; i < say; i++ )
	{
		if ( document.getElementById("checkbox"+i).checked==true )
		{
			kontrol++;
		}
	}
	
	if ( kontrol == 0 )
	{
		alert("En az bir aile grubu seçmelisiniz.");
	} else
	{
		document.getElementById(form).submit();
	}
}

function showLayer( str , sc )
{
	if ( sc == "show" )
	{
		document.getElementById(str).style.visibility = "visible";
	} else
	{
		document.getElementById(str).style.visibility = "hidden";
	}
}

function dateControl( str )
{
	if ( document.getElementById("sday").value=="bos" || document.getElementById("smonth").value=="bos" || document.getElementById("fday").value=="bos" || document.getElementById("fmonth").value=="bos" )
	{
		alert ( "Gün ve Ay Değerlerini Seçiniz" );
	} else
	{
		document.getElementById(str).submit();
	}
}
