﻿var Country ="";
var City ="";
var Town ="";
var District ="";
var Category = "";
var FromScript = false;
var FromScriptUserChoice = false;
var DestinationElementValue = "";
var functionToCall = "";
var kucuktur = "<";
var buyuktur = ">";
var amp = "&";
String.prototype.trim = function()
{
aaa = this.replace(/^\s+/, '');
return aaa.replace(/\s+$/, '');
};
var elementname = "";
var Seciniz = "";
function openWindow(pageLink) {
popupWin=window.open(pageLink,'remote','width=620,height=600,top=100,left=100,scrollbars=yes')
}
function openWindowWide(pageLink) {
popupWin=window.open(pageLink,'remote','width=720,height=500,top=100,left=100,scrollbars=yes')
}
function openWindowWithWidthAndHeight(pageLink,width,height,positionTop,positionLeft,parUseScrollBar) {
    popupWin=window.open(pageLink,'remote','width='+width+',height='+height+',top='+positionTop+',left='+positionLeft+',scrollbars='+parUseScrollBar)
}

//her sayfada olmak zorunda onload=init();
function init(actionType)
{
    if(actionType=='YaziDetayiPrint' || actionType=='IlanDetayiPrint') //print
    {
        window.print();
        window.close();
    }
}

//alert(Math.random()*5);
function GetComboValues(sourceElement,destinationElement)
{
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if (document.getElementById(destinationElement) == null) 
    { i = -1; }
    
    if(i >= 0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;
        
        CallMethot(destinationElement,cID);
    }    
}
function GetComboValuesWithID(sourceElement,destinationElement)
{
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;
        
        CallMethotWithID(destinationElement,cID);
    }    
}

function GetComboValuesWith1Parameters(sourceElement,param,destinationElement,destinationElementValue)
{
    DestinationElementValue = destinationElementValue;
    var paramArray = new Array();
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;
        
        paramArray[0] = cID;
        paramArray[1] = param;
        
        CallMethotWithParameters(destinationElement,paramArray);
    }    
}

function CallMethotWithParameters(DestinationElement,ParamArray)
{
    if(DestinationElement == "Categories")
    {
        ArapSabunu.GetCategoriesOfLabelWithWriterId(ParamArray,callback_ForCombo);    
    }
}


function ShowHighlight(pointElement)
{
      if(pointElement)
      {
        var con = pointElement;
        //con.style.display = "block";
        $(con).highlightFade('blue');
      }
}
function SetLoginAction(parValue)
{
    if(document.getElementById('LoginAction'))
        document.getElementById('LoginAction').value = parValue;
}
function UyeGirisi()
{
    if(document.getElementById('txtEmailLogin'))
	ShowHighlight(document.getElementById('txtEmailLogin'));
	if(document.getElementById('txtPass1Login'))
	ShowHighlight(document.getElementById('txtPass1Login'));
}
function ShowHighlightWhite(pointElement)
{
      if(pointElement)
      {
        var con = pointElement;
        con.style.display = "block";      
        $(con).highlightFade('white');
      }
}

function ChangeImg(src,width,height,elementName)
{
    elementHolder = document.getElementById(elementName);
    if(elementHolder == null)
        return
    elementHolder.innerHTML = '<img src=\''+src+'\' width=\''+width+'\' height=\''+height+'\' />';
}

function ChangeVideo(video,image,width,height,elementName)
{
    elementHolder = document.getElementById(elementName); 
    if(elementHolder == null)
        return
    elementHolder.innerHTML = '<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\' width=\''+width+ '\' height=\''+height+'\'> <param name=\'movie\' value=\'http://video.milliyet.com.tr/Service/Video/Test.swf?clickTag='+video+'&amp;Resim='+image+'\'/><param name=\'wmode\' value=\'transparent\'/><param name=\'quality\' value=\'high\'/><embed src=\'http://video.milliyet.com.tr/Service/Video/Test.swf?clickTag='+video+'&amp;Resim='+image+'\' type=\'application/x-shockwave-flash\' height=\''+height+'\'></embed></object>';
}

