﻿function isEmpty(s){
  return ((s == null)||(s.length == 0))
}

function rtrim(text){
  var lastChar=text.substring(text.length-1, text.length);
  while(lastChar==" "){
    text=text.substring(0, text.length-1);
    lastChar=text.substring(text.length-1, text.length);}
  return text;	
}

function checkString(f,fieldname,l){
  var value=f.value;
  var result=!isEmpty(rtrim(value));
  if(!result)alert("Eksik bilgi : "+fieldname+" giriniz.");
  if(result){
    result=(value.length>=l)
    if(!result)alert("Lütfen en az " + l + " karakter giriniz.");}
  if(!result)f.focus();
  return(result);
}

function checkNumeric(f,fieldname,l){
  var result=checkString(f,fieldname,l);
  if(result){
    for(i=0;(i<l)&&result;i++){
      c=parseInt(f.value.substring(i,i+1),10);
      result=result&&(c==c);}
    if(!result)alert("Lütfen "+fieldname+" olarak sayısal bir değer giriniz.");}
    if(!result)f.focus();
  return(result);
}

function test()
{
	alert();
}
function checkEmail(f){
	var x=f.value;
	var result=(x.search(new RegExp("^\\S+@\\S+\\.\\S+$")));
	if(result!=0){
		alert("Lütfen e-mail adresinizi adsoyad@alanadı.com gibi bir formatta giriniz.");
		f.focus();
		return false
	}
	else
	{
		return true;
	}	
}

function PostSurvey(parID,objID,type)
{
    var Goon = false;
    var radiogroup
    var opID = ""; 
	
    //radiogroup = document.aspnetForm(objID);
    radiogroup = document.aspnetForm.elements[objID]

    for(var j = 0 ; j < radiogroup.length ; ++j) {
        if(radiogroup[j].checked) {
            opID = radiogroup[j].value
            Goon = true			      
            break;
        }
    }

    if (type==0) 
    {
        Goon = true;
        opID = "0";           
    }
	
    if (Goon==true)
    {
        //winprops = 'height=330,width=530,top=0,left=0,scrollbars=yes,resizable';
        //lookupwin = window.open("surveydetail.aspx?sDetailId=" + opID + "&surveyid=" + parID, "survey" , winprops);        
        var oWnd = window.radopen(null, "Window1");
        oWnd.SetSize(720, 450);
        oWnd.SetModal(true);
        oWnd.SetUrl("../surveydetail.aspx?sDetailId=" + opID + "&surveyid=" + parID);
    }
    else 
    {
        alert("Lütfen cevap seçimi yapınız.")
    }
}

function ShowDetail(url,radWindow)
{
    var oWnd = window.radopen(null, radWindow);
    oWnd.SetSize(700, 450);
    oWnd.SetModal(true);
    oWnd.SetUrl(url);
}

function googlesearch(keyword)
{
    winprops = '';//'height=330,width=530,top=0,left=0,scrollbars=yes,resizable';
    lookupwin = window.open("http://www.google.com/search?sitesearch=www.koyuncu.com.tr&as_q=" + keyword, "google" , winprops);        
}

function btngooglesearch()
{
    if(window.event.keyCode==13)
    {
        document.aspnetForm.elements["btnGoogleSearch"].focus();
        //document.aspnetForm.btnGoogleSearch.focus();
        window.event.cancel=true;
    }
}