function CustomJS()
    {
        $js = parent::CustomJS();
        if ($this->getPointer()->ServiceAreasLocations()->Count()) {
            $Count = 1;
            foreach ($this->getPointer()->ServiceAreasLocations() as $Location) {
                $js .= '
address_objects[' . $Count . '-1] = {
	"Title":"' . $Location->Title . '",
	"Address":"' . $Location->Address . '",
	"LatLng":[' . $Location->MapLatitude . ',' . $Location->MapLongitude . ']
};';
                $Count++;
            }
        }
        return $js;
    }
 function CustomJS()
 {
     $JS = parent::CustomJS();
     $FormConfig = $this->FormConfig();
     $JS .= "\n\$(document).ready(function(){\n\t\$(\"#Form_RenderForm\").validate({\n\t\t" . ($FormConfig['useNospam'] ? "useNospam: true," : null) . "\n\t});\n});\n\t\t\t";
     return $JS;
 }
    function CustomJS()
    {
        $js = parent::CustomJS();
        $js .= 'var MapType = "' . $this->MapType . '";
					var address_objects = [];';
        if ($locations = $this->Locations()) {
            foreach ($locations as $key => $l) {
                $js .= 'address_objects[' . $key . '] = {"Title":"' . $l->Title . '","Address":"' . $l->Address . '","LatLng":[' . $l->MapLatitude . ',' . $l->MapLongitude . ']};';
            }
        }
        $js .= 'var Avgs = ' . $this->Avgs() . ';
					var PageLink = "' . $this->Link() . '";';
        return $js;
    }
    function CustomJS()
    {
        $JS = parent::CustomJS();
        if (($PaypalStoreItems = $this->PaypalStoreItems()) && $PaypalStoreItems->Count()) {
            $JS .= '$(document).ready(function(){';
            foreach ($PaypalStoreItems as $PaypalStoreItem) {
                if (($ProductOptions = $PaypalStoreItem->PaypalItemOptions()) && $ProductOptions->Count()) {
                    $JS .= '$("#' . $ProductOptions->First()->OptionID() . '").attr("checked", "checked");';
                    foreach ($ProductOptions as $ProductOption) {
                        $JS .= '
								$("#' . $ProductOption->OptionID() . '").click(function(){
								$("#showprice_' . $ProductOption->FormID() . '").html("$ ' . $ProductOption->Get_Price() . '");
								$("#num_' . $ProductOption->FormID() . '").val("' . $ProductOption->Get_ItemID() . '");
								$("#price_' . $ProductOption->FormID() . '").val("' . $ProductOption->Get_Price() . '");
							});';
                    }
                }
            }
            $JS .= '});';
        }
        $this->extend('updateCustomJS', $JS);
        return $JS;
    }
 function CustomJS()
 {
     $js = parent::CustomJS();
     if ($all_images = DataObject::get('AlbumPage_Image', 'AlbumPageID=' . $this->ID)) {
         $first_id = false;
         $js .= "var images = [";
         $i = 0;
         $total = count($all_images);
         foreach ($all_images as $image) {
             if ($i == 0) {
                 $first_id = $image->ID;
             }
             $js .= "'" . $image->GetBigURL() . "'";
             if ($i + 1 < $total) {
                 $js .= ", ";
             }
             $i++;
         }
         $js .= "];";
         $js .= "var first_id = " . $first_id . ";";
         $js .= "var page_link = '" . $this->Link() . "';";
     }
     return $js;
 }