function FormatNum(thisis,dig) {	
	var tempstr,newstr,str;
	var commapos,aftercomma;
	str = thisis.value;
	str = StrToMoney(str);	
	var mantissa = new String();	
	var tmp = new String();
	tmp = str;			
	if (tmp.indexOf(",",0)>0) {
		str = tmp.substring(0,tmp.indexOf(",",0))
		mantissa = tmp.substring(tmp.indexOf(",",0),tmp.length)
	}

	var output
	commapos=str.indexOf(";");
	if (commapos>=0) {
		aftercomma=str.substr(commapos);
		str=str.substr(0,commapos);
	}
	else aftercomma="";
	if (mantissa.length>dig)
	{
	    mantissa=mantissa.substring(0,dig+1);
	}
	if (str.length > 3) {
		tempstr=str;
		newstr="";
		while (tempstr.length>3)
		{
			newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
			tempstr=tempstr.substr(0,tempstr.length-3);
		}		
		output = tempstr+newstr+aftercomma;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	else
	{
		str		= str.replace('.','');
		output	= str;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	return true;
}
function StrToMoney(currency) {	
	var num = new String();
	num = currency;
	while (num.indexOf('.',0)>0) {
		num = num.replace('.','');
	}
	return num;
}
function ChangeImgWidthOutWidth(img,Link,ElementName)
{
    holder = kucuktur+'img border=\'0\' src=\''+img+'\' '+buyuktur;
    if(Link != '')
    {
	    linkStart = '<xsl:text disable-output-escaping="yes">&lt;</xsl:text>a href="'+Link+'"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>';
	    linkEnd = '<xsl:text disable-output-escaping="yes">&lt;</xsl:text>/a<xsl:text disable-output-escaping="yes">&gt;</xsl:text>';
	}
	else
	{
	    linkStart = '';
	    linkEnd = '';
	}
	document.getElementById(ElementName).innerHTML = linkStart+holder+linkEnd;
}
function GetComboValuesWithTarget(sourceElement,destinationElement,destinationElementValue)
{
    DestinationElementValue = destinationElementValue
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenSelected(document.getElementById(destinationElement))
        document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        elementname = destinationElement;
        
        CallMethot(destinationElement,cID);
    }    
}
function SubmitPageGlobal(formObject,action)
{
    formObject.action = action;
	formObject.submit();
	return; 
}
function ConfirmAndSubmit(formObject,message,action)
{
	if(confirm(message))
	{
		formObject.action = action;
		formObject.submit();
		return;
	}
}
function GetInnerHtmlOfDiv(sourceElement,destinationElement)
{
    
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenDiv(document.getElementById(destinationElement));
        
        //document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        
        elementname = destinationElement;
       
        CallMethot(destinationElement,cID);
        
    }    
}
function GetInnerHtmlOfDivWithID(sourceElement,destinationElement)
{
    
    var i = -1;
    if(sourceElement != '')
    {
        i = document.getElementById(sourceElement).selectedIndex;
    }
    else
    {
        i = 1;
    }
    if(i >=0)
    {
        var cID = "";
        if(sourceElement != '')
        {
            cID = document.getElementById(sourceElement).options[i].value;
        }
        clearGivenDiv(document.getElementById(destinationElement));
        
        //document.getElementById(destinationElement).options[0]= new Option("Yükleniyor...","");
        
        elementname = destinationElement;
       
        CallMethotWithID(destinationElement,cID);
        
    }    
}
function isEnterKeyPressed()
{
    if(event.which || event.keyCode)
	{
		if ((event.which == 13) || (event.keyCode == 13))
		{
            return true;			
		}
	}
	return false;
}
function CallMethot(DestinationElement,ID)
{
    if(DestinationElement == "City")
    {
        ArapSabunu.GetCitiesByCountryID(ID,callback_ForCombo);
        
        clearGivenSelectedNew(document.getElementById('Town'));
        clearGivenSelectedNew(document.getElementById('District'));
        
    }
    else if(DestinationElement == "Town")
    {
        ArapSabunu.GetTownByCityID(ID,callback_ForCombo);
        clearGivenSelectedNew(document.getElementById('District'));
    }
    else if(DestinationElement == "District")
    {
        ArapSabunu.GetTownByParentTownID(ID,callback_ForCombo);
    }
     else if(DestinationElement == "Categories")
    {
        if(document.getElementById('Properties'))
            document.getElementById('Properties').innerHTML = '';
        ArapSabunu.GetCategoriesOfLabel(ID,callback_ForCombo);
    }
    else if(DestinationElement == "Properties")
    {
        //ArapSabunu.GetPropertiesOfCategory(ID,callback_ForDiv); 
        ArapSabunu.GetPropertiesOfCategory_New(ID,callback_ForDiv); 
    }
}
function CallMethotWithID(DestinationElement,ID)
{
    if(DestinationElement == "City")
    {
        ArapSabunu.GetCitiesByCountryID(ID,callback_ForComboWithID);
        
        clearGivenSelectedNew(document.getElementById('Town'));
        clearGivenSelectedNew(document.getElementById('District'));
        
    }
    else if(DestinationElement == "Town")
    {
        ArapSabunu.GetTownByCityID(ID,callback_ForComboWithID);
        clearGivenSelectedNew(document.getElementById('District'));
    }
    else if(DestinationElement == "District")
    {
        ArapSabunu.GetTownByParentTownID(ID,callback_ForComboWithID);
    }
     else if(DestinationElement == "Categories")
    {
        if(document.getElementById('Properties'))
            document.getElementById('Properties').innerHTML = '';
        ArapSabunu.GetCategoriesOfLabel(ID,callback_ForComboWithID);
    }
    else if(DestinationElement == "Properties")
    {
        ArapSabunu.GetPropertiesOfCategoryWithID(ID,callback_ForDiv);
    }
}
function ScriptElementParser(strScript,elementNameStart,elementNameFinish,arr,index)
{
    var Elements = arr;
    if(arr == null)
      Elements = new Array();  
    var startIndex = strScript.indexOf(elementNameStart);
    if(startIndex != -1)
    {
        finishIndex = strScript.indexOf(elementNameFinish);
        var evalJs = strScript.substring(startIndex+elementNameStart.length,finishIndex);
        Elements[index] = evalJs;
        index++;
        strScript=strScript.replace(elementNameStart,"");
        strScript = strScript.replace(elementNameFinish,"");
        return ScriptElementParser(strScript,elementNameStart,elementNameFinish,Elements,index);
    }
    return Elements;
    
}
function ClearObjects(objectNamesArray)
{
    for(k = 0; k<objectNamesArray.length;k++)
    {
        if(document.getElementById(objectNamesArray[k]))
            document.getElementById(objectNamesArray[k]).value = '';
    }
}
function callback_ForDiv(response)
{
       element = elementname;
       clearGivenDiv(document.getElementById(element));
       
       if(response.value== "false")
            return;
       else
       {
           var str = response.value;
           emts = ScriptElementParser(str,'<script>','</script>',null,0);
           var strA = '';
            for(var js=0;js<emts.length;js++)
            {
            //Hash tabledaki datalara gerek duyulduğu için bunlar tekrardan eval edilmesi gerekiyor.
            if(emts[js].indexOf(".put(") != -1)
            strA += emts[js];
            }
          
            if(document.getElementById(element))
            {  
                eval(strA);
                document.getElementById(element).innerHTML = str;
            }
       }
       if(FromScriptUserChoice)
       {
            if(element == 'Properties')
            {
                Category = "";
                //FromScript = false;
                //FillUserChoise();
                
                FillLabels();
                FillChBx();
                
                //FillContact();
                FromScriptUserChoice = false;
            }
       }
}
function callback_ForCombo(response)
{
       element = elementname;
       
       clearGivenSelected(document.getElementById(element));
       
       if(response.value== "false")
       {
            document.getElementById(element).options[0] = new Option('Seçiniz','');
            return;
       }
       else
       {
       
           var str = response.value;
           var Arr = new Array();
           Arr = str.split(",@#");
           var index =0 ;
           document.getElementById(element).options[index] = new Option(Seciniz,'');
           index++;
           var HasValue = false;
           for(var i=0;i<Arr.length;i+=2)
           {
                if(Arr[i] != "undefined" && Arr[i+1] != "undefined" && Arr[i] != null && Arr[i+1] != null)
                {
                    document.getElementById(element).options[index] = new Option(Arr[i+1],Arr[i]);
                    index++;
                    if(Arr[i] == DestinationElementValue)
                        HasValue = true;
                }
                else
                {
                    break;
                }
           }
           
           if(DestinationElementValue != "" && HasValue == true)
           {
               document.getElementById(element).value = DestinationElementValue;
               DestinationElementValue = "";
           }
          
           if(FromScript == true)
           {
           
                if(element == 'City')
                {
                
                    document.getElementById(element).value = City;
                    if(City != '')
                        GetComboValues('City','Town');
                        else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'Town')
                {
                    if(Town != '' && Town != '-1')
                        document.getElementById(element).value = Town;
                    if(Town != '')
                    GetComboValues('Town','District');
                    else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'District')
                {
                    if(District != '' && District != '-1')
                        document.getElementById(element).value = District;
                    Country = "";
                    City = "";
                    Town = "";
                    District = "";
                    FromScript = false;
                    if(functionToCall != '')
                    {
                        setTimeout(functionToCall, 0);
                        functionToCall = "";
                    }
                }
                
           }
           if(FromScriptUserChoice)
           {
                if(element == 'Categories')
                {
                    document.getElementById(element).value = Category;
                    if(Category != '')
                        GetInnerHtmlOfDiv('Categories','Properties');
                }
           }
           //document.getElementById(element).selectedIndex = _index;
       }
}
function callback_ForComboWithID(response)
{
       element = elementname;
       
       clearGivenSelected(document.getElementById(element));
       
       if(response.value== "false")
       {
            document.getElementById(element).options[0] = new Option('Seçiniz','');
            return;
       }
       else
       {
       
           var str = response.value;
           var Arr = new Array();
           Arr = str.split(",@#");
           var index =0 ;
           document.getElementById(element).options[index] = new Option(Seciniz,'');
           index++;
           var HasValue = false;
           for(var i=0;i<Arr.length;i+=2)
           {
                if(Arr[i] != "undefined" && Arr[i+1] != "undefined" && Arr[i] != null && Arr[i+1] != null)
                {
                    document.getElementById(element).options[index] = new Option(Arr[i]+' - '+Arr[i+1],Arr[i]);
                    index++;
                    if(Arr[i] == DestinationElementValue)
                        HasValue = true;
                }
                else
                {
                    break;
                }
           }
           
           if(DestinationElementValue != "" && HasValue == true)
           {
               document.getElementById(element).value = DestinationElementValue;
               DestinationElementValue = "";
           }
          
           if(FromScript == true)
           {
           
                if(element == 'City')
                {
                
                    document.getElementById(element).value = City;
                    if(City != '')
                        GetComboValues('City','Town');
                        else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'Town')
                {
                    if(Town != '' && Town != '-1')
                        document.getElementById(element).value = Town;
                    if(Town != '')
                    GetComboValues('Town','District');
                    else if(functionToCall != '')
                        {
                            setTimeout(functionToCall, 0);
                            functionToCall = "";
                        }
                }
                else if(element == 'District')
                {
                    if(District != '' && District != '-1')
                        document.getElementById(element).value = District;
                    Country = "";
                    City = "";
                    Town = "";
                    District = "";
                    FromScript = false;
                    if(functionToCall != '')
                    {
                        setTimeout(functionToCall, 0);
                        functionToCall = "";
                    }
                }
                
           }
           if(FromScriptUserChoice)
           {
                if(element == 'Categories')
                {
                    document.getElementById(element).value = Category;
                    if(Category != '')
                        GetInnerHtmlOfDiv('Categories','Properties');
                }
           }
           //document.getElementById(element).selectedIndex = _index;
       }
}

