;Implement the Page Object pattern. The Page Object pattern represents the screens of your web app as a series of objects
;Author: henrytejera@gmail.com


; Function: AltavistaPage()
; This class exposes methods for Altavista page
;
; Returns:
;	Altavista Page Object
Func AltaVistaPage()
	Local $oClassObject = _AutoItObject_Create($oPage)
	Local $Repos = NewRepository("AltaVistaRepo");Set repository
	Local $oRepoAltaVista = $Repos.WebPage("Page.AltaVista") ;Object repository for Altavista Pages

	$oClassObject.Create()
	$oClassObject.url = "http://es.altavista.com/"

	;Methods
	_AutoItObject_AddMethod($oClassObject, "Open", "_Page_Open")
	_AutoItObject_AddMethod($oClassObject, "Search", "_Page_Search")

	;Properties
	_AutoItObject_AddProperty($oClassObject, "oRepo", $ELSCOPE_PUBLIC, $oRepoAltaVista)

	Return $oClassObject
EndFunc

Func _Page_Open($oSelf)
	$oSelf.oRepo.load ;Load Alta Vista Page repo

	$oSelf.oRepo.open($oSelf.url)
	If $oSelf.oRepo.input.item("search").wait = 1 Then
		$oSelf.result = 1
		$oSelf.resultDescription = "Open Alta Vista page"
	Else
		$oSelf.result = 0
		$oSelf.resultDescription = "Not display the Alta Vista page"
	EndIf
EndFunc

Func _Page_Search($oSelf,$sSearchCriteria)
	$oSelf.oRepo.load

	With $oSelf.oRepo
		.input.item("search" ).type($sSearchCriteria)
		.button.item("search").click
	EndWith
	Return $oSelf
EndFunc