function isValidEmail(Component)
{
	var filter = new RegExp("^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$", "i")
				
	if (filter.test(Component.value))
		return true
	else
		return false
}
function clearGivenSelectedNew(sel)
{
    if(sel != null)
    {
        while(sel.options.length)
            sel.remove(0);
        sel.options[0] = new Option(Seciniz,'');
    }
}
function clearGivenDiv(sel)
{
    if(sel)
        sel.innerHTML = "";
}
function IsNumericAllowNull(Component)   
{

    strString = Component.value;
    if(strString.trim() == "")
        return true;
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}
function IsNumericAllowNotNull(Component)   
{

    strString = Component.value;
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
        
            blnResult = false;
        }
    }
    return blnResult;
}
function IsNumericAllowNotNullAllowNegative(Component)   
{

    strString = Component.value;
    var strValidChars = "0123456789-,";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;


    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
        
            blnResult = false;
        }
    }
    return blnResult;
}
function ThisIsMoneyField(Component)
{
    temp = Component.value.trim();
    temp = temp.replace(".","");
    Component.value = Replace(temp);
}
function Replace(data)
{
     var newstring = "";
     var strValidChars = "0123456789,";
     var commoExist = false;
     for (i = 0; i < data.length; i++)
     {
        strChar = data.charAt(i);
        if (strValidChars.indexOf(strChar) != -1)
        {
            if(strChar != ',' || !commoExist)
            {
                if(i != 0 || strChar != ',')
                {
                    newstring += strChar;
                    if(strChar == ',')
                commoExist = true;
                 }   
            }
            
        }
     }

    return newstring;
}
function IsMoneyAllowNotNull(Component)   
{
    strString = Component.value;
    var strValidChars = "0123456789.,";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}
function IsMoneyAllowNull(Component)   
{
    strString = Component.value;
    var strValidChars = "0123456789.,";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return true;

    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}
function IsEmpty(strString)
{
    if(strString.trim() == "")
        return true;
    else
        return false;
}
function isComponentHasValue(Component)
{
    var v = Component.value.trim();
    if(v == "")
    {
      ShowHighlight(Component);
      return false;
    }
    return true;
}
function ShowHideDiv(ElementID)
{
    if(document.getElementById(ElementID))
    {
        if(document.getElementById(ElementID).style.display == 'none')
            document.getElementById(ElementID).style.display = 'block';
        else
            document.getElementById(ElementID).style.display = 'none';
    }
}
function GetIndexOfOptionByValue(Component,Value)
{
    if(Component != null)
    {
        
        for(i = 0; i < Component.options.length;i++ )
        {
            if(Component.options[i].value == Value)
                return i;
        }
    
    }
    return 0;
}

/**

Contructor(s):
 Hashtable()
          Creates a new, empty hashtable

Method(s):
 void clear() 
          Clears this hashtable so that it contains no keys. 
 boolean containsKey(String key) 
          Tests if the specified object is a key in this hashtable. 
 boolean containsValue(Object value) 
          Returns true if this Hashtable maps one or more keys to this value. 
 Object get(String key) 
          Returns the value to which the specified key is mapped in this hashtable. 
 boolean isEmpty() 
          Tests if this hashtable maps no keys to values. 
 Array keys() 
          Returns an array of the keys in this hashtable. 
 void put(String key, Object value) 
          Maps the specified key to the specified value in this hashtable. A NullPointerException is thrown is the key or value is null.
 Object remove(String key) 
          Removes the key (and its corresponding value) from this hashtable. Returns the value of the key that was removed
 int size() 
          Returns the number of keys in this hashtable. 
 String toString() 
          Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space). 
 Array values() 
          Returns a array view of the values contained in this Hashtable. 
 Array entrySet()
          Returns a reference to the internal array that stores the data. The Set is backed by the Hashtable, so changes to the Hashtable are reflected in the Set, and vice-versa.
        
*/
function Hashtable(){
this.hashtable = new Array();
}

/* privileged functions */

Hashtable.prototype.clear = function(){
this.hashtable = new Array();
}              
Hashtable.prototype.containsKey = function(key){
var exists = false;
for (var i in this.hashtable) {
    if (i == key && this.hashtable[i] != null) {
        exists = true;
        break;
    }       
}
return exists;
}
Hashtable.prototype.containsValue = function(value){
var contains = false;
if (value != null) {
    for (var i in this.hashtable) {
        if (this.hashtable[i] == value) {
            contains = true;
            break;
        }
    }
}        
return contains;
}
Hashtable.prototype.get = function(key){ 

return this.hashtable[key];
}
Hashtable.prototype.isEmpty = function(){
return (parseInt(this.size()) == 0) ? true : false;
}
Hashtable.prototype.keys = function(){
var keys = new Array();
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        keys.push(i);
}
return keys;
}
Hashtable.prototype.put = function(key, value){
if (key == null || value == null) {
    throw "NullPointerException {" + key + "},{" + value + "}";
}else{
    this.hashtable[key] = value;
}
}
Hashtable.prototype.remove = function(key){
var rtn = this.hashtable[key];
this.hashtable[key] = null;
return rtn;
}    
Hashtable.prototype.size = function(){
var size = 0;
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        size ++;
}
return size;
}
Hashtable.prototype.toString = function(){
var result = "";
for (var i in this.hashtable)
{     
    if (this.hashtable[i] != null)
        result += "{" + i + "},{" + this.hashtable[i] + "}\n";  
}
return result;
}                                  
Hashtable.prototype.values = function(){
var values = new Array();
for (var i in this.hashtable) {
    if (this.hashtable[i] != null)
        values.push(this.hashtable[i]);
}
return values;
}                                  
Hashtable.prototype.entrySet = function(){
return this.hashtable;
}

//----------------------------------------------------------------------------------------------------------------------------------------------
function GetKeysWhereClause(ht,value)
{
    var _keys = ht.keys();
    var result = new Array();
    var cnt = 0;
    for(i=0;i<_keys.length;i++)
    {
        if(_keys[i] != "clear" && _keys[i] != "addRange")
        {
            var v = ht.get(_keys[i]);
            
            if( v == value)
            {
                result[cnt] = _keys[i];
                cnt++;
            }
        }
    }
    return result;
}
function FillCombo(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables,destinationSelectedValue)
{
    
    var val = document.getElementById(sourceidfull+sourceid).value;
    
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option(globallables.get('Seciniz'),'');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
        if(destinationSelectedValue != null)
             destination.value = destinationSelectedValue;
    }
    
}
function FillComboWithID(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables,destinationSelectedValue)
{
    
    var val = document.getElementById(sourceidfull+sourceid).value;
    
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option(globallables.get('Seciniz'),'');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(parsedArray[i]+' - '+optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
        if(destinationSelectedValue != null)
             destination.value = destinationSelectedValue;
    }
    
}
function FillListBox(sourceidfull,sourceid,optionvalues,optionparentoptions,optionpropertyids,propertyparentpropertyids,propertydefaultvalues,globallables)
{
    var val = document.getElementById(sourceidfull+sourceid).value;
    if(val == "")
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
        return;
    }
    
    var parsedArray = GetKeysWhereClause(optionparentoptions,val);
    
    var destinationID = GetKeysWhereClause(propertyparentpropertyids,sourceid);
    if(destinationID.length ==1)
    {
        SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues);
    
        var destination = document.getElementById(sourceidfull+destinationID[0]);
        clearGivenSelected(destination);
        destination.options[0] = new Option('','');
        for(i=0;i<parsedArray.length;i++)
        {
            destination.options[i+1] = new Option(optionvalues.get(parsedArray[i]),parsedArray[i]);

        }
    }
}
function clearGivenSelected(sel,text)
{
        while(sel.options.length)
            sel.remove(0);
        sel.options[0] = new Option(text,'');
}
function SetDefaultToChildren(sourceidfull,sourceid,propertyparentpropertyids,propertydefaultvalues)
{
        var ClearArray;
        ClearArray = GetKeysWhereClause(propertyparentpropertyids,sourceid);
        var PropertyIDHolder = "";
        while(ClearArray.length > 0)
        {
            destcombo = document.getElementById(sourceidfull+ClearArray[0]);
            
            if(destcombo != null)
            {
                clearGivenSelected(destcombo,propertydefaultvalues.get(ClearArray[0]));
                destcombo = null;
                PropertyIDHolder = ClearArray[0];
            }
            ClearArray = GetKeysWhereClause(propertyparentpropertyids,PropertyIDHolder);
        }
}
function StartsWith(sText,TextSearch)
{
    
    if(sText.trim() == "")
        return false;
    if(TextSearch.trim() == "")
        return false;
    var temp = "";
    for(i = 0;i<TextSearch.length;i++)
    {
        if(sText.indexOf(TextSearch.charAt(i)) != -1)
        {
            temp += sText.charAt(i);
        }        
    }
    if(temp == TextSearch)
    {
    return true;
    }
    return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------
function OpenEmlakSiteOnNewWindow(emlakAdvertID)
{
    if (emlakAdvertID != '')
    {
        popupWin=window.open('http://emlak.milliyet.com.tr/Default.aspx?aType=IlanDetay&IlanID='+emlakAdvertID);
        
        var advertPar = 'EmlakAdvertID='+emlakAdvertID;
        var currentUrl = window.location.href;
        currentUrl = currentUrl.replace(advertPar,'');
        
        if (currentUrl.lastIndexOf('?') == currentUrl.length-1)
        {
            currentUrl = currentUrl.replace('?','');
        }
        
        window.location.replace(currentUrl);
    }
}
//----------------------------------------------------------------------------------------------------------------------------------------
function MM_showHideLayers(){
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	//for (i=0; i<xsl:text disable-output-escaping="yes">&lt;</xsl:text>(args.length-2); i+=3){
	for (i=0; i<(args.length-2); i+=3){
	with (document){
	//if (getElementById<xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text>((obj=getElementById(args[i]))!=null)){
	if (getElementById && ((obj=getElementById(args[i]))!=null)){
	v=args[i+2];
	if (obj.style){
	obj=obj.style;
	v=(v=='show')?'visible':(v=='hide')?'hidden':v;
	}
	obj.visibility = v;
	}
	}
	}
}

function MM_showHideLayers2(){
	var i,p,v,obj,args=MM_showHideLayers2.arguments;
	//for (i=0; i<xsl:text disable-output-escaping="yes">&lt;</xsl:text>(args.length-2); i+=3){
	for (i=0; i<(args.length-2); i+=3){
	with (document){
	//if (getElementById<xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text>((obj=getElementById(args[i]))!=null)){
	if (getElementById && ((obj=getElementById(args[i]))!=null)){
	v=args[i+2];
	if (obj.style){
	obj=obj.style;
	//v=(v=='show')?'visible':(v=='hide')?'hidden':v;
	v=(v=='show')?'block':(v=='hide')?'none':v;
	}
	//obj.visibility = v;
	obj.display = v;
	}
	}
	}
}

function OpenNewWindow(url)
{
    popupWin=window.open(url, 'remote');
}

function GoSelectedHelpPage()
{
	if (document.getElementById('cbHelpPage'))
	{
	    var selectedPage = document.getElementById('cbHelpPage').value;
	    var targetPage = '';

	    if(selectedPage == 'HelpNewUser')
	    targetPage='Default.aspx?aType=YardimUyeOlma'

	    else if(selectedPage == 'HelpMyAdverts')
	    targetPage='Default.aspx?aType=YardimIlanlarim'

	    else if(selectedPage == 'HelpMyPage')
	    targetPage='Default.aspx?aType=YardimBenimSayfam'

	    else if(selectedPage == 'HelpMembershipType')
	    targetPage='Default.aspx?aType=YardimUyelikTipi'

	    else if(selectedPage == 'HelpMyMyArticles')
	    targetPage='Default.aspx?aType=YardimYazilarim'

	    else if(selectedPage == 'HelpNewAdvert')
	    targetPage='Default.aspx?aType=YardimIlanVerme'

	    else if(selectedPage == 'HelpNewWriter')
	    targetPage='Default.aspx?aType=YardimYazarOlma'

	    else if(selectedPage == 'HelpFAQ')
	    targetPage='Default.aspx?aType=YardimSSS'

	    if (targetPage != '')
	    window.location=targetPage;
	}
}
//----------------------------------------------------------------------------------------------------------------------------------------
//AramaSonuc ta OnPlan alani
var bannerCount = 6;
var maxBannerOnScreen = 5;
var bannerIndex = 0;

function HideAllBanners()
{
	for(i=0;i<this.bannerCount;i++)
	{
		if(document.getElementById('dvBanner_'+i))
		{
			document.getElementById('dvBanner_'+i).style.display='none';
			document.getElementById('dvBanner_'+i).className='banner100px';
		}
			
		if(document.getElementById('aBanner_'+i))
			document.getElementById('aBanner_'+i).style.display='none';			
	}
}

function ShowBanners(direction)
{
	HideAllBanners();

	if (direction=='ileri')
	{
		this.bannerIndex += 1;
		if (this.bannerIndex >= this.bannerCount-this.maxBannerOnScreen)
			this.bannerIndex = this.bannerCount-this.maxBannerOnScreen;

		index = this.bannerIndex;
		for(i=0;i<this.maxBannerOnScreen;i++)
		{
			if(document.getElementById('dvBanner_'+index))
				document.getElementById('dvBanner_'+index).style.display='block';
				
			index += 1;
		}	
	}
		
	if (direction=='geri')
	{
		this.bannerIndex -= 1;
		if (this.bannerIndex <= 0)
			this.bannerIndex = 0;

		index = this.bannerIndex;
		for(i=0;i<this.maxBannerOnScreen;i++)
		{
			if(document.getElementById('dvBanner_'+index))
				document.getElementById('dvBanner_'+index).style.display='block';
				
			index += 1;
		}	
	}
}	

function ShowDetail(bannerIdNo)
{
	if (bannerIdNo == this.bannerIndex+this.maxBannerOnScreen-1)
		this.bannerIndex += 1;
	else
	if (bannerIdNo == this.bannerCount-1)
		this.bannerIndex = this.bannerCount-this.maxBannerOnScreen+1;		
		
	HideAllBanners();
	
	index = this.bannerIndex;
	for(i=0;i<(this.maxBannerOnScreen-1);i++)
	{
		if(document.getElementById('dvBanner_'+index))
		{
		    if('dvBanner_'+bannerIdNo == 'dvBanner_'+index)
		        document.getElementById('dvBanner_'+index).className='banner200px';
		
			document.getElementById('dvBanner_'+index).style.display='block';
		}
			
		index += 1;
	}		
	
	document.getElementById('aBanner_'+bannerIdNo).style.display='block';
}
//----------------------------------------------------------
function isValidWebFirmName(string) {
if (string.search(/^[a-zA-Z0-9\-]{3,50}$/) != -1)
    return true;
else
    return false;
}